RE: Public key formatting
- From: lelteto <lelteto@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 19 Dec 2006 08:30:00 -0800
I am almost certain that the PublicKey blob is in DER encoded format (like
the rest of the certificate), not Base64 encoded, so you would still need to
correctly decode that blob. Check the blob's format manually and you will see
what format it is in.
Laszlo Elteto
SafeNet, Inc.
"yetty" wrote:
I get a public key blob in byte format. I want to extract the components of.
the public key and save it in a file so that I can send this public key in
the right format to a function that will very the signed xml document. I
have tried using base64 encoding but that did not help out.
CERT_NAME_BLOB cnb;
cnb.cbData = strlen("Administrator");
cnb.pbData = (BYTE*)("Administrator");
pCert = CertFindCertificateInStore(
hCertStore,
ENCODING_TYPE,
0,
CERT_FIND_SUBJECT_STR,//CERT_FIND_ANY,
L"Administrator",
NULL);
if (!pCert) {
printf("Failed to find certificate in store\n");
return NULL;
}
cbb = pCert->pCertInfo->SubjectPublicKeyInfo.PublicKey;
for(unsigned int i = 0 ;i < cbb.cbData; i++)
{
printf("%c",cbb.pbData[i]);
}
DWORD dwSize = Base64EncodeGetRequiredLength((int)cbb.cbData);
DWORD dwErr;
LPSTR pEncodedString = (LPSTR)malloc(sizeof(char)*dwSize);
LPBYTE pRandomBuf = NULL;
....
if (!Base64Encode(cbb.pbData, cbb.cbData, pEncodedString, (int*) &dwSize,
ATL_BASE64_FLAG_NOPAD
))
{
Base64Encode(cbb.pbData, cbb.cbData, pEncodedString, (int*) &dwSize,
ATL_BASE64_FLAG_NOPAD
);
dwErr = GetLastError();
}
printf("The public key blob is as follows - %s.\n",pEncodedString);
...
Regards
Yesh
"lelteto" wrote:
What do you mean "cannot get"? What API functions are you using?
One issue may be endianness: certificates store public key values in big
endian (network byte order); while CAPI needs the values in little endian
byte order.
Laszlo Elteto
SafeNet, Inc.
"yetty" wrote:
I have signed an xml document using a certificate from the windows
certificate store
I want to get the corresponding public key and verify the signature. I am
unable to get the public key in the proper format to verify the signature
Thanks in advance.
yesh
- References:
- RE: Public key formatting
- From: yetty
- RE: Public key formatting
- Prev by Date: Status 80070057
- Next by Date: Re: Encryption Key for Enterprise Library
- Previous by thread: RE: Public key formatting
- Next by thread: Status 80070057
- Index(es):
Relevant Pages
|