2

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?

T.S.
  • 18,195
  • 11
  • 58
  • 78
user1645334
  • 89
  • 1
  • 7
  • also, see this http://stackoverflow.com/questions/30743119/using-cmsenvelopeddata-with-cmssigneddata-to-verify-signed-data Still no answer – T.S. Jun 26 '15 at 17:55
  • @T.S. That's not so strange. It first goes on a bit about encryption, and then it suddenly asks how to verify the signature without any kind of indication what the message even looks like. – Maarten Bodewes Jun 27 '15 at 22:51

2 Answers2

0

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.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
0

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.

  • 1
    Don't go off writing your own ASN.1/BER parser though. That's going to end in tears. – Maarten Bodewes Jun 29 '15 at 20:09
  • according to security requirements I should use internal DER/BER parser. In less secure projects I use C ASN compiler http://lionet.info/asn1c/compiler.html and it's easier. –  Jun 29 '15 at 20:25
  • yes - sometimes I fix bugs in this internal parser. –  Jun 29 '15 at 20:34