Lines Matching refs:sctx
90 static void fio_sha3_init(struct fio_sha3_ctx *sctx, unsigned int digest_sz) in fio_sha3_init() argument
92 memset(sctx->st, 0, sizeof(sctx->st)); in fio_sha3_init()
93 sctx->md_len = digest_sz; in fio_sha3_init()
94 sctx->rsiz = 200 - 2 * digest_sz; in fio_sha3_init()
95 sctx->rsizw = sctx->rsiz / 8; in fio_sha3_init()
96 sctx->partial = 0; in fio_sha3_init()
97 memset(sctx->buf, 0, sizeof(sctx->buf)); in fio_sha3_init()
100 void fio_sha3_224_init(struct fio_sha3_ctx *sctx) in fio_sha3_224_init() argument
102 fio_sha3_init(sctx, SHA3_224_DIGEST_SIZE); in fio_sha3_224_init()
105 void fio_sha3_256_init(struct fio_sha3_ctx *sctx) in fio_sha3_256_init() argument
107 fio_sha3_init(sctx, SHA3_256_DIGEST_SIZE); in fio_sha3_256_init()
110 void fio_sha3_384_init(struct fio_sha3_ctx *sctx) in fio_sha3_384_init() argument
112 fio_sha3_init(sctx, SHA3_384_DIGEST_SIZE); in fio_sha3_384_init()
115 void fio_sha3_512_init(struct fio_sha3_ctx *sctx) in fio_sha3_512_init() argument
117 fio_sha3_init(sctx, SHA3_512_DIGEST_SIZE); in fio_sha3_512_init()
120 int fio_sha3_update(struct fio_sha3_ctx *sctx, const uint8_t *data, in fio_sha3_update() argument
129 if ((sctx->partial + len) > (sctx->rsiz - 1)) { in fio_sha3_update()
130 if (sctx->partial) { in fio_sha3_update()
131 done = -sctx->partial; in fio_sha3_update()
132 memcpy(sctx->buf + sctx->partial, data, in fio_sha3_update()
133 done + sctx->rsiz); in fio_sha3_update()
134 src = sctx->buf; in fio_sha3_update()
140 for (i = 0; i < sctx->rsizw; i++) in fio_sha3_update()
141 sctx->st[i] ^= ((uint64_t *) src)[i]; in fio_sha3_update()
142 keccakf(sctx->st); in fio_sha3_update()
144 done += sctx->rsiz; in fio_sha3_update()
146 } while (done + (sctx->rsiz - 1) < len); in fio_sha3_update()
148 sctx->partial = 0; in fio_sha3_update()
150 memcpy(sctx->buf + sctx->partial, src, len - done); in fio_sha3_update()
151 sctx->partial += (len - done); in fio_sha3_update()
156 void fio_sha3_final(struct fio_sha3_ctx *sctx) in fio_sha3_final() argument
158 unsigned int i, inlen = sctx->partial; in fio_sha3_final()
160 sctx->buf[inlen++] = 0x06; in fio_sha3_final()
161 memset(sctx->buf + inlen, 0, sctx->rsiz - inlen); in fio_sha3_final()
162 sctx->buf[sctx->rsiz - 1] |= 0x80; in fio_sha3_final()
164 for (i = 0; i < sctx->rsizw; i++) in fio_sha3_final()
165 sctx->st[i] ^= ((uint64_t *) sctx->buf)[i]; in fio_sha3_final()
167 keccakf(sctx->st); in fio_sha3_final()
169 for (i = 0; i < sctx->rsizw; i++) in fio_sha3_final()
170 sctx->st[i] = cpu_to_le64(sctx->st[i]); in fio_sha3_final()
172 memcpy(sctx->sha, sctx->st, sctx->md_len); in fio_sha3_final()