generateRsaKeyPair static method
Future<CommercioKeyPair<CommercioRSAPublicKey, CommercioRSAPrivateKey> >
generateRsaKeyPair({
- required CommercioRSAKeyType keyType,
- int bytes = 2048,
Generates a new RSA key pair having the given bytes
length.
If no length is specified, the default is going to be 2048.
Implementation
static Future<CommercioKeyPair<CommercioRSAPublicKey, CommercioRSAPrivateKey>>
generateRsaKeyPair({
required CommercioRSAKeyType keyType,
int bytes = 2048,
}) async {
final rsa = RSAKeyGeneratorParameters(BigInt.from(65537), bytes, 5);
final params = ParametersWithRandom(rsa, _getSecureRandom());
final keyGenerator = RSAKeyGenerator();
keyGenerator.init(params);
final keyPair = keyGenerator.generateKeyPair();
return CommercioKeyPair(
CommercioRSAPublicKey(
keyPair.publicKey as RSAPublicKey,
keyType: keyType,
),
CommercioRSAPrivateKey(keyPair.privateKey as RSAPrivateKey),
);
}