Skip to content

Commit

Permalink
optional encrypted key
Browse files Browse the repository at this point in the history
  • Loading branch information
andkom committed Oct 16, 2022
1 parent c9e1b69 commit a2d2963
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM php:7.2-cli
FROM php:7.4-cli

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

RUN curl -O --referer https://fossies.org/linux/misc/db-18.1.25.tar.gz/ \
https://fossies.org/linux/misc/db-18.1.25.tar.gz \
&& tar -zxf db-18.1.25.tar.gz && cd db-18.1.25/lang/php_db4/ \
RUN curl -O --referer https://fossies.org/linux/misc/db-18.1.40.tar.gz/ \
https://fossies.org/linux/misc/db-18.1.40.tar.gz \
&& tar -zxf db-18.1.40.tar.gz && cd db-18.1.40/lang/php_db4/ \
&& phpize \
&& ./configure --with-db4 \
&& make \
&& make install \
&& docker-php-ext-enable db4

RUN apt-get install libgmp-dev \
RUN apt-get install -y libgmp-dev \
&& docker-php-ext-install gmp
9 changes: 4 additions & 5 deletions src/Item/MasterKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,13 @@ public function getDerivationIterations(): int

/**
* Returns master key hash for hashcat.
* @param EncryptedKey $encryptedKey
* @param EncryptedKey|null $encryptedKey
* @return string
* @throws \AndKom\Bitcoin\Wallet\Exception
*/
public function getHash(EncryptedKey $encryptedKey): string
public function getHash(EncryptedKey $encryptedKey = null): string
{
$encrypted = bin2hex($encryptedKey->getEncryptedPrivateKey());
$public = bin2hex($encryptedKey->getPublicKey());
$encrypted = $encryptedKey ? bin2hex($encryptedKey->getEncryptedPrivateKey()) : '00';
$public = $encryptedKey ? bin2hex($encryptedKey->getPublicKey()) : '00';
$master = substr(bin2hex($this->getEncryptedKey()), -64); // last two aes blocks should be enough
$salt = bin2hex($this->getSalt());

Expand Down
1 change: 1 addition & 0 deletions tests/WalletTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function testMasterKey()
$this->assertEquals($mk->getDerivationMethod(), 0);
$this->assertEquals($mk->getDerivationIterations(), 196349);
$this->assertEquals($mk->getHash($key), '$bitcoin$64$681a195c345695c6e87396eb7f8aefbf4e098ed009a42a173bd6db863c24d464$16$98313fb978e6ef49$196349$96$efe4244d839af470418ee08b278ffd20510dcd105bd1aa3de016bf59c35f99b8537222a0e4a8ea1db2b6b795de697785$66$03f4c3e512b84d950cf7568966a89c9048526076a2654c907a43db8fb8f38db508');
$this->assertEquals($mk->getHash(), '$bitcoin$64$681a195c345695c6e87396eb7f8aefbf4e098ed009a42a173bd6db863c24d464$16$98313fb978e6ef49$196349$2$00$2$00');
}

public function testDecrypt()
Expand Down

0 comments on commit a2d2963

Please sign in to comment.