This sounds like an endianness issue. Microsoft's CryptEncrypt function returns the ciphertext in little-endian format, while OpenSSL expects its data to be in big-endian format. You'll need to reverse the encrypted data before passing it to OpenSSL.
Bingo. Thanks for pointing that out. The pitfall was too much obvious :) – Alexey Naidyonov Nov 18 '08 at 9:52.
Here's the code (just in case someone has googled this topic out): BYTE *spkiData = SPKI; // X.509 ASN.1 encoded SubjectPublicKeyInfo DWORD dwSPKISize = SPKI_SIZE; // 94 bytes for RSA DWORD dwBufSize = 0; // Get buffer size for decoded spki structure CryptDecodeObject(X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO, spkiData, dwSPKISize, 0, NULL, &dwBufSize); BYTE* decBuf = new BYTEdwBufSize; CryptDecodeObject( X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO, spkiData, dwSPKISize, 0, decBuf, &dwBufSize); // Now decode the RSA Public key itself CERT_PUBLIC_KEY_INFO * spki = (CERT_PUBLIC_KEY_INFO *) decBuf; // Get buffer size for decoded public key structure CryptDecodeObject( X509_ASN_ENCODING, RSA_CSP_PUBLICKEYBLOB, spki->PublicKey. PbData, spki->PublicKey. CbData, 0, 0, &dwBufSize); // Get the RSA public key blob BYTE *blobBuf = new BYTEdwBufSize; CryptDecodeObject(X509_ASN_ENCODING, RSA_CSP_PUBLICKEYBLOB, spki->PublicKey.
PbData, spki->PublicKey. CbData, 0, blobBuf, &dwBufSize); // Acquire crypto provider context HCRYPTPROV hCryptProv = NULL; CryptAcquireContext(&hCryptProv, 0, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); // Import key HCRYPTKEY key = NULL; CryptImportKey(hCryptProv, blobBuf, dwBufSize, 0, 0, &key); // Get the key size DWORD dwKeySize; DWORD dwParamSize = sizeof(DWORD); CryptGetKeyParam(key, KP_KEYLEN, (BYTE*) &dwKeySize, &dwParamSize, 0); // we need it in bytes for convenience dwKeySize /= 8; // Now the fun // allocate a buffer of key size BYTE *data = new BYTEdwKeySize; // Copy data need to be encrypted // With PKCS#1 padding data length can not exceed keysize - 11 bytes DWORD dataLen = 16; memcpy(data, "0123456789012345", dataLen); CryptEncrypt(key, 0, TRUE, 0, data, &dataLen, dwKeySize) // now convert it to big endian (for the rest of the world) for (int I = 0; I.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.