Hi James, PKCS1 v2 specifies that RSA must include parameters and the value is NULL. The unused bits field is necessary for asn1 bit strings, in this case is 0.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of James Vanns Sent: Tuesday, April 19, 2005 6:01 AM To: [email protected] Subject: X509PublicKey - non-standard additions?? In my quest for getting Java to open my Crypto++ RSA 1024-bit public key I've noted that RSAFunction inherits from X509PublicKey. X509PublicKey defines its method DEREncode as: void DEREncode(BufferedTransformation &bt) const { DERSequenceEncoder subjectPublicKeyInfo(bt); DERSequenceEncoder algorithm(subjectPublicKeyInfo); GetAlgorithmID().DEREncode(algorithm); DEREncodeAlgorithmParameters(algorithm); algorithm.MessageEnd(); DERGeneralEncoder subjectPublicKey( subjectPublicKeyInfo, BIT_STRING); subjectPublicKey.Put(0); // unused bits DEREncodeKey(subjectPublicKey); subjectPublicKey.MessageEnd(); subjectPublicKeyInfo.MessageEnd(); } Now, according to ASN1 syntax X509 public keys should be represented as: SubjectPublicKeyInfo ::= SEQUENCE { algorithm AlgorithmIdentifier, subjectPublicKey BIT STRING } So my question is: in the code above why are the algorithm parameters included? And whats the extra 'unused bits' for? Now, admittedly even though I have a modicum of understanding of Cryptography - my knowledge of PK standards is practically non existent so I apologise in advance for any misunderstandings on my part. I'm just trying to get Java to import my friggin key!! Java throws a BER Decode error, is this normal? To decode a DER encoded key with a BER decoding algorithm? I'm guessing it is. Any comments on my rantings above? Cheers (again), Jim -- James Vanns BSc (Hons) MCP Linux Systems Administrator Software Engineer (Linux / C & C++) Canterbury Christ Church University College Public Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x24045370
