CryptToAPI 的对称加密在2000下可以通过,为什么在98下总是连接不上CSP 呢 很急 (50分)

  • 主题发起人 主题发起人 jimiking
  • 开始时间 开始时间
J

jimiking

Unregistered / Unconfirmed
GUEST, unregistred user!
对称加密后,在2000环境下可以通过,但是在98下时候,总是连接不到CSP,<br><br>Function Encrypt53(Data53 :string):string;<br>begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Init;<br>&nbsp; &nbsp; &nbsp; &nbsp;if not &nbsp; CryptAcquireContext(@hProv, nil, nil,PROV_RSA_FULL, 0) then &nbsp; &nbsp; &nbsp;//连接缺省的csp<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;windows.MessageBox(0,'Erro during CryptAcquireContext','error..',MB_OK);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clear;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br><br>CryptAcquireContext(@hProv, nil, nil,PROV_RSA_FULL, 0)执行会有错误,请你指教。我做的对称加密在2000下通过,<br>到98下调试的时候需要注意些什么问题呢 &nbsp; 谢谢<br>在98下实现对称加密 &nbsp;,CryptAcquireContext的参数应该怎样取值呢<br><br>看了一下注册表的信息,有一个DSS的CSP可以用<br><br>但是CryptAcquireContext(@hProv, nil, nil,PROV_DSS, 0) 仍然会报错 <br><br>
 
Flag := CryptAcquireContext( hProv, nil, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PROV_RSA_FULL,0);<br>&nbsp;{ If this fails, try again &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp;{ initializing the default key set }<br>&nbsp;If Not Flag then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; Flag := CryptAcquireContext( hProv,nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nil,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PROV_RSA_FULL,CRYPT_NEWKEYSET);<br><br>
 
但是在98 下注册表中 &nbsp;HKEY_LOCAL_MACHINE\SOFTWARE\<br>Microsoft / Cryptography /Defaults<br>是显然没有PROV_RSA_FULL 服务的 &nbsp;
 
我不太明白你的意思<br><br>如果不行,你试试这样<br>Flag := CryptAcquireContext( hProv, nil, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MS_DEF_PROV,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PROV_RSA_FULL,0);<br>{ If this fails, try again &nbsp; &nbsp; &nbsp; &nbsp; }<br>{ initializing the default key set }<br>If Not Flag then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp;Flag := CryptAcquireContext( hProv,nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MS_DEF_PROV,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PROV_RSA_FULL,CRYPT_NEWKEYSET);<br>
 
这个参数代表的意义是 &nbsp;CSP的类型,在注册表中可以查找是否注册了这个服务<br>主要的类型有 &nbsp;<br>?PROV_RSA_FULL &nbsp; &nbsp; <br>?PROV_RSA_SIG<br>?PROV_DSS<br>?PROV_FORTEZZA<br>?PROV_MS_MAIL<br><br>PROV_RSA_FULL &nbsp; &nbsp; 在2000的注册表中是有的,但是在98 下没有注册 该服务,可以用<br>我上面的路径去看的
 
你先看看你的windows98机器上有没有rsa*.dll(在xp下是rsaenh.dll, 98下很可能名字不一样),如果有,就应该支持RSA算法.<br><br>我开始说不太明白你的意思,可能是对你说的服务有些迷惑
 
我可以找到 &nbsp;reabase.dll &nbsp;和rsasig.dll不知道有没有用 &nbsp;
 
应该就是它们<br>上面代码中的MS_DEF_PROV就是Microsoft Base Cryptographic Provider v1.0<br>就是由rsabase.dll提供的
 
好的 &nbsp;我去试一下 &nbsp; 谢谢·
 
采用这一句 &nbsp;<br><br>Flag := CryptAcquireContext( hProv, nil, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MS_DEF_PROV,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PROV_RSA_FULL,0); &nbsp;可以成功 &nbsp; 非常感谢
 
能麻烦你再讲一下 &nbsp;参数MS_DEF_PROV代表的意义好吗 &nbsp;<br>为什么要用这个参数<br><br>CryptAcquireContext还有没有可能是其他的情况 &nbsp;谢谢<br>
 
后退
顶部