• Home
  • Raw
  • Download

Lines Matching refs:csc

31 	struct lws_cose_sign_context *csc;  in lws_cose_sign_create()  local
45 csc = lws_zalloc(sizeof(*csc), __func__); in lws_cose_sign_create()
46 if (!csc) in lws_cose_sign_create()
49 csc->info = *info; in lws_cose_sign_create()
51 return csc; in lws_cose_sign_create()
55 lws_cose_sign_add(struct lws_cose_sign_context *csc, cose_param_t alg, in lws_cose_sign_add() argument
58 lws_cose_sig_alg_t *si = lws_cose_sign_alg_create(csc->info.cx, ck, alg, in lws_cose_sign_add()
64 lws_dll2_add_tail(&si->list, &csc->algs); in lws_cose_sign_add()
79 lws_cose_sign_hashing(struct lws_cose_sign_context *csc, in lws_cose_sign_hashing() argument
87 lws_dll2_get_head(&csc->algs)) { in lws_cose_sign_hashing()
104 lws_cose_sign_payload_chunk(struct lws_cose_sign_context *csc, in lws_cose_sign_payload_chunk() argument
115 switch (csc->tli) { in lws_cose_sign_payload_chunk()
123 if (!csc->algs.count) { in lws_cose_sign_payload_chunk()
128 csc->type = SIGTYPE_MULTI; in lws_cose_sign_payload_chunk()
129 alg = lws_container_of(csc->algs.head, lws_cose_sig_alg_t, list); in lws_cose_sign_payload_chunk()
137 csc->type = SIGTYPE_MAC0; in lws_cose_sign_payload_chunk()
143 if (csc->algs.count == 1) { in lws_cose_sign_payload_chunk()
144 if (!csc->info.sigtype && csc->type == SIGTYPE_MAC) { in lws_cose_sign_payload_chunk()
145 if (csc->info.flags & LCSC_FL_ADD_CBOR_PREFER_MAC0) in lws_cose_sign_payload_chunk()
146 csc->type = SIGTYPE_MAC0; in lws_cose_sign_payload_chunk()
148 if (!csc->info.sigtype || in lws_cose_sign_payload_chunk()
149 csc->info.sigtype == SIGTYPE_SINGLE) /* ie, if no hint */ in lws_cose_sign_payload_chunk()
150 csc->type = SIGTYPE_SINGLE; in lws_cose_sign_payload_chunk()
153 lwsl_notice("%s: decided on type %d\n", __func__, csc->type); in lws_cose_sign_payload_chunk()
159 if (csc->info.flags & LCSC_FL_ADD_CBOR_TAG) { in lws_cose_sign_payload_chunk()
160 ret = lws_lec_printf(csc->info.lec, "%t(", in lws_cose_sign_payload_chunk()
161 cose_tags[csc->type]); in lws_cose_sign_payload_chunk()
169 switch (csc->type) { in lws_cose_sign_payload_chunk()
183 csc->info.lec->scratch[csc->info.lec->scratch_len++] = c; in lws_cose_sign_payload_chunk()
189 lws_cose_sign_hashing(csc, sig_mctx[csc->type], in lws_cose_sign_payload_chunk()
190 sig_mctx_len[csc->type]); in lws_cose_sign_payload_chunk()
192 csc->tli = ST_OUTER_PROTECTED; in lws_cose_sign_payload_chunk()
193 csc->subsequent = 0; in lws_cose_sign_payload_chunk()
204 switch (csc->type) { in lws_cose_sign_payload_chunk()
207 alg = lws_container_of(csc->algs.head, in lws_cose_sign_payload_chunk()
217 if (!csc->subsequent) { in lws_cose_sign_payload_chunk()
221 lws_cose_sign_hashing(csc, lec1.scratch, in lws_cose_sign_payload_chunk()
223 lws_cose_sign_hashing(csc, lec.start, lec.used); in lws_cose_sign_payload_chunk()
224 ret = lws_lec_printf(csc->info.lec, "%.*b", in lws_cose_sign_payload_chunk()
229 csc->subsequent = 1; in lws_cose_sign_payload_chunk()
236 lws_lec_int(csc->info.lec, LWS_CBOR_MAJTYP_BSTR, 0, 0); in lws_cose_sign_payload_chunk()
239 lws_cose_sign_hashing(csc, lec.start, in lws_cose_sign_payload_chunk()
247 csc->tli = ST_OUTER_UNPROTECTED; in lws_cose_sign_payload_chunk()
258 switch (csc->type) { in lws_cose_sign_payload_chunk()
261 alg = lws_container_of(csc->algs.head, in lws_cose_sign_payload_chunk()
265 ret = lws_lec_printf(csc->info.lec, "{%d:%.*b}", in lws_cose_sign_payload_chunk()
276 lws_cose_sign_hashing(csc, lec1.scratch, in lws_cose_sign_payload_chunk()
282 lws_lec_int(csc->info.lec, LWS_CBOR_MAJTYP_BSTR, 0, 0); in lws_cose_sign_payload_chunk()
291 lws_dll2_get_head(&csc->algs)) { in lws_cose_sign_payload_chunk()
317 lws_cose_sign_hashing(csc, lec1.scratch, in lws_cose_sign_payload_chunk()
322 ret = lws_lec_printf(csc->info.lec, "{}"); in lws_cose_sign_payload_chunk()
328 csc->tli = ST_OUTER_PAYLOAD; in lws_cose_sign_payload_chunk()
329 csc->subsequent = 0; in lws_cose_sign_payload_chunk()
333 lws_lec_int(csc->info.lec, LWS_CBOR_MAJTYP_BSTR, 0, in lws_cose_sign_payload_chunk()
334 csc->info.inline_payload_len); in lws_cose_sign_payload_chunk()
338 csc->info.inline_payload_len); in lws_cose_sign_payload_chunk()
339 lws_cose_sign_hashing(csc, lec1.scratch, in lws_cose_sign_payload_chunk()
342 lws_lec_scratch(csc->info.lec); in lws_cose_sign_payload_chunk()
344 csc->rem_pay = csc->info.inline_payload_len; in lws_cose_sign_payload_chunk()
350 if (csc->along) { in lws_cose_sign_payload_chunk()
351 in += csc->along; in lws_cose_sign_payload_chunk()
352 in_len -= csc->along; in lws_cose_sign_payload_chunk()
355 lws_lec_scratch(csc->info.lec); in lws_cose_sign_payload_chunk()
357 if (csc->rem_pay) { in lws_cose_sign_payload_chunk()
359 lws_cose_sign_hashing(csc, in, in_len); in lws_cose_sign_payload_chunk()
365 s = lws_ptr_diff_size_t(csc->info.lec->end, in lws_cose_sign_payload_chunk()
366 csc->info.lec->buf); in lws_cose_sign_payload_chunk()
367 if (s > (size_t)csc->rem_pay) in lws_cose_sign_payload_chunk()
368 s = (size_t)csc->rem_pay; in lws_cose_sign_payload_chunk()
372 memcpy(csc->info.lec->buf, in, s); in lws_cose_sign_payload_chunk()
373 csc->info.lec->buf += s; in lws_cose_sign_payload_chunk()
374 csc->info.lec->used = lws_ptr_diff_size_t( in lws_cose_sign_payload_chunk()
375 csc->info.lec->buf, in lws_cose_sign_payload_chunk()
376 csc->info.lec->start); in lws_cose_sign_payload_chunk()
377 csc->rem_pay -= s; in lws_cose_sign_payload_chunk()
379 csc->along = s; in lws_cose_sign_payload_chunk()
386 if (csc->type == SIGTYPE_MULTI) { in lws_cose_sign_payload_chunk()
388 csc->alg = lws_container_of(csc->algs.head, in lws_cose_sign_payload_chunk()
392 csc->algs.count); in lws_cose_sign_payload_chunk()
393 lws_lec_int(csc->info.lec, LWS_CBOR_MAJTYP_ARRAY, 0, in lws_cose_sign_payload_chunk()
394 csc->algs.count); in lws_cose_sign_payload_chunk()
395 csc->tli = ST_INNER_PROTECTED; in lws_cose_sign_payload_chunk()
398 csc->tli = ST_OUTER_SIGN1_SIGNATURE; in lws_cose_sign_payload_chunk()
399 csc->along = 0; in lws_cose_sign_payload_chunk()
405 alg = lws_container_of(lws_dll2_get_head(&csc->algs), in lws_cose_sign_payload_chunk()
413 ret = lws_lec_printf(csc->info.lec, "%.*b", in lws_cose_sign_payload_chunk()
418 if (csc->type == SIGTYPE_MAC) { in lws_cose_sign_payload_chunk()
419 csc->alg = lws_container_of(csc->algs.head, in lws_cose_sign_payload_chunk()
423 csc->algs.count); in lws_cose_sign_payload_chunk()
424 lws_lec_int(csc->info.lec, LWS_CBOR_MAJTYP_ARRAY, 0, in lws_cose_sign_payload_chunk()
425 csc->algs.count); in lws_cose_sign_payload_chunk()
426 csc->tli = ST_INNER_PROTECTED; in lws_cose_sign_payload_chunk()
440 switch (csc->type) { in lws_cose_sign_payload_chunk()
446 lws_lec_int(csc->info.lec, LWS_CBOR_MAJTYP_ARRAY, 0, 3); in lws_cose_sign_payload_chunk()
452 (long long)csc->alg->cose_alg); in lws_cose_sign_payload_chunk()
457 lws_lec_printf(csc->info.lec, "{1:%lld}", in lws_cose_sign_payload_chunk()
458 (long long)csc->alg->cose_alg); in lws_cose_sign_payload_chunk()
466 csc->tli = ST_INNER_UNPROTECTED; in lws_cose_sign_payload_chunk()
472 switch (csc->type) { in lws_cose_sign_payload_chunk()
474 alg = lws_container_of(csc->algs.head, in lws_cose_sign_payload_chunk()
478 ret = lws_lec_printf(csc->info.lec, "{%d:%.*b}", in lws_cose_sign_payload_chunk()
487 ret = lws_lec_printf(csc->info.lec, "{}"); in lws_cose_sign_payload_chunk()
493 lws_cose_sign_alg_complete(csc->alg); in lws_cose_sign_payload_chunk()
494 if (csc->alg->failed) in lws_cose_sign_payload_chunk()
496 csc->tli = ST_INNER_SIGNATURE; in lws_cose_sign_payload_chunk()
502 ret = lws_lec_printf(csc->info.lec, "%.*b", in lws_cose_sign_payload_chunk()
503 (int)csc->alg->rhash_len, csc->alg->rhash); in lws_cose_sign_payload_chunk()
507 if (csc->alg->list.next) { in lws_cose_sign_payload_chunk()
508 csc->alg = (lws_cose_sig_alg_t *)csc->alg->list.next; in lws_cose_sign_payload_chunk()
509 csc->tli = ST_INNER_PROTECTED; in lws_cose_sign_payload_chunk()
521 struct lws_cose_sign_context *csc = *_csc; in lws_cose_sign_destroy() local
523 if (!csc) in lws_cose_sign_destroy()
527 lws_dll2_get_head(&csc->algs)) { in lws_cose_sign_destroy()