On Tuesday, June 19, 2012 8:44:35 AM UTC-4, Krivak wrote:
>
>
> <SNIP>
>
 

> void GetPublicKeyFromCert(CryptoPP::BufferedTransformation & certin, 
>     CryptoPP::BufferedTransformation & keyout) 
> { 
>        BERSequenceDecoder x509Cert(certin); 
>        BERSequenceDecoder tbsCert(x509Cert); 
>
>        // ASN.1 from RFC 3280 
>        // TBSCertificate  ::=  SEQUENCE  { 
>        // version         [0]  EXPLICIT Version DEFAULT v1, 
>
>        // consume the context tag on the version 
>        BERGeneralDecoder context(tbsCert,0xa0); 
>        word32 ver; 
>
>        // only want a v3 cert 
>        BERDecodeUnsigned<word32>(context,ver,INTEGER,2,2); 
>
>        // serialNumber         CertificateSerialNumber, 
>        Integer serial; 
>        serial.BERDecode(tbsCert); 
>
>        // signature            AlgorithmIdentifier, 
>        BERSequenceDecoder signature(tbsCert); 
>        signature.SkipAll(); 
>
>        // issuer               Name, 
>        BERSequenceDecoder issuerName(tbsCert); 
>        issuerName.SkipAll(); 
>
>        // validity             Validity, 
>        BERSequenceDecoder validity(tbsCert); 
>        validity.SkipAll(); 
>
>        // subject              Name, 
>        BERSequenceDecoder subjectName(tbsCert); 
>        subjectName.SkipAll(); 
>
>        // subjectPublicKeyInfo SubjectPublicKeyInfo, 
>        BERSequenceDecoder spki(tbsCert); 
>        DERSequenceEncoder spkiEncoder(keyout); 
>
> // My code: 
> RSA::PublicKey rsaServerPublicKey; 
> rsaServerPublicKey.Load(spki); 
> //rsaServerPublicKey.BERDecodePublicKey(spki, false /*optParams*/, 
> spki.MaxRetrievable()); 
> // Here it's going to "BER decode error".... 
> // End of My code
>  
>
My bad. With a SubjectPublicKeyInfo, you need to look at 
http://www.cryptopp.com/wiki/Keys_and_Formats.
 
Jeff

-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.

Reply via email to