pypi pycryptodome 4.6.0
v4.6.0 - Nice

one hour ago

New features

  • New module Crypto.PublicKey.SLHDSA, for SLH-DSA keys (FIPS 205), with all
    twelve parameter sets (SHA2 and SHAKE, categories 1, 3 and 5, small or fast).
    The algorithms of FIPS 205 are in Python; the functions that compute most of the hashes
    (WOTS+ chains, XMSS and FORS tree nodes) are in C, on top of the SHA-2 and Keccak code
    of PyCryptodome.
    The C functions compute several hashes at once where the CPU allows it:
    4 SHA-256 hashes with the Intel SHA extensions (interleaved) or the ARMv8 SHA-256
    instructions, 8 SHA-256 hashes with AVX2 (when there are no SHA extensions),
    and 4 SHAKE256 hashes with AVX2 and BMI2 (4-way Keccak).
    The WOTS+ chains of a key pair are computed in one call to C.
  • SLH-DSA keys can be exported and imported as defined in RFC 9909 (pure SLH-DSA):
    public keys as X.509 SubjectPublicKeyInfo (also from certificates),
    private keys as PKCS#8 OneAsymmetricKey (also encrypted), in DER or PEM.
  • New module Crypto.Signature.slhdsa, for SLH-DSA and HashSLH-DSA signatures (FIPS 205),
    hedged (default) or deterministic, with an optional context.
  • SLH-DSA signing, key generation and construct() (which checks the private key)
    accept a parameter threads, to compute the XMSS and FORS trees on several threads.
    With 8 threads, signing with the s parameter sets is 3.5x to 5x faster.
  • Crypto.PublicKey.SLHDSA also supports the six parameter sets of the initial public
    draft of NIST SP 800-230 (April 2026), such as SLH_DSA_SHA2_128_24: smaller signatures
    and faster verification, but each key must sign at most 2^24 messages, and key generation
    and signing take minutes (use threads). The draft may still change: their support is
    experimental, and they must not be used in production.
  • New self-test option --include-very-slow-tests, for the tests marked very_slow
    (like key generation and signing with the SP 800-230 parameter sets, which take about
    half an hour): they do not run otherwise.
  • New module Crypto.Cipher.AEGIS, for the authenticated ciphers AEGIS-128L and
    AEGIS-256 (RFC 10032), with 16- or 32-byte tags. They use the AES instructions of the CPU
    (AES-NI or the ARMv8 Cryptography Extensions): AEGIS-128L is then 3 to 5 times faster
    than AES-GCM. Without them, the AES round is bitsliced (constant time), with NEON
    on ARM and SSE2 on x86; on 64-bit ARM, AEGIS-128L is then still faster than
    ChaCha20-Poly1305.

Breaking changes

  • In Crypto.Signature.mldsa.new(), the context can only be passed as a keyword
    argument (context=), as for Crypto.Signature.slhdsa.new().

Resolved issues

  • Security, GH#968: ECC.construct(), and so ECC.import_key(), accepted the point at infinity
    as a public key on the NIST P curves and secp256k1 (for instance, 04 followed by zero bytes
    in a SubjectPublicKeyInfo). ECDSA signatures for such a key can be forged without
    any secret. It is now rejected with ValueError. Thanks to Zulfareen Shaikh.
  • Security, GH#969: DSA.construct(), and so DSA.import_key(), accepted public keys
    equal to 1 or outside the subgroup of order q (for instance, p - 1).
    For y = 1, a signature can be forged on any message without any secret.
    They are now rejected with ValueError (NIST SP 800-89, 5.3.1). Thanks to Zulfareen Shaikh.
  • GH#966: in the decrypt_and_verify() method of GCM, CCM, EAX and SIV, the output buffer
    is filled with zeroes if the MAC tag is not valid, so that no unauthenticated plaintext
    is left in it (as GCM-SIV already did). Thanks to Zulfareen Shaikh.
  • Security: decoding a DER INTEGER took time quadratic in its length, so a crafted
    key of a few hundred KB (for instance, for RSA.import_key) kept the CPU busy for minutes.
    It now takes linear time. Decoding an OBJECT IDENTIFIER had the same problem: its
    subidentifiers are now limited to 128 bytes. Thanks to netherportal3.
  • GH#965: DSA key import now rejects non-integer domain parameters with ValueError. Thanks to Mrmaxmeier.
  • GH#963: Fixed the build on the x32 ABI (ILP32 on x86-64). Thanks to Kenny Cheng.
  • GH#864: The type hints of the scalar multiplication of EC points accept Integer objects.
    Thanks to danrr and hakarrr.

Don't miss a new pycryptodome release

NewReleases is sending notifications on new releases.