CryptImportKey returns NTE_BAD_TYPE
From: sunit (sunit_at_newsgroup.nospam)
Date: 10/26/05
- Next message: sunit: "Re: CryptImportKey returns NTE_BAD_TYPE"
- Previous message: stvp: "Windows Server 2003 SP1 DCOM policy"
- Next in thread: sunit: "Re: CryptImportKey returns NTE_BAD_TYPE"
- Reply: sunit: "Re: CryptImportKey returns NTE_BAD_TYPE"
- Reply: sunit: "Re: CryptImportKey returns NTE_BAD_TYPE"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Wed, 26 Oct 2005 18:45:49 +0530
I am importing my private keys using CryptImportkey ,but it returns an error NTE_BAD_TYPE
.My private keys are in the CrytoAPI PRIVATEKEYBLOB format in unencrypted form http://msdn.microsoft.com/library/default.asp?url=/library/en-us/seccrypto/security/private_key_blobs.asp
My private keys are stored in a file _privatekeyblob.First I found the size of the PRIVATEKEYBLOB file using API FindFirstFile and stored in dwKeyBlobLen. Then I stored the contents of PRIVATEKEYBLOB file in a buffer pbKeyBlob.
/*code for importing the private keys in conatainer*/
HCRYPTKEY hKey;
CRYPT_DER_BLOB BLOB;
BLOB.cbData=dwKeyBlobLen; //length of the keys in bytes
BLOB.pbData=pbKeyBlob;//private keys r stored in this buffer
//import the Private keys in the key container
if(!CryptImportKey(hCryptProv,// handle to key container
(BYTE*)&BLOB, //Blob which contains the private keys
dwKeyBlobLen,//length of the Blob
0,// unencrypted private keys
0,
&hKey))//pointer to handle of the imported key
.My private keys r in little endian order and the BLOBHEADER parmaters viz
bType is PRIVATEKEYBLOB bVersion is CUR_BLOB_VERSION (0x02)
I am not understanding where is the problem.Pls help me.
Pls consider my problem.Thanx in advance
- Next message: sunit: "Re: CryptImportKey returns NTE_BAD_TYPE"
- Previous message: stvp: "Windows Server 2003 SP1 DCOM policy"
- Next in thread: sunit: "Re: CryptImportKey returns NTE_BAD_TYPE"
- Reply: sunit: "Re: CryptImportKey returns NTE_BAD_TYPE"
- Reply: sunit: "Re: CryptImportKey returns NTE_BAD_TYPE"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]