How to parse CMS (RFC 5652)

1.7k views Asked by At

I consume a java web service function that returns byte array which is in CMS (RFC 5652) format.

Is there a way to parse signed data from this byte array in c# or vb.net?

2

There are 2 answers

0
Maarten Bodewes On

Not without a library. You were smart enough not to ask for one though. So take a look at the Bouncy Castle libraries for C# / .NET.

3
AudioBubble On

This CMS byte array is serialization with ASN.1 standard. C# has ASN.1 parser.

  • First approach is to use high level library like Bouncy Castle (very good).
  • The second approach is harder but more flexible: understand ASN.1 structure (provided in RFC) and parse with some ASN.1 parser.

In some countries the second approach is the only possible solution because some elements in CMS (like AlgorithmParameters) depend on local cryptography standards (not implemented in high level library) and some PKI software can implement those standards incorrectly - in proprietary way.