From: Jesper Angelo on 27 Jul 2010 23:28 Hi, I'm trying to convert an array of bytes ( byte[] ) into an ASN.1 DER encoded memory stream: public static Stream ASN1(byte[] b) { Asn1Encodable Asn1Obj; using (var input = new Asn1InputStream(b)) { input.Position = 0; Asn1Obj = input.ReadObject(); } var ms = new MemoryStream(); var outputDer = new DerOutputStream(ms); outputDer.WriteObject(Asn1Obj); outputDer.Flush(); return ms; } However the Asn1InputStream.ReadObject() method only reads until position 22 of the original data (regardless of what data i feed it). Is there something I'm totally missing here regarding the ReadObject method? Thanks, Jesper Angelo jesper(a)angelo.net
From: Thomas on 28 Jul 2010 00:04 Hello, I don't know anything about whatever language you are using here (java ? urgh), but is the "b" array representing a DER object ? If not, ReadObject is not appropriate. Are you sure you understand the purpose of ReadObject ? I might be wrong but it seems to me you are doing a terrible mistake here. Surely there is a documentation and code samples on the internet ... I can't help you further because I refuse to dwell into the abomination that is java (for me, that is). Probably someone that uses BouncyCastle often can help you.
From: Jesper Angelo on 28 Jul 2010 02:15 On 7/27/2010 9:04 PM, Thomas wrote: > Hello, > I don't know anything about whatever language you are using here > (java ? urgh), but is the "b" array representing a DER object ? If > not, ReadObject is not appropriate. Are you sure you understand the > purpose of ReadObject ? I might be wrong but it seems to me you are > doing a terrible mistake here. Surely there is a documentation and > code samples on the internet ... I can't help you further because I > refuse to dwell into the abomination that is java (for me, that is). > Probably someone that uses BouncyCastle often can help you. It's C# Thanks, I'll check b again. Guess something is fishy in there... j-
From: rossum on 28 Jul 2010 09:58 On Tue, 27 Jul 2010 20:28:27 -0700, Jesper Angelo <jesper(a)angelo.net> wrote: >Hi, > >I'm trying to convert an array of bytes ( byte[] ) into an ASN.1 DER >encoded memory stream: > > public static Stream ASN1(byte[] b) > { > Asn1Encodable Asn1Obj; > using (var input = new Asn1InputStream(b)) > { > input.Position = 0; > Asn1Obj = input.ReadObject(); > } > > var ms = new MemoryStream(); > var outputDer = new DerOutputStream(ms); > outputDer.WriteObject(Asn1Obj); > outputDer.Flush(); > return ms; > } > >However the Asn1InputStream.ReadObject() method only reads until >position 22 of the original data (regardless of what data i feed it). > >Is there something I'm totally missing here regarding the ReadObject method? > > >Thanks, > >Jesper Angelo >jesper(a)angelo.net From what I remember of C#, ReadObject() is for reading a serialized object back in. Unless your input is a serialized Asn1Encodable you are likely to have problems. Is there a simple Read() or ReadBytes()? Either of those may be more suitable. Have you tried microsoft.public.dotnet.languages.csharp? I know microsoft have stopped supporting it but it is still going independent of MS. rossum
|
Pages: 1 Prev: ECDSA with naive message passing Next: Primitive tri/pentanomials |