From: Jeremy Chaney Jeremy on
I'm trying to use the BerDecoder, but even in the simple sample below, I get
the exception "The "format" string contains an invalid character."

Here is my sample code:
byte[] integer1 = {1,2,3,4};
byte[] integer2 = {5,6,7,8};
Object[] data = { integer1, integer2 };

byte[] encodedBytes =
System.DirectoryServices.Protocols.BerConverter.Encode("{oo}", data);

Object[] decodedData =
System.DirectoryServices.Protocols.BerConverter.Decode("{oo}", encodedBytes);

What I really want to do is decode a PKCS.1 private key, but I don't know
what format string to use. I've manually decoded the byte array and I can see
that there are 128 byte "integers" (described with the 0x02 identifier), but
on my sample above, passing a byte array with a format string of "{i}" causes
the Encode function to throw an exception (whereas in the given sample Encode
succeeds, but Decode throws)...

All advice is welcome.
Thanks,
--Jeremy

From: Jeremy Chaney on
Hello.... anyone out there? Should I repost this to another group? Security
perhaps?

"Jeremy Chaney" wrote:

> I'm trying to use the BerDecoder, but even in the simple sample below, I get
> the exception "The "format" string contains an invalid character."
>
> Here is my sample code:
> byte[] integer1 = {1,2,3,4};
> byte[] integer2 = {5,6,7,8};
> Object[] data = { integer1, integer2 };
>
> byte[] encodedBytes =
> System.DirectoryServices.Protocols.BerConverter.Encode("{oo}", data);
>
> Object[] decodedData =
> System.DirectoryServices.Protocols.BerConverter.Decode("{oo}", encodedBytes);
>
> What I really want to do is decode a PKCS.1 private key, but I don't know
> what format string to use. I've manually decoded the byte array and I can see
> that there are 128 byte "integers" (described with the 0x02 identifier), but
> on my sample above, passing a byte array with a format string of "{i}" causes
> the Encode function to throw an exception (whereas in the given sample Encode
> succeeds, but Decode throws)...
>
> All advice is welcome.
> Thanks,
> --Jeremy
>