[Mono-list] UTF8 Encoding of data in PKCS#7

Sebastien Pouliot sebastien.pouliot at gmail.com
Wed Jan 18 12:04:31 EST 2006


Hello Kim,

On Wed, 2006-01-18 at 12:39 +0100, Hellan.Kim KHE wrote:
> If you got a string you want PKCS#7 sign or envelope, are you then
> supposed to UTF8 encode it yourself before adding the data to the
> relevant Mono classes, or is that handled internally by Mono?
> 
> I got a string where I can either choose:
>   byte[] data = System.Text.Encoding.UTF8.GetBytes(myString);
> or
>   byte[] data = System.Text.Encoding.Default.GetBytes(myString);
> 
> The problem is compatibility with OpenSSL. If I choose to UTF8 encode it
> (first choice), the text I extract using OpenSSL is not correct and it
> still seems UTF8 encoded.

PKCS#7 is large, so "data" in PKCS#7 could be a lot of thing (i.e. I
think I know what you mean but I could be wrong).

One thing is sure, you're only providing that UTF8 bytes representing
the string (this is purely data and isn't valid ASN.1). If OpenSSL tries
to interpret this as (any kind of) a ASN.1 string it won't (and can't)
deduce the encoding.

Try creating the same PKCS#7 structure using OpenSSL, dump the ASN.1
content and compare it with Mono's. This may give you the hint you need.
-- 
Sebastien Pouliot  <sebastien at ximian.com>
Blog: http://pages.infinit.net/ctech/



More information about the Mono-list mailing list