Lines Matching defs:ctx
15 void ossl_sha3_reset(KECCAK1600_CTX *ctx)
17 memset(ctx->A, 0, sizeof(ctx->A));
18 ctx->bufsz = 0;
21 int ossl_sha3_init(KECCAK1600_CTX *ctx, unsigned char pad, size_t bitlen)
25 if (bsz <= sizeof(ctx->buf)) {
26 ossl_sha3_reset(ctx);
27 ctx->block_size = bsz;
28 ctx->md_size = bitlen / 8;
29 ctx->pad = pad;
36 int ossl_keccak_kmac_init(KECCAK1600_CTX *ctx, unsigned char pad, size_t bitlen)
38 int ret = ossl_sha3_init(ctx, pad, bitlen);
41 ctx->md_size *= 2;
45 int ossl_sha3_update(KECCAK1600_CTX *ctx, const void *_inp, size_t len)
48 size_t bsz = ctx->block_size;
54 if ((num = ctx->bufsz) != 0) { /* process intermediate buffer? */
58 memcpy(ctx->buf + num, inp, len);
59 ctx->bufsz += len;
67 memcpy(ctx->buf + num, inp, rem);
69 (void)SHA3_absorb(ctx->A, ctx->buf, bsz, bsz);
70 ctx->bufsz = 0;
71 /* ctx->buf is processed, ctx->num is guaranteed to be zero */
75 rem = SHA3_absorb(ctx->A, inp, len, bsz);
80 memcpy(ctx->buf, inp + len - rem, rem);
81 ctx->bufsz = rem;
87 int ossl_sha3_final(unsigned char *md, KECCAK1600_CTX *ctx)
89 size_t bsz = ctx->block_size;
90 size_t num = ctx->bufsz;
92 if (ctx->md_size == 0)
100 memset(ctx->buf + num, 0, bsz - num);
101 ctx->buf[num] = ctx->pad;
102 ctx->buf[bsz - 1] |= 0x80;
104 (void)SHA3_absorb(ctx->A, ctx->buf, bsz, bsz);
106 SHA3_squeeze(ctx->A, md, ctx->md_size, bsz);