DEREncode() encodes the key into a subjectPublicKeyInfo. DEREncodeKey()  
encodes it into the subjectPublicKey inside subjectPublicKeyInfo, but
without the BIT STRING header. I'll add some inline documentation about 
this.

About the second question, reference material like the above should go
into the inline comments. Tutorials and frequently asked questions should
go into the FAQ.

On Sun, Oct 27, 2002 at 11:10:25AM -0500, Zooko wrote:
> 
> It took me a long time to figure out that I was getting a BERDecodeErr when 
> loading a private key from a file because it had been encoded with 
> "->DEREncode()" and was getting decoded with "->BERDecodeKey()".
> 
> I have a couple of questions:
> 
> 1.  What is the difference between the two encodings?  An in-line comment 
> (quoted below) suggests maybe the "EncodeKey()" variant is X509 spec?
> 
> 2.  A meta-issue: where will documentation which explains such issues 
> ultimately live?  In richer in-line comments?  In Denis Bider's tutorial?  The 
> auto-FAQ?  What's is your grand plan, Wei, for Crypto++ doc as Crypto++ 
> becomes more widely used?  (About which more in a separate message.)
> 
> Regards,
> 
> Zooko
> 
> ------- begin excerpt from rsa.h:
>       // X509PublicKey
>       OID GetAlgorithmID() const;
>       void BERDecodeKey(BufferedTransformation &bt);
>       void DEREncodeKey(BufferedTransformation &bt) const;
> ------- end excerpt from rsa.h:
> 

Reply via email to