Simple Encrypt /DeCrypt using imported DES key

From: Aiden (Aiden.Devine@ffastfill.com)
Date: 08/12/02


From: "Aiden" <Aiden.Devine@ffastfill.com>
Date: Mon, 12 Aug 2002 12:52:58 +0100


Hi,

I am writing a simple dll to encrypt and decrypt messages using DES (in the
first instance). For my test app I have created and exported to a file a DES
key using:

::CryptGenKey(this->m_hCryptProvider, ALG_SID_DES, CRYPT_EXPORTABLE, &hKey)
...
::CryptExportKey(hKey, 0, PUBLICKEYBLOB, 0, pbKeyBlob, &dwKeyBlobLen)

My encryption class both encrypts and decrypts messages, so when I import
the encryption key, I create a duplicate to use as a decryption key:

::CryptDuplicateKey( m_hEncryptKey, NULL, 0, &m_hDecryptKey) )

My test harness then encodes a message using the encryption key (works
fine), and Decodes the result using the decryption key. I am getting
NTE_BAD_KEY error each time I attempt to decode.

Any ideas where I should be looking ?

Thanks,



Relevant Pages

  • 3DES and super-encryption
    ... I'm basically familiar with 3DES and how it was developed to extend the ... short version of what I know about the transition from DES ... DES is basically a secure cipher except that with 56 bit keys it is ... adds nothing to the strength of encryption but may actually weaken a cipher. ...
    (sci.crypt)
  • Re: DES and UUEncoded
    ... If you're using CBC mode encryption, than you need to use an IV by definition. ... You'll need to find some documentation for the DES utility you're ... >> Next you create a MemoryStream that will hold the output of your ...
    (microsoft.public.dotnet.security)
  • Cryptography FAQ (05/10: Product Ciphers)
    ... What makes a product cipher secure? ... What exactly is DES? ... Let E_Kbe the encryption of X under key K. Then, for any fixed K, ...
    (sci.crypt)
  • Cryptography FAQ (05/10: Product Ciphers)
    ... What makes a product cipher secure? ... What exactly is DES? ... Let E_Kbe the encryption of X under key K. Then, for any fixed K, ...
    (sci.crypt)
  • Cryptography FAQ (05/10: Product Ciphers)
    ... What makes a product cipher secure? ... What exactly is DES? ... Let E_Kbe the encryption of X under key K. Then, for any fixed K, ...
    (sci.crypt)

Quantcast