Hello Hai,

PFX aka PKCS#12 is a format specified in ASN.1 for storing data like private keys.
DER specifies how to encode data whose format is specified as ASN.1.

Almost all X.509 related data can be stored with DER encoding. For example, your PFX file is also DER encoded. Thus, with the information you have told us, we do not know the actual format of your binary file. Therefore we need more information to tell how to decode this binary file. Maybe you have a file extension?

Encoding and decoding is also something completely different than encryption and decryption. For the former, you just have to know the specific format used and for the latter, you have to have a cryptographic key. Since you have a private key and it is related to your "binary file", this file is probably encrypted with an asymmetric encryption algorithm like RSA. Maybe it's a CMS file?

If you just want to decrypt a single file, I suggest you use openssl with the cms command. This is easier than writing your own application with Bouncy Castle.


Best,

Christoph


On 12.01.2013 00:22, Hai Ning wrote:

I have a binary file someone sent me. I am told it is DER encoded and I have the private key in a PFX format.

How do I use BC to decode this file using C#? Is there any sample code? Thanks.

-Hai


Reply via email to