DES Encryption and Decryption using different keys gives 'Bad Data' exception

From: dean (abc_at_def.com)
Date: 05/27/03


Date: Tue, 27 May 2003 15:43:33 +0200


Hi all,

Is anyone familiar with the AnsiX9.19 document which handles the generation
of Key Encryption Keys (KEK) and Key Check Vaues (KCV). A rough overview of
the process is as follows:

Step 1 : Take a given 128bit key, and divide it into 2 - to generate key
parts KL equals the left 64 bits and KR the right.
Step 2 : Then encrypt the number zero "0" using the left hand key part (KL)
and DES.
Step 3 : The output of step 2 is then decrypted using the right hand key
part (KR).
Step 4 : The final step is to re-encrypt this output using the left hand key
part once again.

According to the ANSI doc this yields a Key Check Value which can be used
for message authentication.

The Step 1 encryption part works fine but Step 2 decrypting using the right
hand key part fails with the infamous 'Bad Data' cryptographic exception.
When I reran the process using the the left hand key part (KL) for both
encryption, decryption and the re-encryption it works fine. This leads me to
beleive that the code is ok but the decryption process doesn't like a
different key.

Does any one have any ideas on this. Help would be greatly appreciated.

Best regards

Dean

PS I can attach some code samples if that would help.



Relevant Pages

  • Re: Encryption and decryption
    ... Vyas, MVP (SQL Server) ... SQL Server Articles and Code Samples @ http://vyaskn.tripod.com/ ... How to do encryption and decryption? ...
    (microsoft.public.sqlserver.security)
  • Re: Securing data to a process principal
    ... encryption key first time for the user - and use it later). ... secret. ... I need the decryption to ... You MAY think that instead of a filter driver you can simply ...
    (microsoft.public.platformsdk.security)
  • Re: embedded keys - there has to be a less vulnerable approach
    ... the database would be run on top of an encrypting file system ... > The use of an asymmetrical encryption algorithm does not seem to offer ... because the encryption and decryption ... > a hostile attacker is not a member of that small knowledgeable elite. ...
    (comp.security.misc)
  • embedded keys - there has to be a less vulnerable approach
    ... the database would be run on top of an encrypting file system ... The use of an asymmetrical encryption algorithm does not seem to offer ... because the encryption and decryption ... You have a table with customer names and addresses. ...
    (comp.security.misc)
  • NTE_BAD_DATA
    ... decryption module using the self signed certificate. ... My encryption and decryption module are as follows. ... goto Exit_MyDecryptFile; ... // imported from a BLOB read in from the source file or having ...
    (microsoft.public.platformsdk.security)