I have P & G— how do I use the Wincrypt API to generate a Diffie-Hellman keypair?
问题 There's an MSDN article here, but I'm not getting very far: p = 139; g = 5; CRYPT_DATA_BLOB pblob; pblob.cbData = sizeof( ULONG ); pblob.pbData = ( LPBYTE ) &p; CRYPT_DATA_BLOB gblob; gblob.cbData = sizeof( ULONG ); gblob.pbData = ( LPBYTE ) &g; HCRYPTKEY hKey; if ( ::CryptGenKey( m_hCryptoProvider, CALG_DH_SF, CRYPT_PREGEN, &hKey ) ) { ::CryptSetKeyParam( hKey, KP_P, ( LPBYTE ) &pblob, 0 ); Fails here with NTE_BAD_DATA . I'm using MS_DEF_DSS_DH_PROV . What gives? 回答1: It may be that it just