Skip to content

Commit a2d2963

Browse files
committed
optional encrypted key
1 parent c9e1b69 commit a2d2963

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
FROM php:7.2-cli
1+
FROM php:7.4-cli
22

33
RUN apt-get update && apt-get install -y libdb5.3++-dev
44

5-
RUN curl -O --referer https://fossies.org/linux/misc/db-18.1.25.tar.gz/ \
6-
https://fossies.org/linux/misc/db-18.1.25.tar.gz \
7-
&& tar -zxf db-18.1.25.tar.gz && cd db-18.1.25/lang/php_db4/ \
5+
RUN curl -O --referer https://fossies.org/linux/misc/db-18.1.40.tar.gz/ \
6+
https://fossies.org/linux/misc/db-18.1.40.tar.gz \
7+
&& tar -zxf db-18.1.40.tar.gz && cd db-18.1.40/lang/php_db4/ \
88
&& phpize \
99
&& ./configure --with-db4 \
1010
&& make \
1111
&& make install \
1212
&& docker-php-ext-enable db4
1313

14-
RUN apt-get install libgmp-dev \
14+
RUN apt-get install -y libgmp-dev \
1515
&& docker-php-ext-install gmp

src/Item/MasterKey.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,13 @@ public function getDerivationIterations(): int
6868

6969
/**
7070
* Returns master key hash for hashcat.
71-
* @param EncryptedKey $encryptedKey
71+
* @param EncryptedKey|null $encryptedKey
7272
* @return string
73-
* @throws \AndKom\Bitcoin\Wallet\Exception
7473
*/
75-
public function getHash(EncryptedKey $encryptedKey): string
74+
public function getHash(EncryptedKey $encryptedKey = null): string
7675
{
77-
$encrypted = bin2hex($encryptedKey->getEncryptedPrivateKey());
78-
$public = bin2hex($encryptedKey->getPublicKey());
76+
$encrypted = $encryptedKey ? bin2hex($encryptedKey->getEncryptedPrivateKey()) : '00';
77+
$public = $encryptedKey ? bin2hex($encryptedKey->getPublicKey()) : '00';
7978
$master = substr(bin2hex($this->getEncryptedKey()), -64); // last two aes blocks should be enough
8079
$salt = bin2hex($this->getSalt());
8180

tests/WalletTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function testMasterKey()
3636
$this->assertEquals($mk->getDerivationMethod(), 0);
3737
$this->assertEquals($mk->getDerivationIterations(), 196349);
3838
$this->assertEquals($mk->getHash($key), '$bitcoin$64$681a195c345695c6e87396eb7f8aefbf4e098ed009a42a173bd6db863c24d464$16$98313fb978e6ef49$196349$96$efe4244d839af470418ee08b278ffd20510dcd105bd1aa3de016bf59c35f99b8537222a0e4a8ea1db2b6b795de697785$66$03f4c3e512b84d950cf7568966a89c9048526076a2654c907a43db8fb8f38db508');
39+
$this->assertEquals($mk->getHash(), '$bitcoin$64$681a195c345695c6e87396eb7f8aefbf4e098ed009a42a173bd6db863c24d464$16$98313fb978e6ef49$196349$2$00$2$00');
3940
}
4041

4142
public function testDecrypt()

0 commit comments

Comments
 (0)