Lines Matching refs:jwe
29 lws_jwe_encrypt_cbc_hs(struct lws_jwe *jwe, uint8_t *cek, in lws_jwe_encrypt_cbc_hs() argument
32 int n, hlen = (int)lws_genhmac_size(jwe->jose.enc_alg->hmac_type); in lws_jwe_encrypt_cbc_hs()
42 if (jwe->jws.map.len[LJWE_ATAG] != (unsigned int)hlen / 2) { in lws_jwe_encrypt_cbc_hs()
44 hlen / 2, jwe->jws.map.len[LJWE_ATAG]); in lws_jwe_encrypt_cbc_hs()
48 if (jwe->jws.map.len[LJWE_IV] != 16) { in lws_jwe_encrypt_cbc_hs()
50 jwe->jws.map.len[LJWE_IV]); in lws_jwe_encrypt_cbc_hs()
72 lws_get_random(jwe->jws.context, (void *)jwe->jws.map.buf[LJWE_IV], 16); in lws_jwe_encrypt_cbc_hs()
96 n = lws_genaes_crypt(&aesctx, (uint8_t *)jwe->jws.map.buf[LJWE_CTXT], in lws_jwe_encrypt_cbc_hs()
97 jwe->jws.map.len[LJWE_CTXT], in lws_jwe_encrypt_cbc_hs()
98 (uint8_t *)jwe->jws.map.buf[LJWE_CTXT], in lws_jwe_encrypt_cbc_hs()
99 (uint8_t *)jwe->jws.map.buf[LJWE_IV], in lws_jwe_encrypt_cbc_hs()
102 jwe->jws.map.len[LJWE_CTXT]); in lws_jwe_encrypt_cbc_hs()
103 jwe->jws.map.len[LJWE_CTXT] = (uint32_t)paddedlen; in lws_jwe_encrypt_cbc_hs()
104 lws_genaes_destroy(&aesctx, (uint8_t *)jwe->jws.map.buf[LJWE_CTXT] + in lws_jwe_encrypt_cbc_hs()
119 if (lws_genhmac_init(&hmacctx, jwe->jose.enc_alg->hmac_type, in lws_jwe_encrypt_cbc_hs()
138 lws_genhmac_update(&hmacctx, jwe->jws.map.buf[LJWE_IV], in lws_jwe_encrypt_cbc_hs()
142 (uint8_t *)jwe->jws.map.buf[LJWE_CTXT], in lws_jwe_encrypt_cbc_hs()
143 jwe->jws.map.len[LJWE_CTXT]) || in lws_jwe_encrypt_cbc_hs()
156 memcpy((void *)jwe->jws.map.buf[LJWE_ATAG], digest, (unsigned int)hlen / 2); in lws_jwe_encrypt_cbc_hs()
158 return (int)jwe->jws.map.len[LJWE_CTXT]; in lws_jwe_encrypt_cbc_hs()
162 lws_jwe_auth_and_decrypt_cbc_hs(struct lws_jwe *jwe, uint8_t *enc_cek, in lws_jwe_auth_and_decrypt_cbc_hs() argument
165 int n, hlen = (int)lws_genhmac_size(jwe->jose.enc_alg->hmac_type); in lws_jwe_auth_and_decrypt_cbc_hs()
174 if (jwe->jws.map.len[LJWE_ATAG] != (unsigned int)hlen / 2) { in lws_jwe_auth_and_decrypt_cbc_hs()
176 hlen / 2, jwe->jws.map.len[LJWE_ATAG]); in lws_jwe_auth_and_decrypt_cbc_hs()
180 if (jwe->jws.map.len[LJWE_IV] != 16) { in lws_jwe_auth_and_decrypt_cbc_hs()
182 jwe->jws.map.len[LJWE_IV]); in lws_jwe_auth_and_decrypt_cbc_hs()
203 if (lws_genhmac_init(&hmacctx, jwe->jose.enc_alg->hmac_type, enc_cek, in lws_jwe_auth_and_decrypt_cbc_hs()
210 lws_genhmac_update(&hmacctx, (uint8_t *)jwe->jws.map.buf[LJWE_IV], in lws_jwe_auth_and_decrypt_cbc_hs()
211 jwe->jws.map.len[LJWE_IV]) || in lws_jwe_auth_and_decrypt_cbc_hs()
212 lws_genhmac_update(&hmacctx, (uint8_t *)jwe->jws.map.buf[LJWE_CTXT], in lws_jwe_auth_and_decrypt_cbc_hs()
213 jwe->jws.map.len[LJWE_CTXT]) || in lws_jwe_auth_and_decrypt_cbc_hs()
227 if (lws_timingsafe_bcmp(digest, jwe->jws.map.buf[LJWE_ATAG], (unsigned int)hlen / 2)) { in lws_jwe_auth_and_decrypt_cbc_hs()
229 __func__, hlen / 2, jwe->jws.map.len[LJWE_ATAG]); in lws_jwe_auth_and_decrypt_cbc_hs()
230 lwsl_hexdump_notice(jwe->jws.map.buf[LJWE_ATAG], (unsigned int)hlen / 2); in lws_jwe_auth_and_decrypt_cbc_hs()
246 n = lws_genaes_crypt(&aesctx, (uint8_t *)jwe->jws.map.buf[LJWE_CTXT], in lws_jwe_auth_and_decrypt_cbc_hs()
247 jwe->jws.map.len[LJWE_CTXT], in lws_jwe_auth_and_decrypt_cbc_hs()
248 (uint8_t *)jwe->jws.map.buf[LJWE_CTXT], in lws_jwe_auth_and_decrypt_cbc_hs()
249 (uint8_t *)jwe->jws.map.buf[LJWE_IV], NULL, NULL, 16); in lws_jwe_auth_and_decrypt_cbc_hs()
253 if (jwe->jws.map.len[LJWE_CTXT] < LWS_AES_CBC_BLOCKLEN || in lws_jwe_auth_and_decrypt_cbc_hs()
254 jwe->jws.map.len[LJWE_CTXT] <= (unsigned char)jwe->jws.map.buf[LJWE_CTXT] in lws_jwe_auth_and_decrypt_cbc_hs()
255 [jwe->jws.map.len[LJWE_CTXT] - 1]) { in lws_jwe_auth_and_decrypt_cbc_hs()
257 __func__, jwe->jws.map.len[LJWE_CTXT]); in lws_jwe_auth_and_decrypt_cbc_hs()
260 jwe->jws.map.len[LJWE_CTXT] = (uint32_t)((int)jwe->jws.map.len[LJWE_CTXT] - in lws_jwe_auth_and_decrypt_cbc_hs()
261 jwe->jws.map.buf[LJWE_CTXT][jwe->jws.map.len[LJWE_CTXT] - 1]); in lws_jwe_auth_and_decrypt_cbc_hs()
269 return (int)jwe->jws.map.len[LJWE_CTXT]; in lws_jwe_auth_and_decrypt_cbc_hs()