wbond / asn1crypto

Python ASN.1 library with a focus on performance and a pythonic API
MIT License
335 stars 140 forks source link

Add scrypt KDF #226

Closed geitda closed 2 years ago

geitda commented 2 years ago

Add a new KDF algorithm type for scrypt. Field names are pulled exactly from RFC7914. Added some logic (but no direct tests for it) in EncryptionAlgorithm.kdf_hmac and EncryptionAlgorithm.kdf_iterations to return None as scrypt has no concept of those, but as it has both a salt and (optional) key_length parameter, EncryptionAlgorithm.kdf_salt and EncryptionAlgorithm.key_length can be left as-is. I created a test case modeled after the ccmparameters test - it loads an entire EncryptionAlgorithm but only tests the KdfAlgorithm part we're interested in. Again, additional tests for the `kdf*andkey_lengthproperties may be prudent. Creating other files to test with is easy usingopenssl pkcs8 -scryptand any of the optional switches that go with that (-scrypt_N N,-scrypt_r r, or-scrypt_p p`)

wbond commented 2 years ago

Sorry that I missed this earlier. Could you rebase on master so we can try and get all of the CI jobs to run? For some reason only a couple did.

wbond commented 2 years ago

Awesome, thank you for this enhancement!