Article ID: 841715 - Last Review: May 18, 2007 - Revision: 2.5 You cannot decrypt data on Windows XP SP1 or later versionsOn This PageSUMMARYWhen you try to decrypt data on a computer that is running the Microsoft Windows XP operating system, and the data was encrypted by using the RC2 algorithm on a computer that is running Microsoft Windows 2000, you may not be able to decrypt the data successfully. To be able to decrypt the data successfully, you must make an explicit call to the CryptSetKeyParam function. The CryptSetKeyParam function is defined in the Advapi32.dll file to adjust the key length for the RC2 algorithm explicitly. This article contains the links to download the sample code for both the encryption program and the decryption program. It also contains information about how the problem can be reproduced. SYMPTOMSIf data has been encrypted on a computer that is running
Windows 2000, you may not be able to decrypt the data on a computer that is
running Window XP and that has Window XP Service Pack 1 (SP1)
installed. CAUSEThe encryption program and the decryption program use the
Microsoft Enhanced Cryptographic Service Provider V1.0 as the Cryptographic
Service Provider (CSP). This behavior occurs because a change has been
implemented in the RC2 cipher text algorithm. In the earlier implementation of the CryptSetKeyParam function in the version of Microsoft Enhanced Cryptographic Provider that is included with Windows 2000, the RC2 session keys are 128 bits long. However, the effective key length that is used to expand keys in the key table is 40 bits. This is the default behavior. For security reasons, Microsoft changed this default behavior beginning with the version of Microsoft Enhanced Cryptographic Provider that is included with Microsoft Windows XP SP1. By default, the effective key length is now 128 bits for a 128-bit session key in the RC2 algorithm. WORKAROUNDTo work around this behavior, you must make an explicit call
to the CryptSetKeyParam function in your program to set the correct session key length.
For more information, and for instructions to download and to run the sample encryption program and the sample decryption program, see the "More information" section. STATUS This
behavior is by design. MORE INFORMATIONSample programsIn the following downloadable DecryptSample program, the CryptSetKeyParam function is called to set the effective key length to 40 bits.The following files are available for download from the Microsoft Download Center: Collapse this image ![]() Collapse this image ![]() 119591
(http://support.microsoft.com/kb/119591/
)
How to obtain Microsoft support files from online services
Microsoft scanned this file for viruses. Microsoft used the most
current virus-detection software that was available on the date that the file
was posted. The file is stored on security-enhanced servers that help prevent
any unauthorized changes to the file.
Instructions to run the EncryptSample program
Instructions to run the DecryptSample program
Steps to reproduce the behaviorTo reproduce this behavior, comment the following lines of code in the CryptoDecrypt method of the clsCryptoAPI.cls class of the CryptWrap.vbp project in the DecryptGroup.vbg program group.Note The DecryptGroup.vbg is the same program group that is described in the "Instructions to run the DecryptSample program" section. You may not experience this behavior when you create an encryption program or a decryption program in Microsoft Visual Studio .NET by using the Microsoft Enhanced Cryptographic Service Provider. The Microsoft .NET Framework handles this difference in key length internally by changing the key length depending on the operating system. Therefore, this difference in key length becomes transparent when you are developing encryption programs and decryption programs in Visual Studio .NET. REFERENCESFor more information, visit the following Microsoft
Developer Network (MSDN) Web sites: CryptSetKeyParam For more information, click the following article number to
view the article in the Microsoft Knowledge Base: http://msdn2.microsoft.com/en-us/library/ms938335.aspx (http://msdn2.microsoft.com/en-us/library/ms938335.aspx) The Cryptography API, or how to keep a secret http://msdn2.microsoft.com/en-us/library/ms867086.aspx (http://msdn2.microsoft.com/en-us/library/ms867086.aspx) CopyMemory http://msdn2.microsoft.com/en-us/library/aa366535.aspx (http://msdn2.microsoft.com/en-us/library/aa366535.aspx) GetLastError http://msdn2.microsoft.com/en-us/library/ms679360.aspx (http://msdn2.microsoft.com/en-us/library/ms679360.aspx) CryptCreateHash http://msdn2.microsoft.com/en-us/library/ms935996.aspx (http://msdn2.microsoft.com/en-us/library/ms935996.aspx) CryptAcquireContext http://msdn2.microsoft.com/en-us/library/ms935987.aspx (http://msdn2.microsoft.com/en-us/library/ms935987.aspx) CryptDestroyHash http://msdn2.microsoft.com/en-us/library/ms936018.aspx (http://msdn2.microsoft.com/en-us/library/ms936018.aspx) CryptEncrypt http://msdn2.microsoft.com/en-us/library/ms936039.aspx (http://msdn2.microsoft.com/en-us/library/ms936039.aspx) CryptDecrypt http://msdn2.microsoft.com/en-us/library/ms936011.aspx (http://msdn2.microsoft.com/en-us/library/ms936011.aspx) CryptReleaseContext http://msdn2.microsoft.com/en-us/library/ms936171.aspx (http://msdn2.microsoft.com/en-us/library/ms936171.aspx) CryptDeriveKey http://msdn2.microsoft.com/en-us/library/ms936014.aspx (http://msdn2.microsoft.com/en-us/library/ms936014.aspx) CryptDestroyKey http://msdn2.microsoft.com/en-us/library/ms936021.aspx (http://msdn2.microsoft.com/en-us/library/ms936021.aspx) 277786
(http://support.microsoft.com/kb/277786/
)
Encrypting/decrypting data across systems
| Article Translations
|
Back to the top

