I have an RSA public key crypto shell that works well on Windows desktop and Windows Embedded / POSReady. I need to port this system to Windows CE 5 and Windows CE 3. Within this system, I allow developers to import various cryptographic objects, such as certificates and keys, into several encodings. The most commonly used encoding is Base64 encoded PEM. On most versions of Windows, it is easy to convert encodings to binary (DER) format, which Windows requires for calls CryptDecodeObjectEx:
bool MyClass::externalToBinary( const DATA_BLOB &in, DATA_BLOB &outDER )
{
DWORD flags;
if ( ::CryptStringToBinaryA( reinterpret_cast<char *>(in.pbData), in.cbData, CRYPT_STRING_ANY, NULL, &outDER.cbData, NULL, &flags ) == false &&
::CryptStringToBinaryA( reinterpret_cast<char *>(in.pbData), in.cbData, CRYPT_STRING_HEX_ANY, NULL, &outDER.cbData, NULL, &flags ) == false )
{
return false;
}
if ( ( outDER.pbData = new unsigned char[outDER.cbData] ) == NULL )
{
return false;
}
return ( ::CryptStringToBinaryA( reinterpret_cast<char *>(in.pbData), in.cbData, flags, outDER.pbData, &outDER.cbData, NULL, NULL ) != FALSE );
}
, CryptStringToBinary Windows CE 3 CryptoAPI. (, hex), PEM API CE 3.
CryptStringToBinary, Windows CE 3? , API, OpenSSL , .