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


Reply via email to