Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
p6dhkeyexchange.h
Go to the documentation of this file.
1 
12 #ifndef P6DHKEYEXCHANGE_H__
13 #define P6DHKEYEXCHANGE_H__ 1
14 
15 #include "p6random.h"
16 
17 namespace P6R {
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
34 typedef enum {
35  DH_GROUP1 = 0x01,
36  DH_GROUP14 = 0x02,
37  DH_RAW = 0x03,
38  DH_MAX = 0x04
39 } P6DHGROUP;
40 
49 const P6DHKEXFLAGS P6DHKEX_NOFLAGS = 0x00000000;
50 const P6DHKEXFLAGS P6DHKEX_TRACEON = 0x00000001;
51 
52 
61 interface p6IDHKeyExchange : public p6ICom
62 {
74  P6COMMETHOD initialize( P6DHKEXFLAGS flags ) = 0;
75 
93  P6COMMETHOD genDHKeyPair( P6DHGROUP keyType, P6CHAR* pPrime, P6UINT32 generator ) = 0;
94 
111  P6COMMETHOD genDHKeyPairByBinary( P6BSTR prime, P6BSTR generator ) = 0;
112 
130  P6COMMETHOD getPrime( P6UCHAR* pBuffer, P6UINT32 cBuffer, P6UINT32* pWritten ) = 0;
131 
145  P6COMMETHOD checkPrime() = 0;
146 
164  P6COMMETHOD generatePrime( P6UINT32 primeLength, P6UINT32 generator, p6IRandom* pRandom ) = 0;
165 
183  P6COMMETHOD getPublicKey( P6UCHAR* pBuffer, P6UINT32 cBuffer, P6UINT32* pWritten ) = 0;
184 
202  P6COMMETHOD getPrivateKey( P6UCHAR* pBuffer, P6UINT32 cBuffer, P6UINT32* pWritten ) = 0;
203 
236  P6COMMETHOD getRawPublicKey( P6BSTR* pP, P6BSTR* pG, P6BSTR* pY ) = 0;
237 
271  P6COMMETHOD getRawPrivateKey( P6BSTR* pP, P6BSTR* pG, P6BSTR* pX ) = 0;
272 
285  P6COMMETHOD loadPublicKey( P6UCHAR* pBuffer, P6UINT32 cBuffer ) = 0;
286 
299  P6COMMETHOD loadPrivateKey( P6UCHAR* pBuffer, P6UINT32 cBuffer ) = 0;
300 
315  P6COMMETHOD loadRawPublicKey( const P6BSTR* pP, const P6BSTR* pG, const P6BSTR* pY ) = 0;
316 
331  P6COMMETHOD loadRawPrivateKey( const P6BSTR* pP, const P6BSTR* pG, const P6BSTR* pX ) = 0;
332 
354  P6COMMETHOD calculateSharedSecret( const P6UCHAR* pPublicKey,
355  P6UINT32 keyLength,
356  P6UCHAR* pSharedSecret,
357  P6UINT32 cBuffer,
358  P6UINT32* pWritten ) = 0;
359 };
360 
361 // {8257A87C-B44D-453c-B28B-28D21A8E9AF6}
362 #define IF_p6IDHKeyExchange {0x8257a87c,0xb44d,0x453c,{0xb2,0x8b,0x28,0xd2,0x1a,0x8e,0x9a,0xf6}}
363 
364 // {6023D47D-767B-42b8-94B2-6D123215E854}
365 #define COMP_p6DHKeyExchange {0x6023d47d,0x767b,0x42b8,{0x94,0xb2,0x6d,0x12,0x32,0x15,0xe8,0x54}}
366 
367 #ifdef __cplusplus
368 }
369 #endif
370 
371 } // namespace
372 
373 
374 #endif
375 
376 
377 
virtual P6R::P6ERR checkPrime()=0
Is the prime that was set via a call to the genDHKeyPair() method safe and have a valid generator...
virtual P6R::P6ERR initialize(P6DHKEXFLAGS flags)=0
Sets up the object to run properly.
unsigned char P6UCHAR
Definition: p6types.h:74
virtual P6R::P6ERR generatePrime(P6UINT32 primeLength, P6UINT32 generator, p6IRandom *pRandom)=0
Generate a prime to be used in a Diffie-Hellman algorithm of prime length in bits.
unsigned int P6UINT32
Definition: p6types.h:40
virtual P6R::P6ERR loadPrivateKey(P6UCHAR *pBuffer, P6UINT32 cBuffer)=0
This method loads the binary data for a Diffie-Hellman (DH) private key.
virtual P6R::P6ERR getPrime(P6UCHAR *pBuffer, P6UINT32 cBuffer, P6UINT32 *pWritten)=0
This method retrieves the binary prime value set by the call to genDHKeyPair().
P6UINT32 P6DHKEXFLAGS
P6DHKEXFLAGS.
[p6]COM Cryptographic Random Number Generator.
The base interface all [p6]COM components must derive from and implement.
Definition: p6comdef.h:96
P6DHGROUP
Defines the built-in primes used to generate keys.
virtual P6R::P6ERR calculateSharedSecret(const P6UCHAR *pPublicKey, P6UINT32 keyLength, P6UCHAR *pSharedSecret, P6UINT32 cBuffer, P6UINT32 *pWritten)=0
Key exchange between two parties requires each party to exchange their public keys.
Provides a cryptographically strong random number generator.
Definition: p6random.h:70
Binary string.
Definition: p6types.h:154
virtual P6R::P6ERR loadRawPublicKey(const P6BSTR *pP, const P6BSTR *pG, const P6BSTR *pY)=0
This method loads the standard parts of a Diffie-Hellman (DH) public key from a set of buffers...
virtual P6R::P6ERR getRawPublicKey(P6BSTR *pP, P6BSTR *pG, P6BSTR *pY)=0
This method retrieves the standard parts of a a Diffie-Hellman (DH) public key.
virtual P6R::P6ERR getRawPrivateKey(P6BSTR *pP, P6BSTR *pG, P6BSTR *pX)=0
This method retrieves the standard parts of a a Diffie-Hellman (DH) private key.
This component provides the basics of the key exchange calculates used in the Diffe-Hellman key excha...
#define P6COMMETHOD
Definition: p6types.h:872
virtual P6R::P6ERR loadRawPrivateKey(const P6BSTR *pP, const P6BSTR *pG, const P6BSTR *pX)=0
This method loads the standard parts of a Diffie-Hellman (DH) private key from a set of buffers...
virtual P6R::P6ERR loadPublicKey(P6UCHAR *pBuffer, P6UINT32 cBuffer)=0
This method loads the binary data for a Diffie-Hellman (DH) public key.
virtual P6R::P6ERR getPrivateKey(P6UCHAR *pBuffer, P6UINT32 cBuffer, P6UINT32 *pWritten)=0
This method retrieves the binary key data for Diffie-Hellman generated private key.
const P6DHKEXFLAGS P6DHKEX_TRACEON
virtual P6R::P6ERR genDHKeyPairByBinary(P6BSTR prime, P6BSTR generator)=0
Generates the public - private Diffie-Hellman key pair based on a passed in prime.
const P6DHKEXFLAGS P6DHKEX_NOFLAGS
virtual P6R::P6ERR genDHKeyPair(P6DHGROUP keyType, P6CHAR *pPrime, P6UINT32 generator)=0
Generates the public - private Diffie-Hellman key pair based on the selected built in primes...
virtual P6R::P6ERR getPublicKey(P6UCHAR *pBuffer, P6UINT32 cBuffer, P6UINT32 *pWritten)=0
This method retrieves the binary key data for Diffie-Hellman generated public key.
char P6CHAR
Narrow character type.
Definition: p6types.h:71