Lines Matching refs:alg
32 lws_cose_sig_alg_t *alg = lws_zalloc(sizeof(*alg), __func__); in lws_cose_val_alg_create() local
38 if (!alg) in lws_cose_val_alg_create()
41 alg->cose_alg = cose_alg; in lws_cose_val_alg_create()
42 alg->cose_key = ck; in lws_cose_val_alg_create()
51 alg->keybits = 256; in lws_cose_val_alg_create()
56 alg->keybits = 384; in lws_cose_val_alg_create()
61 alg->keybits = 521; in lws_cose_val_alg_create()
70 if (lws_genhash_init(&alg->hash_ctx, gh)) in lws_cose_val_alg_create()
73 if (lws_genecdsa_create(&alg->u.ecdsactx, cx, lws_ec_curves)) { in lws_cose_val_alg_create()
79 if (lws_genecdsa_set_key(&alg->u.ecdsactx, ck->e)) { in lws_cose_val_alg_create()
90 alg->keybits = 64; in lws_cose_val_alg_create()
94 alg->keybits = 256; in lws_cose_val_alg_create()
98 alg->keybits = 384; in lws_cose_val_alg_create()
102 alg->keybits = 512; in lws_cose_val_alg_create()
110 if (lws_genhmac_init(&alg->u.hmacctx, ghm, ke->buf, ke->len)) in lws_cose_val_alg_create()
132 alg->keybits = (int)ck->e[LWS_GENCRYPTO_RSA_KEYEL_N].len * 8; in lws_cose_val_alg_create()
134 if (lws_genhash_init(&alg->hash_ctx, gh)) in lws_cose_val_alg_create()
137 if (lws_genrsa_create(&alg->u.rsactx, ck->e, cx, in lws_cose_val_alg_create()
150 return alg; in lws_cose_val_alg_create()
153 lws_genec_destroy(&alg->u.ecdsactx); in lws_cose_val_alg_create()
155 lws_genhash_destroy(&alg->hash_ctx, NULL); in lws_cose_val_alg_create()
157 lws_free(alg); in lws_cose_val_alg_create()
164 lws_free(alg); in lws_cose_val_alg_create()
170 lws_cose_val_alg_hash(lws_cose_sig_alg_t *alg, const uint8_t *in, size_t in_len) in lws_cose_val_alg_hash() argument
176 switch (alg->cose_alg) { in lws_cose_val_alg_hash()
181 return lws_genhmac_update(&alg->u.hmacctx, in, in_len); in lws_cose_val_alg_hash()
184 return lws_genhash_update(&alg->hash_ctx, in, in_len); in lws_cose_val_alg_hash()
193 lws_cose_sig_alg_t *alg = *_alg; in lws_cose_val_alg_destroy() local
199 lws_dll2_remove(&alg->list); in lws_cose_val_alg_destroy()
200 ht = alg->hash_ctx.type; in lws_cose_val_alg_destroy()
201 keybits = alg->keybits; in lws_cose_val_alg_destroy()
206 res->cose_key = alg->cose_key; in lws_cose_val_alg_destroy()
207 res->cose_alg = alg->cose_alg; in lws_cose_val_alg_destroy()
213 switch (alg->cose_alg) { in lws_cose_val_alg_destroy()
217 hs = lws_genhash_size(alg->hash_ctx.type); in lws_cose_val_alg_destroy()
218 lws_genhash_destroy(&alg->hash_ctx, digest); in lws_cose_val_alg_destroy()
224 &alg->u.ecdsactx, digest, ht, in lws_cose_val_alg_destroy()
226 lws_genec_destroy(&alg->u.ecdsactx); in lws_cose_val_alg_destroy()
233 shs = hs = lws_genhmac_size(alg->u.hmacctx.type); in lws_cose_val_alg_destroy()
234 if (alg->cose_alg == LWSCOSE_WKAHMAC_256_64) in lws_cose_val_alg_destroy()
237 if (lws_genhmac_destroy(&alg->u.hmacctx, digest)) { in lws_cose_val_alg_destroy()
259 if (!lws_genhash_destroy(&alg->hash_ctx, digest) && in lws_cose_val_alg_destroy()
260 !alg->failed && in lws_cose_val_alg_destroy()
261 lws_genrsa_hash_sig_verify(&alg->u.rsactx, digest, in lws_cose_val_alg_destroy()
262 alg->hash_ctx.type, in lws_cose_val_alg_destroy()
269 lws_genrsa_destroy(&alg->u.rsactx); in lws_cose_val_alg_destroy()