KeyPair.generateRsa constructor
KeyPair.generateRsa(
{ - BigInt? exponent,
- int bitStrength = 2048,
})
Implementation
factory KeyPair.generateRsa({BigInt? exponent, int bitStrength = 2048}) {
exponent ??= BigInt.from(65537);
var generator = pc.RSAKeyGenerator()
..init(pc.ParametersWithRandom(
pc.RSAKeyGeneratorParameters(exponent, bitStrength, 5),
DefaultSecureRandom()));
var pair = generator.generateKeyPair();
return KeyPair(
publicKey: RsaPublicKey(
exponent: (pair.publicKey as pc.RSAPublicKey).publicExponent!,
modulus: (pair.publicKey as pc.RSAPublicKey).n!,
),
privateKey: RsaPrivateKey(
modulus: (pair.privateKey as pc.RSAPrivateKey).n!,
privateExponent:
(pair.privateKey as pc.RSAPrivateKey).privateExponent!,
firstPrimeFactor: (pair.privateKey as pc.RSAPrivateKey).p!,
secondPrimeFactor: (pair.privateKey as pc.RSAPrivateKey).q!,
));
}