// DWBS ------------------------------------------------------------------ DWBS
//
// PLATFORM		: ALL
// PRODUCT		: BIT_DEMON
// VISIBILITY	: PUBLIC
//
// DWBS ------------------------------------------------------------------ DWBS

// PURPOSE: Wrapper around key exchange functionality.
// Despite the name, it is not necesseraly Diffie-Hellman: can also be ECC.

#ifndef BD_DHKEY_H
#define BD_DHKEY_H

#include <bdCore/bdMemory/bdMemory.h>
#include <bdCore/bdCrypto/bdCryptoConfig.h>

class bdDHKey
{
	public:

		BD_DECLARE_NEW_AND_DELETE_OPERATORS

 		/// Default constructor
		bdDHKey();

		/// Virtual destructor
		~bdDHKey();

		bdBool create();

		bdBool importKey(const bdUByte8 *const pubKey,
						 bdUInt keylen);

		bdBool generateSecret(bdDHKey &other,
							  bdUByte8 secret[BD_DH_SHARED_SECRET_SIZE]);

		bdBool exportKey(bdUByte8 *pubKey,
						 bdUInt &keylen);

	protected:

		bdBool m_madeKey;

#if defined BD_DH_USE_ECC
		ecc_key m_key;
#else
		dh_key m_key;
#endif
};



#endif // BD_DHKEY_H

