cryptImportkey
-
Hi! How do I calculate the value of dwBloblen of pbKeyBlob read from a file.Even if i use the number of byted read returned from the CFile read function the key import function fail.How does the know the receiving side know the size of KEYBLOB. ////read KEYBLOB from a received file CFile file; BYTE *pbKeyBlob1 = NULL; DWORD dwBlobLen1=512; //just for testing but doesnt work for RSA //signature pbKeyBlob1 = (BYTE*)malloc(dwBlobLen1); // Read the key BLOB from the file. if(file.Open("key.txt",CFile::modeRead)) { file.Read(pbKeyBlob1,dwBlobLen1); file.Close(); } // call CryptImportKey if(CryptImportKey( hProv, pbKeyBlob1, dwBlobLen1, 0, 0, &hPubKey)) { MessageBox("The key has been imported"); } else { MessageBox("The key import failed"); }
-
Hi! How do I calculate the value of dwBloblen of pbKeyBlob read from a file.Even if i use the number of byted read returned from the CFile read function the key import function fail.How does the know the receiving side know the size of KEYBLOB. ////read KEYBLOB from a received file CFile file; BYTE *pbKeyBlob1 = NULL; DWORD dwBlobLen1=512; //just for testing but doesnt work for RSA //signature pbKeyBlob1 = (BYTE*)malloc(dwBlobLen1); // Read the key BLOB from the file. if(file.Open("key.txt",CFile::modeRead)) { file.Read(pbKeyBlob1,dwBlobLen1); file.Close(); } // call CryptImportKey if(CryptImportKey( hProv, pbKeyBlob1, dwBlobLen1, 0, 0, &hPubKey)) { MessageBox("The key has been imported"); } else { MessageBox("The key import failed"); }
The length of the Key BLOB depends on its type. Take a look here: Base Provider Key BLOBs[^] But shouldn't the length equal the file length? You can obtain it using CFile's GetLength method after opening it. -- jlr http://jlamas.blogspot.com/[^]