Search code examples
cng

CNG replacements for CryptBinaryToString/CryptStringToBinary?


I was expecting to find CNG alternatives to the older Crypto API calls for serializing BLOB data. However there do not seem to be CNG replacements for CryptBinaryToString and CryptStringToBinary.

Am I missing something, or do most programmers either go ahead and load and use Crypt32.dll or do they just roll their own, use a 3rd party library, or ...?


Solution

  • I expect that CNG doesn't have counterparts for CryptBinaryToString and CryptStringToBinary because CNG focuses on improving the base cryptographic functionality and has fewer helper functions than CAPI. Also, in many applications they would not be applicable, as the crypto code would be integrated with a protocol that will want cryptographic material to be marshalled in a particular way that these CAPI functions don't support.

    I can see though that these CAPI functions would be useful when dealing with Base64/PEM formats for e.g. RSA public keys. There's no reason not to continue to use these CAPI functions with CNG if they do the job you want, or you could use a third-party library like you say.