Re: how can i export the private key as PKCS#7 ?



CryptExportKey() exports MS-specific format keyblobs.

For CryptExportPKCS8(), for the usual default OID you can use is:
String szOID_RSA_RSA ="1.2.840.113549.1.1.1" ;

See source code here for an implementation (in .NET but usage of capi
function parameters is same in C code):
http://www.jensign.com/KeyPal

- Mitch Gallant
MVP Security

"wuhao" <wuhao@xxxxxxxxxxx> wrote in message
news:OhjoJwEaGHA.3612@xxxxxxxxxxxxxxxxxxxxxxx
CryptExportKey export the privatekey,but it seemed the format is pkcs11,


i have tried CryptExportPKCS8,but but what's private key OID for my
certificate request?





//here are my source code
void exportPrivateKey(HCRYPTPROV &hCryptProv,DWORD
&dwKeySpec,PCCERT_CONTEXT &pSignerCertContext)
{
HCRYPTKEY phUserKey;
BYTE *pbKeyBlob;
DWORD dwBlobLen;

//CryptGetUserKey(hCryptProv,dwKeySpec,&phUserKey);
if(CryptExportPKCS8(
hCryptProv,
dwKeySpec,
"wh-ok",
0,
NULL,
NULL,
&dwBlobLen))
{
printf("Size of the BLOB for the public key determined. \n");
}
else
{
MyHandleError("Error computing BLOB length.");
}
//--------------------------------------------------------------------
// Allocate memory for the pbKeyBlob.

if(pbKeyBlob = (BYTE*)malloc(dwBlobLen))
{
printf("Memory has been allocated for the BLOB. \n");
}
else
{
MyHandleError("Out of memory. \n");
}
//--------------------------------------------------------------------
// Do the actual exporting into the key BLOB.

if(CryptExportPKCS8(
hCryptProv,
dwKeySpec,
"wh-ok",
0x8000,
NULL,
pbKeyBlob,
&dwBlobLen))
{
printf("Contents have been written to the BLOB. \n");
}
else
{
MyHandleError("Error during CryptExportKey.");
}

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
FILE *fppp=fopen("pri.key","wb");
fwrite(pSignerCertContext->pbCertEncoded,1,pSignerCertContext->cbCertEncoded,fppp);
fclose(fppp);
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////}



.



Relevant Pages

  • Re: Binary Image Contour
    ... point on the edge of the blob. ... I want to contour it and get all the ege ... I have source code for extracting boundaries of blobs, ... At my Applications page, the Image Analysis ...
    (comp.graphics.algorithms)
  • Re: Binary Image Contour
    ... point on the edge of the blob. ... Could you please tell me a fast contouring algorithm or C/C++ code for ... I have source code for extracting boundaries of blobs, ... At my Applications page, the Image Analysis ...
    (comp.graphics.algorithms)