Lines Matching +full:mac +full:- +full:base
2 * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
23 /* pick 32-bit unsigned integer in little endian order */
34 * words making up the multi-precision value, or in other words radix
35 * or base of numerical representation, e.g. base 2^64, base 2^32,
36 * base 2^26. Complementary characteristic is how wide is the result of
38 * accommodate multiplication result in base 2^64 case. These are used
40 * is designed to isolate this so that low-level primitives implemented
41 * in assembly can be self-contained/self-coherent.
46 void poly1305_emit(void *ctx, unsigned char mac[16],
51 ctx->nonce[0] = U8TOU32(&key[16]); in Poly1305_Init()
52 ctx->nonce[1] = U8TOU32(&key[20]); in Poly1305_Init()
53 ctx->nonce[2] = U8TOU32(&key[24]); in Poly1305_Init()
54 ctx->nonce[3] = U8TOU32(&key[28]); in Poly1305_Init()
58 * to return a value: non-zero if it initializes ctx->func, and zero in Poly1305_Init()
62 if (!poly1305_init(ctx->opaque, key, &ctx->func)) { in Poly1305_Init()
63 ctx->func.blocks = poly1305_blocks; in Poly1305_Init()
64 ctx->func.emit = poly1305_emit; in Poly1305_Init()
67 ctx->num = 0; in Poly1305_Init()
74 * conscious choice imposed by -Wshadow compiler warnings.
89 poly1305_blocks_f poly1305_blocks_p = ctx->func.blocks; in Poly1305_Update()
93 if ((num = ctx->num)) { in Poly1305_Update()
94 rem = POLY1305_BLOCK_SIZE - num; in Poly1305_Update()
96 memcpy(ctx->data + num, inp, rem); in Poly1305_Update()
97 poly1305_blocks(ctx->opaque, ctx->data, POLY1305_BLOCK_SIZE, 1); in Poly1305_Update()
99 len -= rem; in Poly1305_Update()
102 memcpy(ctx->data + num, inp, len); in Poly1305_Update()
103 ctx->num = num + len; in Poly1305_Update()
109 len -= rem; in Poly1305_Update()
112 poly1305_blocks(ctx->opaque, inp, len, 1); in Poly1305_Update()
117 memcpy(ctx->data, inp, rem); in Poly1305_Update()
119 ctx->num = rem; in Poly1305_Update()
122 void Poly1305_Final(POLY1305 *ctx, unsigned char mac[16]) in Poly1305_Final()
125 poly1305_blocks_f poly1305_blocks_p = ctx->func.blocks; in Poly1305_Final()
126 poly1305_emit_f poly1305_emit_p = ctx->func.emit; in Poly1305_Final()
130 if ((num = ctx->num)) { in Poly1305_Final()
131 ctx->data[num++] = 1; /* pad bit */ in Poly1305_Final()
133 ctx->data[num++] = 0; in Poly1305_Final()
134 poly1305_blocks(ctx->opaque, ctx->data, POLY1305_BLOCK_SIZE, 0); in Poly1305_Final()
137 poly1305_emit(ctx->opaque, mac, ctx->nonce); in Poly1305_Final()
170 .name = "OpenSSL-Poly1305",