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

RSA Public Key.

Fields
Methods
string algorithm() @property const nothrow @safe @nogc pure
string format() @property const nothrow @safe @nogc pure
const(ubyte)[] encoded() @property const
size_t toHash() const
bool opEquals(const Key other) const
void wipe() nothrow @nogc @trustedZeroizes the modulus and exponent in place.
Constructors

RSA Private Key.

Methods
string algorithm() @property const nothrow @safe @nogc pure
string format() @property const nothrow @safe @nogc pure
const(ubyte)[] encoded() @property const
size_t toHash() const
bool opEquals(const Key other) const
bool opEquals(const Object o) constObject-typed equality twin.
void wipe() nothrow @nogc @trustedZeroizes every key component in place.
Constructors
this(BigInt n, BigInt d, BigInt p = 0, BigInt q = 0, BigInt dP = 0, BigInt dQ = 0, BigInt qInv = 0, BigInt e = 0)
Methods
KeyPair generateKeyPair()Generates a new RSA key pair using the stored parameters.
size_t keySize() @property const @safe pure nothrow @nogcReturns: The key size in bits.
KeyPair generate(int bitLength, BigInt e = BigInt(65_537))Generates an RSA key pair with the given parameters.
Constructors
this(Random random, int bitLength = 2_048, BigInt e = BigInt(65_537))Constructs an RSAKeyPairGenerator.

Functions 13

fnubyte[] encodeRsaSpki(RSAPublicKey key)Encodes an RSA public key as a DER-encoded SubjectPublicKeyInfo (SPKI).
fnRSAPublicKey decodeRsaSpki(const(ubyte)[] der)Decodes an RSA public key from DER-encoded SubjectPublicKeyInfo (SPKI).
fnubyte[] encodeRsaPkcs1(RSAPrivateKey key)Encodes an RSA private key in PKCS#1 format.
fnRSAPrivateKey decodeRsaPkcs1(const(ubyte)[] der)Decodes an RSA private key from PKCS#1 format.
fnubyte[] encodeRsaPkcs8(RSAPrivateKey key)Encodes an RSA private key in PKCS#8 format (PrivateKeyInfo).
fnRSAPrivateKey decodeRsaPkcs8(const(ubyte)[] der)Decodes an RSA private key from PKCS#8 format (PrivateKeyInfo).
fnBigInt os2ip(const(ubyte)[] octets)
fnubyte[] i2osp(BigInt x, size_t xLen)
fnBigInt rsaDp(RSAPrivateKey key, BigInt c)RSA decryption primitive (RSADP) - unblinded version.
fnBigInt rsaDpBlinded(RSAPrivateKey key, BigInt c, Random random)RSA decryption primitive with blinding for side-channel resistance.
fnvoid mgf1(Hash hash, const(ubyte)[] seed, size_t maskLen, ubyte[] mask)