Update documentation

pull/873/head
Jeffrey Walton 2019-08-03 23:25:15 -04:00
parent 4e6dd922f7
commit 0b42a18cde
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
3 changed files with 72 additions and 13 deletions

29
fhmqv.h
View File

@ -181,10 +181,22 @@ public:
params.EncodeElement(true, y, publicKey); params.EncodeElement(true, y, publicKey);
} }
/// \brief Provides the size of the ephemeral private key
/// \return size of ephemeral private keys in this domain
/// \details An ephemeral private key is a private key and public key.
/// The serialized size is different than a static private key.
unsigned int EphemeralPrivateKeyLength() const {return StaticPrivateKeyLength() + StaticPublicKeyLength();} unsigned int EphemeralPrivateKeyLength() const {return StaticPrivateKeyLength() + StaticPublicKeyLength();}
/// \brief Provides the size of the ephemeral public key
/// \return size of ephemeral public keys in this domain
/// \details An ephemeral public key is a public key.
/// The serialized size is the same as a static public key.
unsigned int EphemeralPublicKeyLength() const{return StaticPublicKeyLength();} unsigned int EphemeralPublicKeyLength() const{return StaticPublicKeyLength();}
/// return length of ephemeral private keys in this domain /// \brief Generate ephemeral private key in this domain
/// \param rng a RandomNumberGenerator derived class
/// \param privateKey a byte buffer for the generated private key in this domain
/// \pre <tt>COUNTOF(privateKey) == EphemeralPrivateKeyLength()</tt>
void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
{ {
const DL_GroupParameters<Element> &params = GetAbstractGroupParameters(); const DL_GroupParameters<Element> &params = GetAbstractGroupParameters();
@ -194,22 +206,29 @@ public:
params.EncodeElement(true, y, privateKey+StaticPrivateKeyLength()); params.EncodeElement(true, y, privateKey+StaticPrivateKeyLength());
} }
/// return length of ephemeral public keys in this domain /// \brief Generate ephemeral public key from a private key in this domain
/// \param rng a RandomNumberGenerator derived class
/// \param privateKey a byte buffer with the previously generated private key
/// \param publicKey a byte buffer for the generated public key in this domain
/// \pre <tt>COUNTOF(publicKey) == EphemeralPublicKeyLength()</tt>
void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
{ {
CRYPTOPP_UNUSED(rng); CRYPTOPP_UNUSED(rng);
memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength()); memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength());
} }
/// \brief Derive shared secret from your private keys and couterparty's public keys /// \brief Derive agreed value or shared secret
/// \param agreedValue the shared secret /// \param agreedValue the shared secret
/// \param staticPrivateKey your long term private key /// \param staticPrivateKey your long term private key
/// \param ephemeralPrivateKey your ephemeral private key /// \param ephemeralPrivateKey your ephemeral private key
/// \param staticOtherPublicKey couterparty's long term public key /// \param staticOtherPublicKey couterparty's long term public key
/// \param ephemeralOtherPublicKey couterparty's ephemeral public key /// \param ephemeralOtherPublicKey couterparty's ephemeral public key
/// \param validateStaticOtherPublicKey flag indicating validation /// \param validateStaticOtherPublicKey flag indicating validation
/// \details Agree() performs the authenticated key agreement. Each instance /// \return true upon success, false in case of failure
/// or run of the protocol should use a new ephemeral key pair. /// \details Agree() performs the authenticated key agreement. Agree()
/// derives a shared secret from your private keys and couterparty's
/// public keys. Each instance or run of the protocol should use a new
/// ephemeral key pair.
/// \details The other's ephemeral public key will always be validated at /// \details The other's ephemeral public key will always be validated at
/// Level 1 to ensure it is a point on the curve. /// Level 1 to ensure it is a point on the curve.
/// <tt>validateStaticOtherPublicKey</tt> determines how thoroughly other's /// <tt>validateStaticOtherPublicKey</tt> determines how thoroughly other's

29
hmqv.h
View File

@ -180,10 +180,22 @@ public:
params.EncodeElement(true, y, publicKey); params.EncodeElement(true, y, publicKey);
} }
/// \brief Provides the size of the ephemeral private key
/// \return size of ephemeral private keys in this domain
/// \details An ephemeral private key is a private key and public key.
/// The serialized size is different than a static private key.
unsigned int EphemeralPrivateKeyLength() const {return StaticPrivateKeyLength() + StaticPublicKeyLength();} unsigned int EphemeralPrivateKeyLength() const {return StaticPrivateKeyLength() + StaticPublicKeyLength();}
/// \brief Provides the size of the ephemeral public key
/// \return size of ephemeral public keys in this domain
/// \details An ephemeral public key is a public key.
/// The serialized size is the same as a static public key.
unsigned int EphemeralPublicKeyLength() const{return StaticPublicKeyLength();} unsigned int EphemeralPublicKeyLength() const{return StaticPublicKeyLength();}
/// return length of ephemeral private keys in this domain /// \brief Generate ephemeral private key in this domain
/// \param rng a RandomNumberGenerator derived class
/// \param privateKey a byte buffer for the generated private key in this domain
/// \pre <tt>COUNTOF(privateKey) == EphemeralPrivateKeyLength()</tt>
void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
{ {
const DL_GroupParameters<Element> &params = GetAbstractGroupParameters(); const DL_GroupParameters<Element> &params = GetAbstractGroupParameters();
@ -193,22 +205,29 @@ public:
params.EncodeElement(true, y, privateKey+StaticPrivateKeyLength()); params.EncodeElement(true, y, privateKey+StaticPrivateKeyLength());
} }
/// return length of ephemeral public keys in this domain /// \brief Generate ephemeral public key from a private key in this domain
/// \param rng a RandomNumberGenerator derived class
/// \param privateKey a byte buffer with the previously generated private key
/// \param publicKey a byte buffer for the generated public key in this domain
/// \pre <tt>COUNTOF(publicKey) == EphemeralPublicKeyLength()</tt>
void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
{ {
CRYPTOPP_UNUSED(rng); CRYPTOPP_UNUSED(rng);
memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength()); memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength());
} }
/// \brief Derive shared secret from your private keys and couterparty's public keys /// \brief Derive agreed value or shared secret
/// \param agreedValue the shared secret /// \param agreedValue the shared secret
/// \param staticPrivateKey your long term private key /// \param staticPrivateKey your long term private key
/// \param ephemeralPrivateKey your ephemeral private key /// \param ephemeralPrivateKey your ephemeral private key
/// \param staticOtherPublicKey couterparty's long term public key /// \param staticOtherPublicKey couterparty's long term public key
/// \param ephemeralOtherPublicKey couterparty's ephemeral public key /// \param ephemeralOtherPublicKey couterparty's ephemeral public key
/// \param validateStaticOtherPublicKey flag indicating validation /// \param validateStaticOtherPublicKey flag indicating validation
/// \details Agree() performs the authenticated key agreement. Each instance /// \return true upon success, false in case of failure
/// or run of the protocol should use a new ephemeral key pair. /// \details Agree() performs the authenticated key agreement. Agree()
/// derives a shared secret from your private keys and couterparty's
/// public keys. Each instance or run of the protocol should use a new
/// ephemeral key pair.
/// \details The other's ephemeral public key will always be validated at /// \details The other's ephemeral public key will always be validated at
/// Level 1 to ensure it is a point on the curve. /// Level 1 to ensure it is a point on the curve.
/// <tt>validateStaticOtherPublicKey</tt> determines how thoroughly other's /// <tt>validateStaticOtherPublicKey</tt> determines how thoroughly other's

27
mqv.h
View File

@ -143,9 +143,22 @@ public:
params.EncodeElement(true, y, publicKey); params.EncodeElement(true, y, publicKey);
} }
/// \brief Provides the size of the ephemeral private key
/// \return size of ephemeral private keys in this domain
/// \details An ephemeral private key is a private key and public key.
/// The serialized size is different than a static private key.
unsigned int EphemeralPrivateKeyLength() const {return StaticPrivateKeyLength() + StaticPublicKeyLength();} unsigned int EphemeralPrivateKeyLength() const {return StaticPrivateKeyLength() + StaticPublicKeyLength();}
/// \brief Provides the size of the ephemeral public key
/// \return size of ephemeral public keys in this domain
/// \details An ephemeral public key is a public key.
/// The serialized size is the same as a static public key.
unsigned int EphemeralPublicKeyLength() const {return StaticPublicKeyLength();} unsigned int EphemeralPublicKeyLength() const {return StaticPublicKeyLength();}
/// \brief Generate ephemeral private key in this domain
/// \param rng a RandomNumberGenerator derived class
/// \param privateKey a byte buffer for the generated private key in this domain
/// \pre <tt>COUNTOF(privateKey) == EphemeralPrivateKeyLength()</tt>
void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
{ {
const DL_GroupParameters<Element> &params = GetAbstractGroupParameters(); const DL_GroupParameters<Element> &params = GetAbstractGroupParameters();
@ -155,21 +168,29 @@ public:
params.EncodeElement(true, y, privateKey+StaticPrivateKeyLength()); params.EncodeElement(true, y, privateKey+StaticPrivateKeyLength());
} }
/// \brief Generate ephemeral public key from a private key in this domain
/// \param rng a RandomNumberGenerator derived class
/// \param privateKey a byte buffer with the previously generated private key
/// \param publicKey a byte buffer for the generated public key in this domain
/// \pre <tt>COUNTOF(publicKey) == EphemeralPublicKeyLength()</tt>
void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
{ {
CRYPTOPP_UNUSED(rng); CRYPTOPP_UNUSED(rng);
memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength()); memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength());
} }
/// \brief Derive shared secret from your private keys and couterparty's public keys /// \brief Derive agreed value or shared secret
/// \param agreedValue the shared secret /// \param agreedValue the shared secret
/// \param staticPrivateKey your long term private key /// \param staticPrivateKey your long term private key
/// \param ephemeralPrivateKey your ephemeral private key /// \param ephemeralPrivateKey your ephemeral private key
/// \param staticOtherPublicKey couterparty's long term public key /// \param staticOtherPublicKey couterparty's long term public key
/// \param ephemeralOtherPublicKey couterparty's ephemeral public key /// \param ephemeralOtherPublicKey couterparty's ephemeral public key
/// \param validateStaticOtherPublicKey flag indicating validation /// \param validateStaticOtherPublicKey flag indicating validation
/// \details Agree() performs the authenticated key agreement. Each instance /// \return true upon success, false in case of failure
/// or run of the protocol should use a new ephemeral key pair. /// \details Agree() performs the authenticated key agreement. Agree()
/// derives a shared secret from your private keys and couterparty's
/// public keys. Each instance or run of the protocol should use a new
/// ephemeral key pair.
/// \details The other's ephemeral public key will always be validated at /// \details The other's ephemeral public key will always be validated at
/// Level 1 to ensure it is a point on the curve. /// Level 1 to ensure it is a point on the curve.
/// <tt>validateStaticOtherPublicKey</tt> determines how thoroughly other's /// <tt>validateStaticOtherPublicKey</tt> determines how thoroughly other's