decapitation
decapitation

Reputation: 131

Smallest RSA Key File Size possible

I'm trying to get the smallest rsa key pair file size possible to save with extra encryption on a QR-Code. I'd like the size to be as close as possible to the default 2048 bits, but unfortunatly I've only managed to export it with the additional CRT-Data, which is only usefull for faster calculation. To me size is more important than speed.

I'm using BouncyCastle and managed to create an AsymmetricCipherKeyPair. The "oversized" Private Key i managed to get by using:

AsymmetricKeyParameter rsaPri = res.Private;
PrivateKeyInfo p = PrivateKeyInfoFactory.CreatePrivateKeyInfo(rsaPri);
byte[] piby = p.Attributes.GetEncoded();

Where res is equal to the mentioned AsymmetricCipherKeyPair

How can I achieve only getting e,N and d,N from Keypair?

And further more, how can I import it again?

I've done multiple hours of research but I'm strugging to wrap my head around it.

Any assistance is apprechiaded :)

Upvotes: 0

Views: 77

Answers (1)

decapitation
decapitation

Reputation: 131

as expected there is an easy way of doing this: as progman stated, one can easily parse the AsymmetricKeyParameter as RsaKeyParameters and extract the values I was looking for.

Upvotes: 1

Related Questions