Translate PEM to DER on Windows CE 3

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;

    // This call determines the format and how much memory is needed in outDER
    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 )
    {
        // Log errors here using ::GetLastError();
        return false;
    }

    if ( ( outDER.pbData = new unsigned char[outDER.cbData] ) == NULL )
    {
        // Log errors here using ::GetLastError();
        return false;
    }
    return ( ::CryptStringToBinaryA( reinterpret_cast<char *>(in.pbData), in.cbData, flags, outDER.pbData, &outDER.cbData, NULL, NULL ) != FALSE );
} // end externalToBinary

, CryptStringToBinary Windows CE 3 CryptoAPI. (, hex), PEM API CE 3.

CryptStringToBinary, Windows CE 3? , API, OpenSSL , .

+3
1

- PEM - DER base64. , , ; API; , '-'; base64 , . DER. WindowsCE3 Encode/Decodeter Base64; - / - () base64 C? http://www.adp-gmbh.ch/cpp/common/base64.html - "" .

0

All Articles