ddn.crypto.key.rsa
RSA Keys, Primitives, and Key Generator.
Side-Channel Resistance: This module provides RSA blinding for private key operations to prevent timing side-channel attacks. Use rsaDpBlinded instead of rsaDp for security-critical applications.
Types 3
classRSAPublicKey : PublicKey
RSA Public Key.
Methods
size_t toHash() constclassRSAPrivateKey : PrivateKey
RSA Private Key.
Methods
size_t toHash() constMethods
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
bool primeDistanceOk(BigInt p, BigInt q, int bitLength) staticValidates the distance between the two primes.private
BigInt generatePrime(int bits, BigInt e)private
bool millerRabin(BigInt n, int k)private
BigInt millerRabinBase(const(ubyte)[] buf, BigInt n) staticMaps random octets to a Miller-Rabin witness base.Functions 14
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.