This commit is contained in:
Adam Ierymenko 2019-08-14 16:05:09 -07:00
parent 1b20cc6075
commit b23d551d00
No known key found for this signature in database
GPG key ID: 1657198823E52A61
4 changed files with 20 additions and 32 deletions

View file

@ -33,29 +33,14 @@ namespace ZeroTier {
#define ZT_POLY1305_MAC_LEN 16
/**
* Poly1305 one-time authentication code
* Compute a one-time authentication code
*
* This takes a one-time-use 32-byte key and generates a 16-byte message
* authentication code. The key must never be re-used for a different
* message.
*
* In Packet this is done by using the first 32 bytes of the stream cipher
* keystream as a one-time-use key. These 32 bytes are then discarded and
* the packet is encrypted with the next N bytes.
* @param auth Buffer to receive code -- MUST be 16 bytes in length
* @param data Data to authenticate
* @param len Length of data to authenticate in bytes
* @param key 32-byte one-time use key to authenticate data (must not be reused)
*/
class Poly1305
{
public:
/**
* Compute a one-time authentication code
*
* @param auth Buffer to receive code -- MUST be 16 bytes in length
* @param data Data to authenticate
* @param len Length of data to authenticate in bytes
* @param key 32-byte one-time use key to authenticate data (must not be reused)
*/
static void compute(void *auth,const void *data,unsigned int len,const void *key);
};
void poly1305(void *auth,const void *data,unsigned int len,const void *key);
} // namespace ZeroTier