• Home
  • Raw
  • Download

Lines Matching refs:alg

32 	lws_cose_sig_alg_t *alg = lws_zalloc(sizeof(*alg), __func__);  in lws_cose_sign_alg_create()  local
38 if (!alg) in lws_cose_sign_alg_create()
41 alg->cose_alg = cose_alg; in lws_cose_sign_alg_create()
42 alg->cose_key = ck; in lws_cose_sign_alg_create()
51 alg->keybits = 256; in lws_cose_sign_alg_create()
56 alg->keybits = 384; in lws_cose_sign_alg_create()
61 alg->keybits = 521; in lws_cose_sign_alg_create()
70 if (lws_genhash_init(&alg->hash_ctx, gh)) in lws_cose_sign_alg_create()
73 if (lws_genecdsa_create(&alg->u.ecdsactx, cx, lws_ec_curves)) { in lws_cose_sign_alg_create()
79 if (lws_genecdsa_set_key(&alg->u.ecdsactx, ck->e)) { in lws_cose_sign_alg_create()
90 alg->keybits = 64; in lws_cose_sign_alg_create()
94 alg->keybits = 256; in lws_cose_sign_alg_create()
98 alg->keybits = 384; in lws_cose_sign_alg_create()
102 alg->keybits = 512; in lws_cose_sign_alg_create()
110 if (lws_genhmac_init(&alg->u.hmacctx, ghm, ke->buf, ke->len)) in lws_cose_sign_alg_create()
133 alg->keybits = (int)ck->e[LWS_GENCRYPTO_RSA_KEYEL_N].len * 8; in lws_cose_sign_alg_create()
135 if (lws_genhash_init(&alg->hash_ctx, gh)) in lws_cose_sign_alg_create()
138 if (lws_genrsa_create(&alg->u.rsactx, ck->e, cx, in lws_cose_sign_alg_create()
151 return alg; in lws_cose_sign_alg_create()
154 lws_genec_destroy(&alg->u.ecdsactx); in lws_cose_sign_alg_create()
156 lws_genhash_destroy(&alg->hash_ctx, NULL); in lws_cose_sign_alg_create()
158 lws_free(alg); in lws_cose_sign_alg_create()
163 lws_free(alg); in lws_cose_sign_alg_create()
169 lws_cose_sign_alg_hash(lws_cose_sig_alg_t *alg, const uint8_t *in, size_t in_len) in lws_cose_sign_alg_hash() argument
175 switch (alg->cose_alg) { in lws_cose_sign_alg_hash()
181 return lws_genhmac_update(&alg->u.hmacctx, in, in_len); in lws_cose_sign_alg_hash()
186 return lws_genhash_update(&alg->hash_ctx, in, in_len); in lws_cose_sign_alg_hash()
196 lws_cose_sign_alg_complete(lws_cose_sig_alg_t *alg) in lws_cose_sign_alg_complete() argument
203 if (alg->completed) in lws_cose_sign_alg_complete()
206 switch (alg->cose_alg) { in lws_cose_sign_alg_complete()
210 hs = lws_genhash_size(alg->hash_ctx.type); in lws_cose_sign_alg_complete()
211 bytes = (unsigned int)lws_gencrypto_bits_to_bytes(alg->keybits); in lws_cose_sign_alg_complete()
212 lws_genhash_destroy(&alg->hash_ctx, digest); in lws_cose_sign_alg_complete()
213 alg->rhash_len = 0; in lws_cose_sign_alg_complete()
214 lwsl_notice("alg keybits %d hs %d\n", (int)alg->keybits, (int)hs); in lws_cose_sign_alg_complete()
215 if (!alg->failed && in lws_cose_sign_alg_complete()
216 lws_genecdsa_hash_sign_jws(&alg->u.ecdsactx, digest, in lws_cose_sign_alg_complete()
217 alg->hash_ctx.type, in lws_cose_sign_alg_complete()
218 (int)alg->keybits, alg->rhash, in lws_cose_sign_alg_complete()
220 alg->rhash_len = (int)(2 * bytes); in lws_cose_sign_alg_complete()
222 alg->failed = 1; in lws_cose_sign_alg_complete()
224 lws_genec_destroy(&alg->u.ecdsactx); in lws_cose_sign_alg_complete()
231 alg->rhash_len = (int)lws_genhmac_size(alg->u.hmacctx.type); in lws_cose_sign_alg_complete()
232 if (alg->cose_alg == LWSCOSE_WKAHMAC_256_64) in lws_cose_sign_alg_complete()
233 alg->rhash_len = 8; in lws_cose_sign_alg_complete()
235 if (lws_genhmac_destroy(&alg->u.hmacctx, alg->rhash)) { in lws_cose_sign_alg_complete()
244 bytes = (unsigned int)lws_gencrypto_bits_to_bytes(alg->keybits); in lws_cose_sign_alg_complete()
245 htype = alg->hash_ctx.type; in lws_cose_sign_alg_complete()
247 if (!lws_genhash_destroy(&alg->hash_ctx, digest) && in lws_cose_sign_alg_complete()
248 !alg->failed && in lws_cose_sign_alg_complete()
249 lws_genrsa_hash_sign(&alg->u.rsactx, digest, htype, in lws_cose_sign_alg_complete()
250 alg->rhash, bytes) >= 0) in lws_cose_sign_alg_complete()
251 alg->rhash_len = (int)bytes; in lws_cose_sign_alg_complete()
255 lws_genrsa_destroy(&alg->u.rsactx); in lws_cose_sign_alg_complete()
262 alg->completed = 1; in lws_cose_sign_alg_complete()