Lines Matching refs:ctx
236 create_alg(struct lecp_ctx *ctx, struct lws_cose_validate_context *cps)
444 cb_cose_sig(struct lecp_ctx *ctx, char reason)
447 (struct lws_cose_validate_context *)ctx->user;
458 cps->sub, ctx->pst[ctx->pst_sp].ppos, cps->sp);
475 switch (ctx->item.u.u64) {
496 if (ctx->item.u.u64 != LWSCOAP_CONTENTFORMAT_COSE_SIGN)
500 if (ctx->item.u.u64 != LWSCOAP_CONTENTFORMAT_COSE_SIGN1)
504 if (ctx->item.u.u64 != LWSCOAP_CONTENTFORMAT_COSE_SIGN)
508 if (ctx->item.u.u64 != LWSCOAP_CONTENTFORMAT_COSE_MAC0)
512 if (ctx->item.u.u64 != LWSCOAP_CONTENTFORMAT_COSE_MAC) {
515 (int)ctx->item.u.u64);
529 if (ctx->pst[ctx->pst_sp].ppos == 4 ||
530 ctx->pst[ctx->pst_sp].ppos == 6) {
537 lecp_parse_report_raw(ctx, 1);
545 if (ctx->pst[ctx->pst_sp].ppos != 2)
559 lecp_parse_report_raw(ctx, 1);
566 if (create_alg(ctx, cps))
582 if (ctx->pst[ctx->pst_sp].ppos == 2) {
589 lecp_parse_report_raw(ctx, 0);
599 if (lecp_parse_subtree(&cps->ctx,
644 if (ctx->pst[ctx->pst_sp].ppos >= 4) {
656 lecp_parse_report_raw(ctx, 0);
695 if (lecp_parse_subtree(&cps->ctx, p, s) !=
708 if (create_alg(ctx, cps))
728 if (lecp_parse_map_is_key(ctx)) {
729 cps->map_key = ctx->item.u.i64;
734 // lwsl_notice("%s: key %d val %d\n", __func__, (int)cps->map_key, (int)ctx->item.u.i64);
742 sl->alg = ctx->item.u.i64;
746 sl->alg = ctx->item.u.i64;
762 lwsl_notice("%s: blob size %d\n", __func__, (int)ctx->item.u.u64);
766 if (ctx->item.u.u64 > sizeof(cps->sig_agg))
781 ctx->item.u.u64);
797 cps->payload_stash_size = (size_t)(ctx->item.u.u64 + s);
814 if (cps->info.pay_cb && ctx->npos)
816 (uint8_t *)ctx->buf, ctx->npos);
819 if (cps->payload_pos + ctx->npos >
823 ctx->buf, ctx->npos);
824 cps->payload_pos += ctx->npos;
832 if (ctx->npos &&
833 lws_cose_val_alg_hash(alg, (uint8_t *)ctx->buf,
834 ctx->npos)) {
841 /* the sig is big compared to ctx->buf... we need to
843 memcpy(cps->sig_agg + cps->sig_agg_pos, ctx->buf,
844 ctx->npos);
845 cps->sig_agg_pos = cps->sig_agg_pos + ctx->npos;
855 memcpy(cps->sig_agg + cps->sig_agg_pos, ctx->buf,
856 ctx->npos);
857 cps->sig_agg_pos = cps->sig_agg_pos + ctx->npos;
859 if (create_alg(ctx, cps))
875 ke->buf = lws_malloc(ctx->npos, __func__);
878 ke->len = ctx->npos;
879 memcpy(ke->buf, ctx->buf, ctx->npos);
885 if (cps->info.pay_cb && ctx->npos)
887 (uint8_t *)ctx->buf, ctx->npos);
889 if (cps->payload_pos + ctx->npos >
893 ctx->buf, ctx->npos);
894 cps->payload_pos += ctx->npos;
903 if (ctx->npos &&
904 lws_cose_val_alg_hash(alg, (uint8_t *)ctx->buf,
905 ctx->npos))
913 memcpy(cps->sig_agg + cps->sig_agg_pos, ctx->buf,
914 ctx->npos);
915 cps->sig_agg_pos += ctx->npos;
927 if (cps->mac_pos + ctx->npos > sizeof(cps->mac))
929 memcpy(cps->mac + cps->mac_pos, ctx->buf, ctx->npos);
930 cps->mac_pos += ctx->npos;
933 if (create_alg(ctx, cps))
950 if (sl->ph_pos[hi] + 3 + ctx->cbor_pos >
954 memcpy(sl->ph[hi] + 3 + sl->ph_pos[hi], ctx->cbor,
955 ctx->cbor_pos);
956 sl->ph_pos[hi] += ctx->cbor_pos;
985 lecp_construct(&cps->ctx, cb_cose_sig, cps, NULL, 0);
996 n = lecp_parse(&cps->ctx, in, in_len);
998 *used_in = cps->ctx.used_in;
1003 lecp_destruct(&cps->ctx);