Re: Converting Diffie-Hellman Session keys to CALG_AES_128
- From: joe hacker <tlviewer@xxxxxxxxx>
- Date: Sun, 17 Sep 2006 19:30:27 -0700
On Thu, 14 Sep 2006 14:09:13 -0700, Medical-Fix wrote:
How can I convert a Diffie-Hellman Session keys to CALG_AES_128??
The following code snip shows how I created my Diffie-Hellman Session
Keys, now I need to convert this session key to AES...
Thansk for the help!
1) CryptAcquireContext(&hProv, NULL, MS_ENH_DSS_DH_PROV, PROV_DSS_DH,
CRYPT_VERIFYCONTEXT);
2)CryptGenKey(hProv, CALG_DH_EPHEM, (DHKEYSIZE << 16) |CRYPT_EXPORTABLE
| CRYPT_PREGEN, &hPrivateKey1);
3)CryptSetKeyParam(hPrivateKey1, KP_P, (PBYTE)&P, 0);
4)CryptSetKeyParam(hPrivateKey1, KP_G, (PBYTE)&G, 0);
5)CryptSetKeyParam( hPrivateKey1, KP_X, NULL, 0);
6)CryptExportKey(hPrivateKey1, NULL, PUBLICKEYBLOB, 0, NULL,
&dwDataLen2);
7)CryptImportKey(hProv, pbKeyBlobParty2, dwDataLen2, hPrivateKey1, 0,
&hSessionKey);
-------- snip --------
Alg = CALG_AES_128;
CryptSetKeyParam(hSessionKey, KP_ALGID,(BYTE *) &Alg, (128 << 16) |
CRYPT_EXPORTABLE);
// defaults to IV vector 0x00 x 16 (16 bytes of null)
--------unsnip -------------------
hth,
tlviewer
.
- Follow-Ups:
- Re: Converting Diffie-Hellman Session keys to CALG_AES_128
- From: Medical-Fix
- Re: Converting Diffie-Hellman Session keys to CALG_AES_128
- References:
- Converting Diffie-Hellman Session keys to CALG_AES_128
- From: Medical-Fix
- Converting Diffie-Hellman Session keys to CALG_AES_128
- Prev by Date: Re: Who can alter User rights ?
- Next by Date: Makccert and x509name
- Previous by thread: Converting Diffie-Hellman Session keys to CALG_AES_128
- Next by thread: Re: Converting Diffie-Hellman Session keys to CALG_AES_128
- Index(es):