From: Lars U. <la...@kn...> - 2003-02-24 10:07:25
|
On Mon, Feb 24, 2003 at 07:22:34AM +0000, Chris Ridd wrote: > On 23/2/03 9:20 pm, Lars Uffmann <la...@kn...> wrote: Hello Chris, thanks for your help. The following ASN1 worked: AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, parameters ANY } SubjectPublicKeyInfo ::= SEQUENCE { algorithm AlgorithmIdentifier, subjectPublicKey BIT STRING } -- from ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2.asn RSAPublicKey ::= SEQUENCE { modulus INTEGER, -- (Usually large) n = p*q publicExponent INTEGER -- (Usually small) e } I attached an updated version of my script, this one only decodes the publick key in DER, but support for Convert::PEM schould be trivial. > I don't think the ASN.1 of the public key looks like that. Using dumpasn1 > (grab from http://www.cs.auckland.ac.nz/~pgut001/) on the public.der file I > get something like: > > 0 92: SEQUENCE { > 2 13: SEQUENCE { > 4 9: OBJECT IDENTIFIER '1 2 840 113549 1 1 1' > 15 0: NULL > : } > 17 75: BIT STRING, encapsulates { > 20 72: SEQUENCE { > 22 65: INTEGER > : 00 B9 79 14 11 64 33 67 A2 2D 8F 7A E0 F4 DD BD > : 1E 4E 3F 88 73 19 A5 FD D2 24 17 4F 0C 68 D8 52 > : A2 EA BB B5 00 ED 32 1A AF AA C2 B8 A1 97 1D 6D > : 99 4E C5 58 80 CE 8D 6A AC 7E 9C 6F D4 B5 49 E4 > : 71 > 89 3: INTEGER 65537 > : } > : } > : } > > In other words there's some extra wrapper, and your encoded public key SEQ > is actually inside a BIT STRING. > > I'd be inclined to try telling Convert::ASN1 that the BIT STRING is actually > a [UNIVERSAL 3 IMPLICIT] OCTET STRING so you can get the raw bytes of the > bit string out, and then do a second parse using your original ASN.1 on that > octet string. Actually BIT STRING worked fine. > But you can't have too many ASN.1 decoders as far as I'm concerned ;-) I'll try dumpasn1, seems to be _really_ usefull. regards, Lars |