use cryptography library for pbkdf2 function
This commit is contained in:
parent
7374b53130
commit
b001c1a792
3 changed files with 9 additions and 9 deletions
2
.github/workflows/pylint.yaml
vendored
2
.github/workflows/pylint.yaml
vendored
|
|
@ -29,7 +29,7 @@ jobs:
|
|||
run: |
|
||||
python3 -m pip install gmpy2 cryptography pynacl ecdsa aiohttp requests pexpect scrypt semantic-version
|
||||
python3 -m pip install pycryptodomex pysocks pycoin ipaddress varint pylint
|
||||
python3 -m pip install --no-deps py_ecc==1.6.0 mypy_extensions==0.4.1 monero pbkdf2
|
||||
python3 -m pip install --no-deps py_ecc==1.6.0 mypy_extensions==0.4.1 monero
|
||||
|
||||
- name: Check the code with Pylint static code analyzer
|
||||
env:
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
pycryptodomex
|
||||
pbkdf2
|
||||
|
|
|
|||
|
|
@ -48,13 +48,14 @@ def decrypt_keystore(data,passwd,mac_algo=None,mac_params={}):
|
|||
elif kdf == 'pbkdf2':
|
||||
if (prf := parms.get('prf')) != 'hmac-sha256':
|
||||
die(1, f"unsupported hash function {prf!r} (must be 'hmac-sha256')")
|
||||
from pbkdf2 import PBKDF2
|
||||
hashed_pw = PBKDF2(
|
||||
passphrase = passwd,
|
||||
salt = bytes.fromhex(parms['salt']),
|
||||
iterations = parms['c'],
|
||||
digestmodule = 'sha256',
|
||||
).read(parms['dklen'])
|
||||
from cryptography.hazmat.primitives import hashes
|
||||
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
|
||||
hashed_pw = PBKDF2HMAC(
|
||||
algorithm = hashes.SHA256(),
|
||||
length = parms['dklen'],
|
||||
salt = bytes.fromhex(parms['salt']),
|
||||
iterations = parms['c']
|
||||
).derive(passwd)
|
||||
# see:
|
||||
# https://github.com/xchainjs/xchainjs-lib.git
|
||||
# https://github.com/xchainjs/foundry-primitives-js.git
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue