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


Relevant Pages

  • Re: Files Encrypted on Win9x/NT/2K Cannot be Decrypted on WinXP
    ... > We've been using the Microsoft Cryptography functions to encrypt and ... > decrypt files. ... > cannot be decrypted on WindowsXP. ...
    (microsoft.public.security)
  • Re: Files Encrypted on Win9x/NT/2K Cannot be Decrypted on WinXP
    ... And I don't see you specify the key length in CryptDeriveKey. ... >> decrypt files. ... >> Encrypt: ... (Currently we have to encrypt on WindowsXP if we want the>> files to be decryptable on WIndowsXP.) ...
    (microsoft.public.security)
  • RE: NTE_BAD_DATA
    ... They are NOT used DIRECTLY to encrypt / decrypt data; ... you should generate a RANDOM SESSION KEY and select a SYMMETRIC ENCRYPTION ... // imported from a BLOB read in from the source file or having ...
    (microsoft.public.platformsdk.security)
  • Re: Back Doors
    ... >> Design into the system a master key. ... Encrypt that with public key. ... Decrypt random symmetric key with private key. ...
    (sci.crypt)
  • Re: CAPI and RC4: can not decrypt when Final parameter is set to F
    ... to store ASYMMETRIC key pairs - never symmetric keys like RC4, ... Now when you need to encrypt at one place and decrypt at the other normally ... Get a HCRYPTPROV handle to a key container with CryptAcquireContext ...
    (microsoft.public.platformsdk.security)