genRsaKeyPair function
Generate RSA key pair for the authentication
Implementation
Future<Map> genRsaKeyPair() async {
/// Generate a key pair
var rsaKeyPair = await RSA.generate(2048);
/// JWK conversion of private and public keys
var publicKeyJwk = await RSA.convertPublicKeyToJWK(rsaKeyPair.publicKey);
var privateKeyJwk = await RSA.convertPrivateKeyToJWK(rsaKeyPair.privateKey);
publicKeyJwk['alg'] = "RS256";
return {
'rsa': rsaKeyPair,
'privKeyJwk': privateKeyJwk,
'pubKeyJwk': publicKeyJwk
};
}