Hello all,
please is here anyone who can help me?
I haven't yet succeeded to extract the PrivateKey from RSA X509 certificate.
Has anyone an experience with that issue?
Could you please give me a hint or even better send a piece of code with an
example?
I'm just playing with the example at: http://www.cryptopp.com/wiki/X.509
(see below). However I can't succeed to transfer "spki" of "keyout" to
"RSA::PublicKey rsaServerPublicKey". Please below section "// My code:". -
What's wrong?
Thanks in advance for an answer.
Krivak
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
spki.CopyTo(spkiEncoder);
spkiEncoder.MessageEnd();
spki.SkipAll();
tbsCert.SkipAll();
x509Cert.SkipAll();
}
--
View this message in context:
http://old.nabble.com/Using-certificates-in-crypto%2B%2B-tp33964188p34036160.html
Sent from the Crypto++ Users mailing list archive at Nabble.com.
--
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.