[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ms-cryptoapi
Subject:    CryptEncryptMessage Triple DES and RC2 Samples Requested
From:       "Wedinger, Keith" <Keith_Wedinger () STERCOMM ! COM>
Date:       2002-01-29 13:02:25
[Download RAW message or body]


In order to be compatible with the S/MIME specification, my application
needs to support Triple DES and RC2 encryption/decryption.  My code
currently uses RC4 with CryptEncryptMessage.  In the documentation for the
CRYPT_ENCRYPT_MESSAGE_PARA structure, it states that:

The following encryption algorithms require that the Parameters member of
the structure to contain an encoded eight byte Initialization Vector (IV)
(see CryptSetKeyParam for more information about the KP_IV parameter).

szOID_OIWSEC_desCBC (CALG_DES)
szOID_RSA_DES_EDE3_CBC (CALG_3DES)

The szOID_RSA_RC2CBC(CALG_RC2) algorithm requires the pbData member of
Parameters to be a CRYPT_RC2_CBC_PARAMETERS structure. If the cbData member
of the Parameters member is zero, an ASN.1 encoded CRYPT_RC2_CBC_PARAMETERS
containing the IV is generated as the pbData member. This generated pbData
uses the default dwVersion corresponding to the 40 bit key length. To
override the default 40 bit key length, pvEncryptionAuxInfo can be set to
point to a CMSG_RC2_AUX_INFO structure that contains a key bit length.

Unfortunately, there are no samples in MSDN showing:
1.  How to properly set up the Initialization Vector stored in the
Parameters member mentioned above for DES.
2.  How to properly set up the CRYPT_RC2_CBC_PARAMETERS structure.
3.  What if anything is done with this Parameters member when
CryptEncryptMessage is finished.

What is particularly confusing is the fact that the above documention
mentions a Parameters member which is not listed in the docs for
CRYPT_ENCRYPT_MESSAGE_PARA.

Does anyone have a working sample of CryptEncryptMessage using Triple DES
and RC2 that they are willing to share?
I searched through the CryptoAPI mailing list archives and found no working
samples

J. Keith Wedinger
Senior Software Developer
Sterling Commerce
keith_wedinger@stercomm.com

----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:CryptoAPI-signoff-request@DISCUSS.MICROSOFT.COM

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic