开发者

How to work with CryptoAPI via C#?

There is a group of CryptoApi functions which works with crypto service providers (CSP).

CPAcquireContext
CPCreateHash
CPDecrypt
CPDeriveKey
CPDestroyHash
CPDestroyKey
CPDuplicateHash
CPDuplicateKey
CPEncrypt
CPExportKey
CPGenKey
CPGenRandom
CPGetHashParam
CPGetKeyParam
CPGetProvP开发者_Go百科aram
CPGetUserKey
CPHashData
CPHashSessionKey
CPImportKey
CPReleaseContext
CPSetHashParam
CPSetKeyParam
CPSetProvParam
CPSignHash
CPVerifySignature

Yes, I know that there is System.Cryptography namespace. But I don't need their implementations.

Is there any ready library which provides a .NET wrapper to these functions?


There has been an extended article on MSDN about this topic:

Extending .NET Cryptography with CAPICOM and P/Invoke

An article on using CryptoAPI Certificate Stores from .Net.

Some P/Invoke declarations lifted from this blog post that shows the p/Invoke definitions for it:

[snip] code sample too large for SO [/snip]


I think your best bet is to use P/Invoke to pull the functionality into your C# application. Here's an (old) article on MSDN about using P/Invoke and CryptoAPI in C#:

Extending .NET Cryptography with CAPICOM and P/Invoke

It's for .Net 1.1, but the concepts are still the same.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜