-1

I'm using pointycastle to generate a new RSA-Key for asymmetric encryption of data. To identify the key I want the fingerprint/hash of that key. How do I get it?

Here is my code to generate the RSA key (feel free to give me feedback when I do something wrong or insecure):

final secureRandom = FortunaRandom();

final seedSource = Random.secure();
final seeds = <int>[];
for (int i = 0; i < 32; i++) {
  seeds.add(seedSource.nextInt(255));
}
secureRandom.seed(KeyParameter(Uint8List.fromList(seeds)));

final keyGen = RSAKeyGenerator()
  ..init(ParametersWithRandom(RSAKeyGeneratorParameters(BigInt.parse('65537'), 4096, 64), secureRandom));

final pair = keyGen.generateKeyPair();

final myPublic = pair.publicKey as RSAPublicKey;
final myPrivate = pair.privateKey as RSAPrivateKey;

What do I need hash exactly of my RSA key pair to get a fingerprint? sha1(myPublic.publicExponent)?

rekire
  • 47,260
  • 30
  • 167
  • 264
  • Although it's insignificant, you probably want `seedSource.nextInt(256)`. There's no *certificate* present anywhere in the question. As for hashing the public key, for RSA the public key consists of a modulus and a public exponent. Thus, I don't understand your last question *What do I need to hash exactly myPublic.publicExponent?*. – President James K. Polk Sep 02 '23 at 22:02

0 Answers0