English 中文(简体)
密码 CryptImport ERROR_INVALID_PARAMETER 但关键进口
原标题:CryptoAPI CryptImportKey fails with ERROR_INVALID_PARAMETER but imports the key

我正试图从PKCS第12号档案中进口RSA的私人钥匙。 我正在利用开放式特别安全局对P12进行整顿,然后我正试图利用CryptImportKey将钥匙输入强化的RSA供应商。

Ï create the blob exactly same way as I get it when I do export the key from CSP with CryptExportKey.

Lastly I do not want to use any session encryption as I am only parsing encrypted file and storing it into CSP. If I use

publickeystruc.aiKeyAlg := CALG_RSA_KEYX;

and

if not CryptImportKey(tmpprovider,addr(privkey),dwBlobLen,0,flags,hPubKey) then 
  errorCode := GetLastError;

然后,该功能失败,我获得ERROR_INVALID_PARAMETER错误。 但是,这些钥匙是进口的,而且正在全面运作(我试图与它签署,如果出口明显,我能够出口)。

兹宣布如下:

 hpubkey:PHCRYPTKEY;
 privkey:privkeyblob;

地点

  HCRYPTKEY   = ULONG;
  PHCRYPTKEY  = ^HCRYPTKEY;

其余为ger和 card。

问题已经解决,这是真正的 st。 我忘记,当我把最后的参数归为零时,就不提这一参数。

hPubKey^:=0;

hPubKey := 0;

感谢TLama向我指出了正确方向。

问题回答

你写道,你试图从PKCS第12号档案中进口RSA的私人钥匙。 在我看来,你应当使用PFXImportCertStore。 进口的样本可找到here。 如果你只需要私人钥匙,并节省费用,那么你可以用<代码”取代这一步骤。 CertAddCertificateContextToStore to CertGetCertificateContextProperty>。 <代码>PFXImportCertStore 创建主要集装箱自动。 http://msdn.microsoft.com/en-us/library/windows/desktop/a3814 2028v=vs.85)





相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签