#include "common.h"
#if defined(MBEDTLS_POLY1305_C)
#include "mbedtls/poly1305.h"
#include "mbedtls/platform_util.h"
#include "mbedtls/error.h"
#include <string.h>
#include "mbedtls/platform.h"
#if !defined(MBEDTLS_POLY1305_ALT)
#define POLY1305_BLOCK_SIZE_BYTES …
#if defined(MBEDTLS_NO_64BIT_MULTIPLICATION)
static uint64_t mul64(uint32_t a, uint32_t b)
{
const uint16_t al = (uint16_t) a;
const uint16_t bl = (uint16_t) b;
const uint16_t ah = a >> 16;
const uint16_t bh = b >> 16;
const uint32_t lo = (uint32_t) al * bl;
const uint64_t me = (uint64_t) ((uint32_t) ah * bl) + (uint32_t) al * bh;
const uint32_t hi = (uint32_t) ah * bh;
return lo + (me << 16) + ((uint64_t) hi << 32);
}
#else
static inline uint64_t mul64(uint32_t a, uint32_t b)
{ … }
#endif
static void poly1305_process(mbedtls_poly1305_context *ctx,
size_t nblocks,
const unsigned char *input,
uint32_t needs_padding)
{ … }
static void poly1305_compute_mac(const mbedtls_poly1305_context *ctx,
unsigned char mac[16])
{ … }
void mbedtls_poly1305_init(mbedtls_poly1305_context *ctx)
{ … }
void mbedtls_poly1305_free(mbedtls_poly1305_context *ctx)
{ … }
int mbedtls_poly1305_starts(mbedtls_poly1305_context *ctx,
const unsigned char key[32])
{ … }
int mbedtls_poly1305_update(mbedtls_poly1305_context *ctx,
const unsigned char *input,
size_t ilen)
{ … }
int mbedtls_poly1305_finish(mbedtls_poly1305_context *ctx,
unsigned char mac[16])
{ … }
int mbedtls_poly1305_mac(const unsigned char key[32],
const unsigned char *input,
size_t ilen,
unsigned char mac[16])
{ … }
#endif
#if defined(MBEDTLS_SELF_TEST)
static const unsigned char test_keys[2][32] = …;
static const unsigned char test_data[2][127] = …;
static const size_t test_data_len[2] = …;
static const unsigned char test_mac[2][16] = …;
#undef ASSERT
#define ASSERT(cond, args) …
int mbedtls_poly1305_self_test(int verbose)
{ … }
#endif
#endif