Lines Matching refs:ctx
42 struct crypto_hash *ctx; in crypto_hash_init() local
47 ctx = os_zalloc(sizeof(*ctx)); in crypto_hash_init()
48 if (ctx == NULL) in crypto_hash_init()
51 ctx->alg = alg; in crypto_hash_init()
55 MD5Init(&ctx->u.md5); in crypto_hash_init()
58 SHA1Init(&ctx->u.sha1); in crypto_hash_init()
62 sha256_init(&ctx->u.sha256); in crypto_hash_init()
67 sha384_init(&ctx->u.sha384); in crypto_hash_init()
72 sha512_init(&ctx->u.sha512); in crypto_hash_init()
77 MD5Init(&ctx->u.md5); in crypto_hash_init()
78 MD5Update(&ctx->u.md5, key, key_len); in crypto_hash_init()
79 MD5Final(tk, &ctx->u.md5); in crypto_hash_init()
83 os_memcpy(ctx->key, key, key_len); in crypto_hash_init()
84 ctx->key_len = key_len; in crypto_hash_init()
91 MD5Init(&ctx->u.md5); in crypto_hash_init()
92 MD5Update(&ctx->u.md5, k_pad, sizeof(k_pad)); in crypto_hash_init()
96 SHA1Init(&ctx->u.sha1); in crypto_hash_init()
97 SHA1Update(&ctx->u.sha1, key, key_len); in crypto_hash_init()
98 SHA1Final(tk, &ctx->u.sha1); in crypto_hash_init()
102 os_memcpy(ctx->key, key, key_len); in crypto_hash_init()
103 ctx->key_len = key_len; in crypto_hash_init()
110 SHA1Init(&ctx->u.sha1); in crypto_hash_init()
111 SHA1Update(&ctx->u.sha1, k_pad, sizeof(k_pad)); in crypto_hash_init()
116 sha256_init(&ctx->u.sha256); in crypto_hash_init()
117 sha256_process(&ctx->u.sha256, key, key_len); in crypto_hash_init()
118 sha256_done(&ctx->u.sha256, tk); in crypto_hash_init()
122 os_memcpy(ctx->key, key, key_len); in crypto_hash_init()
123 ctx->key_len = key_len; in crypto_hash_init()
130 sha256_init(&ctx->u.sha256); in crypto_hash_init()
131 sha256_process(&ctx->u.sha256, k_pad, sizeof(k_pad)); in crypto_hash_init()
135 os_free(ctx); in crypto_hash_init()
139 return ctx; in crypto_hash_init()
143 void crypto_hash_update(struct crypto_hash *ctx, const u8 *data, size_t len) in crypto_hash_update() argument
145 if (ctx == NULL) in crypto_hash_update()
148 switch (ctx->alg) { in crypto_hash_update()
151 MD5Update(&ctx->u.md5, data, len); in crypto_hash_update()
155 SHA1Update(&ctx->u.sha1, data, len); in crypto_hash_update()
160 sha256_process(&ctx->u.sha256, data, len); in crypto_hash_update()
165 sha384_process(&ctx->u.sha384, data, len); in crypto_hash_update()
170 sha512_process(&ctx->u.sha512, data, len); in crypto_hash_update()
179 int crypto_hash_finish(struct crypto_hash *ctx, u8 *mac, size_t *len) in crypto_hash_finish() argument
184 if (ctx == NULL) in crypto_hash_finish()
188 os_free(ctx); in crypto_hash_finish()
192 switch (ctx->alg) { in crypto_hash_finish()
196 os_free(ctx); in crypto_hash_finish()
200 MD5Final(mac, &ctx->u.md5); in crypto_hash_finish()
205 os_free(ctx); in crypto_hash_finish()
209 SHA1Final(mac, &ctx->u.sha1); in crypto_hash_finish()
215 os_free(ctx); in crypto_hash_finish()
219 sha256_done(&ctx->u.sha256, mac); in crypto_hash_finish()
226 os_free(ctx); in crypto_hash_finish()
230 sha384_done(&ctx->u.sha384, mac); in crypto_hash_finish()
237 os_free(ctx); in crypto_hash_finish()
241 sha512_done(&ctx->u.sha512, mac); in crypto_hash_finish()
247 os_free(ctx); in crypto_hash_finish()
252 MD5Final(mac, &ctx->u.md5); in crypto_hash_finish()
254 os_memcpy(k_pad, ctx->key, ctx->key_len); in crypto_hash_finish()
255 os_memset(k_pad + ctx->key_len, 0, in crypto_hash_finish()
256 sizeof(k_pad) - ctx->key_len); in crypto_hash_finish()
259 MD5Init(&ctx->u.md5); in crypto_hash_finish()
260 MD5Update(&ctx->u.md5, k_pad, sizeof(k_pad)); in crypto_hash_finish()
261 MD5Update(&ctx->u.md5, mac, 16); in crypto_hash_finish()
262 MD5Final(mac, &ctx->u.md5); in crypto_hash_finish()
267 os_free(ctx); in crypto_hash_finish()
272 SHA1Final(mac, &ctx->u.sha1); in crypto_hash_finish()
274 os_memcpy(k_pad, ctx->key, ctx->key_len); in crypto_hash_finish()
275 os_memset(k_pad + ctx->key_len, 0, in crypto_hash_finish()
276 sizeof(k_pad) - ctx->key_len); in crypto_hash_finish()
279 SHA1Init(&ctx->u.sha1); in crypto_hash_finish()
280 SHA1Update(&ctx->u.sha1, k_pad, sizeof(k_pad)); in crypto_hash_finish()
281 SHA1Update(&ctx->u.sha1, mac, 20); in crypto_hash_finish()
282 SHA1Final(mac, &ctx->u.sha1); in crypto_hash_finish()
288 os_free(ctx); in crypto_hash_finish()
293 sha256_done(&ctx->u.sha256, mac); in crypto_hash_finish()
295 os_memcpy(k_pad, ctx->key, ctx->key_len); in crypto_hash_finish()
296 os_memset(k_pad + ctx->key_len, 0, in crypto_hash_finish()
297 sizeof(k_pad) - ctx->key_len); in crypto_hash_finish()
300 sha256_init(&ctx->u.sha256); in crypto_hash_finish()
301 sha256_process(&ctx->u.sha256, k_pad, sizeof(k_pad)); in crypto_hash_finish()
302 sha256_process(&ctx->u.sha256, mac, 32); in crypto_hash_finish()
303 sha256_done(&ctx->u.sha256, mac); in crypto_hash_finish()
307 os_free(ctx); in crypto_hash_finish()
311 os_free(ctx); in crypto_hash_finish()