Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
virtual P6R::P6ERR P6R::p6IDHKeyExchange::calculateSharedSecret ( const P6UCHAR pPublicKey,
P6UINT32  keyLength,
P6UCHAR pSharedSecret,
P6UINT32  cBuffer,
P6UINT32 pWritten 
)
pure virtual

Key exchange between two parties requires each party to exchange their public keys.

Once this is done then the Diffie-Hellman algorithm can be used to compute the shared secret.

Parameters
pPublicKey[ in ] The peer's DH public key (obtained by the caller of this method - e.g., SSH protocol)
keyLength[ in ] Size in bytes of the data passed in by pPublicKey
pSharedSecret[ out ] The shared secret, (or key), that has been exchanged (i.e., both sides compute). If NULL, then the required size of a buffer to hold the shared secret is returned in pWritten.
cBuffer[ in ] Number of entries in the buffer pointed to by pSharedSecret.
pWritten[ out ] Optional can be NULL, returns the number of bytes written into pSharedSecret. This parameter cannot be NULL when pSharedSecret is also NULL.
Returns
SuccessP6R::eOk 
FailureeNotInitializedA successful call to initialize was not made before this call.
P6R::eInvalidArgIf pPublicKey is NULL. If pSharedSecret and pWritten are both NULL.
P6R::eInvalidStateA call to genDHKeyPair() must be made before a call to this function.
P6R::eTooSmallThe buffer pointed to by pSharedSecret is not large enough to hold the key data.
P6R::eFailAndExceptionThe shared secret calculation failed. Exception record provides detailed error info.