Lines Matching defs:sctx
72 static void sm3_transform(struct sm3_state *sctx, u8 const *data, u32 W[16])
76 a = sctx->state[0];
77 b = sctx->state[1];
78 c = sctx->state[2];
79 d = sctx->state[3];
80 e = sctx->state[4];
81 f = sctx->state[5];
82 g = sctx->state[6];
83 h = sctx->state[7];
153 sctx->state[0] ^= a;
154 sctx->state[1] ^= b;
155 sctx->state[2] ^= c;
156 sctx->state[3] ^= d;
157 sctx->state[4] ^= e;
158 sctx->state[5] ^= f;
159 sctx->state[6] ^= g;
160 sctx->state[7] ^= h;
169 static inline void sm3_block(struct sm3_state *sctx,
173 sm3_transform(sctx, data, W);
178 void sm3_update(struct sm3_state *sctx, const u8 *data, unsigned int len)
180 unsigned int partial = sctx->count % SM3_BLOCK_SIZE;
183 sctx->count += len;
191 memcpy(sctx->buffer + partial, data, p);
195 sm3_block(sctx, sctx->buffer, 1, W);
202 sm3_block(sctx, data, blocks, W);
211 memcpy(sctx->buffer + partial, data, len);
215 void sm3_final(struct sm3_state *sctx, u8 *out)
218 __be64 *bits = (__be64 *)(sctx->buffer + bit_offset);
220 unsigned int partial = sctx->count % SM3_BLOCK_SIZE;
224 sctx->buffer[partial++] = 0x80;
226 memset(sctx->buffer + partial, 0, SM3_BLOCK_SIZE - partial);
229 sm3_block(sctx, sctx->buffer, 1, W);
232 memset(sctx->buffer + partial, 0, bit_offset - partial);
233 *bits = cpu_to_be64(sctx->count << 3);
234 sm3_block(sctx, sctx->buffer, 1, W);
237 put_unaligned_be32(sctx->state[i], digest++);
241 memzero_explicit(sctx, sizeof(*sctx));