Decrypt RC8032 PGP with Bouncy Castle .NET

1.1k views Asked by At

I am trying to decrypt a given PGP message with Bouncy Castle .NET. I have a string for the message, a stream for the private key, and a string for the passphrase. Looking online, it looks like the first thing to do with the key is the following:

var keyStream = PgpUtilities.GetDecoderStream(keyIn);
PgpSecretKeyRingBundle pgpSec = new PgpSecretKeyRingBundle(keyStream);

But I am getting the exception:

System.IO.IOException: 'unknown PGP public key algorithm encountered'

I used this useful tool https://cirw.in/gpg-decoder/ to find out more about my key and it looks like the Secret Key Packet and Signature Packet, have the unknown algorithm 0x16. I found a single source that said it is referring to RFC8032 but I am not quite sure.

I can't share my key but I found someone online who shared a throw-away key that looks to be in the same format here

Is this algorithm simply not supported by Bouncy Castle? Is there any way to decrypt messages with this types of keys in .NET?

Thanks!

1

There are 1 answers

0
ofrir On BEST ANSWER

This is fixed in the newest BouncyCastle (2.0) https://www.nuget.org/packages/BouncyCastle.Cryptography