Files Encrypted on Win9x/NT/2K Cannot be Decrypted on WinXP

From: Dave (NOSPAM_drubin@NOSPAM_i-2000.com)
Date: 06/11/02


From: Dave <NOSPAM_drubin@NOSPAM_i-2000.com>
Date: Tue, 11 Jun 2002 11:50:32 -0400


We've been using the Microsoft Cryptography functions to encrypt and
decrypt files. The encryption in XP seems to be incompatible with
previous versions of Windows: files encrypted on previous versions
cannot be decrypted on WindowsXP.

Our code is simple and follows the MSDN samples. In summary:

#ifdef USE_BLOCK_CIPHER
    // defines for RC2 block cipher
    #define ENCRYPT_ALGORITHM CALG_RC2
    #define ENCRYPT_BLOCK_SIZE 8
#else
    // defines for RC4 stream cipher
    #define ENCRYPT_ALGORITHM CALG_RC4
    #define ENCRYPT_BLOCK_SIZE 1
#endif

Initialize:
::CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)
::CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash)
::CryptDeriveKey(hProv, ENCRYPT_ALGORITHM, hHash, 0, &hKey)

Encrypt:
::CryptEncrypt(hKey, 0, TRUE, 0, *ppDataOut, pdwLenOut, dwBufLen)

Decrypt:
::CryptDecrypt(hKey, 0, TRUE, 0, *ppDataOut, pdwLenOut)

Our goal is to encrypt the files on ANY OS and have them decryptable
on ANY OS. (Currently we have to encrypt on WindowsXP if we want the
files to be decryptable on WIndowsXP.)

I would appreciate any advice on how to use the Crypto functions in a
platform-independent way. Please respond via mailto:drubin@i-2000.com.

--
Dave Rubin
mailto:drubin@i-2000.com