Skip to content

v4.7.0 - Orléans

Latest

Choose a tag to compare

@Legrandin Legrandin released this 30 Nov 18:21

New features

  • Argon2 (RFC 9106) in Crypto.Protocol.KDF: argon2() derives keys, and argon2_hash()
    and argon2_check() store and check passwords as PHC strings ($argon2id$v=19$...),
    compatible with most other implementations. Argon2id, Argon2i and Argon2d are supported,
    the lanes run on as many threads as the CPU cores by default (threads), the blocks are computed with SSE2
    or AVX2 on x86, and Argon2Profile offers
    the recommended parameters of RFC 9106, OWASP and libsodium.
    argon2_check() rejects hashes that need too much memory (max_memory) or time (max_cost).
  • GH#843: import_key() of RSA, DSA and ECC accepts an OpenSSH certificate
    (such as ssh-rsa-cert-v01@openssh.com) and returns the certified public key.
    The certificate is not verified.
  • GH#402: Shamir.split() and Shamir.combine() accept 32-byte secrets and shares, in GF(2^256).
    With ssss=True, the shares are compatible with ssss -s 256 -D.

Resolved issues

  • ECC.import_key() showed binary data (as the curve name) in the error
    for an unsupported OpenSSH key type starting with ecdsa-sha2-.
  • DSA.construct(), DSA.import_key() and DSA.generate() (with domain) raise ValueError
    (instead of ZeroDivisionError) when q or p is 0.
  • DSA keys are limited to p and q of 16384 bits, as RSA keys:
    DSA.construct() and DSA.import_key() raise ValueError for larger ones,
    and for a q that is not smaller than p, before the primality tests.
    A large public key from an untrusted source could take minutes to import.
  • RSA.import_key() and DSA.import_key() raise ValueError (instead of IndexError)
    for an OpenSSH public key with missing components.
  • GH#493: DSS in mode 'fips-186-3' with a DSA key raises ValueError (instead of AttributeError)
    for an object that is not a hash, for instance an HMAC. Thanks to koolfy.
  • GH#493: An HMAC object created with a hash module (for instance, digestmod=SHA256) now has the attribute oid,
    as one created with a hash object (digestmod=SHA256.new()). Thanks to koolfy.
  • GH#974: ECC.import_key() accepts an OpenSSH public key with spaces in its comment.
    Thanks to mottopanikeiku.
  • With the parameter threads, a function no longer fails with RuntimeError when the system
    cannot create all the threads (for instance, because of a limit on the number of processes):
    the calling thread does their work.
  • GH#973: A DerSequence initialized with a tuple can now be modified like one initialized with a list.
    Thanks to mottopanikeiku.
  • GH#535: RSA.import_key() rejects a PKCS#1 private key (also inside PKCS#8)
    whose CRT components (exponent1, exponent2, coefficient) do not match the key.
    They were ignored and recomputed. Thanks to sfluhrer.
  • GH#535: RSA.generate() rejects a public exponent of 2^256 or more (the upper bound of FIPS 186).
    Thanks to Bl4omArchie.
  • GH#535: RSA.construct() no longer requires the private exponent to be coprime to the modulus.
    That check was redundant, and would have rejected (with negligible probability) a valid key.
    Thanks to sfluhrer.
  • GH#976: In deterministic mode (RFC 6979), DSS raised AssertionError when signing
    a hash that is 0 modulo the order (for instance, equal to the order). Thanks to Anton Efimow.
  • GH#972: Crypto.Util.asn1.DerNull accepted a NULL with non-empty contents (X.690, 8.8.2),
    so an RSA, EdDSA or XDH key (SubjectPublicKeyInfo or PKCS#8) whose NULL parameters
    carried extra bytes was imported as the same key. A PKCS#8 RSA key with parameters
    other than NULL is also rejected (RFC 8017, Appendix C). Thanks to Zulfareen Shaikh.

Other changes

  • Added the Wycheproof test vectors for PBKDF2 (with HMAC-SHA1, SHA-224, SHA-256, SHA-384 and SHA-512).
  • Faster imports, which matters for short scripts. With cffi, the declarations of the native modules
    are precompiled (cffi's out-of-line ABI mode), so neither the cffi package nor pycparser is imported.
    With ctypes, ctypes.util, platform and subprocess are no longer imported (about 20 ms less).
  • With Python 3.15+, more modules are imported only when they are first used (PEP 810).
  • GH#228: With -OO, PyCryptodome uses cffi too (instead of falling back to ctypes).