Lines Matching refs:ctx
88 poly1305_blocks(void *ctx, const unsigned char *inp, size_t len, u32 padbit);
133 static void poly1305_init(void *ctx, const unsigned char key[16])
135 poly1305_internal *st = (poly1305_internal *) ctx;
148 poly1305_blocks(void *ctx, const unsigned char *inp, size_t len, u32 padbit)
150 poly1305_internal *st = (poly1305_internal *)ctx;
213 static void poly1305_emit(void *ctx, unsigned char mac[16],
216 poly1305_internal *st = (poly1305_internal *) ctx;
271 static void poly1305_init(void *ctx, const unsigned char key[16])
273 poly1305_internal *st = (poly1305_internal *) ctx;
290 poly1305_blocks(void *ctx, const unsigned char *inp, size_t len, u32 padbit)
292 poly1305_internal *st = (poly1305_internal *)ctx;
379 static void poly1305_emit(void *ctx, unsigned char mac[16],
382 poly1305_internal *st = (poly1305_internal *) ctx;
426 int poly1305_init(void *ctx, const unsigned char key[16], void *func);
427 void poly1305_blocks(void *ctx, const unsigned char *inp, size_t len,
429 void poly1305_emit(void *ctx, unsigned char mac[16],
433 void Poly1305_Init(POLY1305 *ctx, const unsigned char key[32])
435 ctx->nonce[0] = U8TOU32(&key[16]);
436 ctx->nonce[1] = U8TOU32(&key[20]);
437 ctx->nonce[2] = U8TOU32(&key[24]);
438 ctx->nonce[3] = U8TOU32(&key[28]);
441 poly1305_init(ctx->opaque, key);
445 * to return a value: non-zero if it initializes ctx->func, and zero
449 if (!poly1305_init(ctx->opaque, key, &ctx->func)) {
450 ctx->func.blocks = poly1305_blocks;
451 ctx->func.emit = poly1305_emit;
455 ctx->num = 0;
468 void Poly1305_Update(POLY1305 *ctx, const unsigned char *inp, size_t len)
477 poly1305_blocks_f poly1305_blocks_p = ctx->func.blocks;
481 if ((num = ctx->num)) {
484 memcpy(ctx->data + num, inp, rem);
485 poly1305_blocks(ctx->opaque, ctx->data, POLY1305_BLOCK_SIZE, 1);
490 memcpy(ctx->data + num, inp, len);
491 ctx->num = num + len;
500 poly1305_blocks(ctx->opaque, inp, len, 1);
505 memcpy(ctx->data, inp, rem);
507 ctx->num = rem;
510 void Poly1305_Final(POLY1305 *ctx, unsigned char mac[16])
513 poly1305_blocks_f poly1305_blocks_p = ctx->func.blocks;
514 poly1305_emit_f poly1305_emit_p = ctx->func.emit;
518 if ((num = ctx->num)) {
519 ctx->data[num++] = 1; /* pad bit */
521 ctx->data[num++] = 0;
522 poly1305_blocks(ctx->opaque, ctx->data, POLY1305_BLOCK_SIZE, 0);
525 poly1305_emit(ctx->opaque, mac, ctx->nonce);
528 OPENSSL_cleanse(ctx, sizeof(*ctx));