Search Persits Software Knowledge Base

 

Article PS01071661

Do not specify key size when using DES or Triple-DES

Problem Description

When a DES or Triple-DES key is created and key size explicitly specified, inconsistent results are produced, and when decrypting, the following error may occur:

Bad Data

Solution

The DES cipher uses 56-bit keys, and Triple-DES 168-bit keys. However, CryptoAPI allocates 64 bits for DES keys and 192 bits for 3DES keys. An attempt to specify 56 or 168 for the Key Length argument of the GenerateKey or GenerateKeyFromPassword methods may produce inconsistent encrypted data. You should never specify key size explicitly when using DES or Triple-DES ciphers:

<%
' Incorrect
Set Key = Context.GenerateKeyFromPassword("xxx", calgSHA, calg3DES, 168)
%>

<%
' Correct
Set Key = Context.GenerateKeyFromPassword("xxx", calgSHA, calg3DES)
%>

Created: 2/8/2002 4:46:58 AM
Last Modified: 2/9/2002 4:13:16 PM

Copyright © Persits Software, Inc. 1998 - 2018
For technical support, write to support@persits.com.