ddn.crypto.key.rsa
RSA Keys, Primitives, and Key Generator.
Side-Channel Resistance: This module provides RSA blindingfor private key operations to prevent timing side-channel attacks. Use rsaDpBlinded instead of rsaDp for security-critical applications.
Types 3
classRSAPublicKey : PublicKey
classRSAPrivateKey : PrivateKey
Methods
KeyPair generateKeyPair()Generates a new RSA key pair using the stored parameters.KeyPair generate(int bitLength, BigInt e = BigInt(65_537))Generates an RSA key pair with the given parameters.private
BigInt generatePrime(int bits, BigInt e)private
bool millerRabin(BigInt n, int k)Functions 16
private fn
ubyte[] bigIntToBytes(BigInt val)Converts a non-negative BigInt to minimal big-endian unsigned bytes.fn
ubyte[] encodeRsaSpki(RSAPublicKey key)Encodes an RSA public key as a DER-encoded SubjectPublicKeyInfo (SPKI).fn
RSAPublicKey decodeRsaSpki(const(ubyte)[] der)Decodes an RSA public key from DER-encoded SubjectPublicKeyInfo (SPKI).fn
ubyte[] encodeRsaPkcs8(RSAPrivateKey key)Encodes an RSA private key in PKCS#8 format (PrivateKeyInfo).fn
RSAPrivateKey decodeRsaPkcs8(const(ubyte)[] der)Decodes an RSA private key from PKCS#8 format (PrivateKeyInfo).fn
BigInt modInverse(BigInt a, BigInt n)fn
BigInt rsaEp(RSAPublicKey key, BigInt m)fn
BigInt rsaDpBlinded(RSAPrivateKey key, BigInt c, Random random)RSA decryption primitive with blinding for side-channel resistance.private fn
BigInt generateBlindingFactor(BigInt n, Random random)Generates a random blinding factor for RSA.