Lines Matching refs:jwe
2 * lws-api-test-jose - RFC7516 jwe tests
72 struct lws_jwe jwe;
76 lws_jwe_init(&jwe, context);
78 if (lws_jwk_import(&jwe.jwk, NULL, NULL, ex_a1_jwk_json,
86 &jwe.jws.map, &jwe.jws.map_b64, temp,
92 n = lws_jwe_auth_and_decrypt(&jwe, lws_concat_temp(temp, temp_len),
101 if (jwe.jws.map.len[LJWE_CTXT] < strlen(ex_a1_ptext) ||
102 lws_timingsafe_bcmp(jwe.jws.map.buf[LJWE_CTXT], ex_a1_ptext,
106 lwsl_hexdump_notice(jwe.jws.map.buf[LJWE_CTXT],
107 jwe.jws.map.len[LJWE_CTXT]);
115 lws_jwe_destroy(&jwe);
117 lws_jwe_init(&jwe, context);
119 if (lws_jwk_import(&jwe.jwk, NULL, NULL, ex_a1_jwk_json,
125 if (lws_gencrypto_jwe_alg_to_definition("RSA-OAEP", &jwe.jose.alg)) {
129 if (lws_gencrypto_jwe_enc_to_definition("A256GCM", &jwe.jose.enc_alg)) {
136 jwe.jws.map.buf[LJWS_JOSE] = temp;
137 jwe.jws.map.len[LJWS_JOSE] = (uint32_t)lws_snprintf(temp, (unsigned int)temp_len,
139 temp_len -= (int)jwe.jws.map.len[LJWS_JOSE];
146 if (lws_jws_dup_element(&jwe.jws.map, LJWE_CTXT,
155 n = lws_gencrypto_bits_to_bytes(jwe.jose.enc_alg->keybits_fixed);
156 if (lws_jws_randomize_element(context, &jwe.jws.map, LJWE_EKEY,
164 n = lws_jwe_encrypt(&jwe, lws_concat_temp(temp, temp_len),
170 n = lws_jwe_render_compact(&jwe, compact, sizeof(compact));
183 lws_jwe_destroy(&jwe);
184 lws_jwe_init(&jwe, context);
188 if (lws_jws_compact_decode(compact, (int)strlen(compact), &jwe.jws.map,
189 &jwe.jws.map_b64, temp, &temp_len) != 5) {
194 if (lws_jwk_import(&jwe.jwk, NULL, NULL, ex_a1_jwk_json,
200 n = lws_jwe_auth_and_decrypt(&jwe, lws_concat_temp(temp, temp_len),
211 lws_jwe_destroy(&jwe);
288 struct lws_jwe jwe;
292 lws_jwe_init(&jwe, context);
294 if (lws_jwk_import(&jwe.jwk, NULL, NULL, (char *)lws_jwe_ex_a2_jwk_json,
303 &jwe.jws.map, &jwe.jws.map_b64,
309 n = lws_jwe_auth_and_decrypt(&jwe, lws_concat_temp(temp, temp_len),
318 if (jwe.jws.map.len[LJWE_CTXT] < sizeof(ex_a2_ptext) ||
319 lws_timingsafe_bcmp(jwe.jws.map.buf[LJWE_CTXT], ex_a2_ptext,
323 lwsl_hexdump_notice(jwe.jws.map.buf[LJWE_CTXT],
324 jwe.jws.map.len[LJWE_CTXT]);
331 lws_jwe_destroy(&jwe);
496 struct lws_jwe jwe;
499 lws_jwe_init(&jwe, context);
503 if (lws_jwk_import(&jwe.jwk, NULL, NULL, jwk_txt, (unsigned int)jwk_len) < 0) {
510 if (lws_jws_dup_element(&jwe.jws.map, LJWE_CTXT,
521 if (lws_jws_dup_element(&jwe.jws.map, LJWE_EKEY,
529 jwe.jws.map.buf[LJWE_JOSE] = rsa256a128_jose;
530 jwe.jws.map.len[LJWE_JOSE] = (uint32_t)strlen(rsa256a128_jose);
532 n = lws_jwe_parse_jose(&jwe.jose, jwe.jws.map.buf[LJWE_JOSE],
533 (int)jwe.jws.map.len[LJWE_JOSE],
541 n = lws_jwe_encrypt(&jwe, lws_concat_temp(temp, temp_len),
548 n = lws_jwe_render_compact(&jwe, compact, sizeof(compact));
556 lws_jwe_destroy(&jwe);
557 lws_jwe_init(&jwe, context);
562 if (lws_jwk_import(&jwe.jwk, NULL, NULL, jwk_txt, (unsigned int)jwk_len) < 0) {
567 if (lws_jws_compact_decode(compact, n, &jwe.jws.map, &jwe.jws.map_b64,
574 n = lws_jwe_auth_and_decrypt(&jwe, lws_concat_temp(temp, temp_len),
583 if (jwe.jws.map.len[LJWE_CTXT] < sizeof(ra_ptext_1024) ||
584 lws_timingsafe_bcmp(jwe.jws.map.buf[LJWE_CTXT], ra_ptext_1024,
588 lwsl_hexdump_notice(jwe.jws.map.buf[LJWE_CTXT],
589 jwe.jws.map.len[LJWE_CTXT]);
596 lws_jwe_destroy(&jwe);
622 struct lws_jwe jwe;
626 lws_jwe_init(&jwe, context);
630 if (lws_jwk_import(&jwe.jwk, NULL, NULL, jwk_txt, (unsigned int)jwk_len) < 0) {
640 if (lws_jws_dup_element(&jwe.jws.map, LJWE_CTXT,
651 if (lws_jws_dup_element(&jwe.jws.map, LJWE_EKEY,
659 jwe.jws.map.buf[LJWE_JOSE] = rsa256a192_jose;
660 jwe.jws.map.len[LJWE_JOSE] = (uint32_t)strlen(rsa256a192_jose);
662 n = lws_jwe_parse_jose(&jwe.jose, jwe.jws.map.buf[LJWE_JOSE],
663 (int)jwe.jws.map.len[LJWE_JOSE],
671 n = lws_jwe_encrypt(&jwe, lws_concat_temp(temp, temp_len),
678 n = lws_jwe_render_compact(&jwe, compact, sizeof(compact));
688 lws_jwe_destroy(&jwe);
689 lws_jwe_init(&jwe, context);
691 if (lws_jwk_import(&jwe.jwk, NULL, NULL, jwk_txt, (unsigned int)jwk_len) < 0) {
696 if (lws_jws_compact_decode(compact, n, &jwe.jws.map, &jwe.jws.map_b64,
703 n = lws_jwe_auth_and_decrypt(&jwe, lws_concat_temp(temp, temp_len),
712 if (jwe.jws.map.len[LJWE_CTXT] < sizeof(ra_ptext_1024) ||
713 lws_timingsafe_bcmp(jwe.jws.map.buf[LJWE_CTXT], ra_ptext_1024,
717 lwsl_hexdump_notice(jwe.jws.map.buf[LJWE_CTXT],
718 jwe.jws.map.len[LJWE_CTXT]);
725 lws_jwe_destroy(&jwe);
754 struct lws_jwe jwe;
758 lws_jwe_init(&jwe, context);
762 if (lws_jwk_import(&jwe.jwk, NULL, NULL, jwk_txt, (unsigned int)jwk_len) < 0) {
772 if (lws_jws_dup_element(&jwe.jws.map, LJWE_CTXT,
783 if (lws_jws_dup_element(&jwe.jws.map, LJWE_EKEY,
791 jwe.jws.map.buf[LJWE_JOSE] = rsa256a256_jose;
792 jwe.jws.map.len[LJWE_JOSE] = (uint32_t)strlen(rsa256a256_jose);
794 n = lws_jwe_parse_jose(&jwe.jose, rsa256a256_jose,
803 n = lws_jwe_encrypt(&jwe, lws_concat_temp(temp, temp_len),
810 n = lws_jwe_render_compact(&jwe, compact, sizeof(compact));
820 lws_jwe_destroy(&jwe);
821 lws_jwe_init(&jwe, context);
823 if (lws_jwk_import(&jwe.jwk, NULL, NULL, jwk_txt, (unsigned int)jwk_len) < 0) {
828 if (lws_jws_compact_decode(compact, n, &jwe.jws.map, &jwe.jws.map_b64,
835 n = lws_jwe_auth_and_decrypt(&jwe, lws_concat_temp(temp, temp_len),
844 if (jwe.jws.map.len[LJWE_CTXT] < sizeof(ra_ptext_1024) ||
845 lws_timingsafe_bcmp(jwe.jws.map.buf[LJWE_CTXT], ra_ptext_1024,
849 lwsl_hexdump_notice(jwe.jws.map.buf[LJWE_CTXT],
850 jwe.jws.map.len[LJWE_CTXT]);
857 lws_jwe_destroy(&jwe);
1048 struct lws_jwe jwe;
1052 lws_jwe_init(&jwe, context);
1054 if (lws_jwk_import(&jwe.jwk, NULL, NULL, (char *)lws_jwe_ex_a2_jwk_json,
1063 &jwe.jws.map, &jwe.jws.map_b64,
1069 n = lws_jwe_auth_and_decrypt(&jwe, lws_concat_temp(temp, temp_len),
1078 if (jwe.jws.map.len[LJWE_CTXT] < sizeof(ra_ptext_1024) ||
1079 lws_timingsafe_bcmp(jwe.jws.map.buf[LJWE_CTXT], ra_ptext_1024,
1083 lwsl_hexdump_notice(jwe.jws.map.buf[LJWE_CTXT],
1084 jwe.jws.map.len[LJWE_CTXT]);
1091 lws_jwe_destroy(&jwe);
1139 struct lws_jwe jwe;
1143 lws_jwe_init(&jwe, context);
1145 if (lws_jwk_import(&jwe.jwk, NULL, NULL, (char *)lws_jwe_ex_a2_jwk_json,
1154 &jwe.jws.map, &jwe.jws.map_b64,
1160 n = lws_jwe_auth_and_decrypt(&jwe, lws_concat_temp(temp, temp_len),
1169 if (jwe.jws.map.len[LJWE_CTXT] < sizeof(ra_ptext_1024) ||
1170 lws_timingsafe_bcmp(jwe.jws.map.buf[LJWE_CTXT], ra_ptext_1024,
1174 lwsl_hexdump_notice(jwe.jws.map.buf[LJWE_CTXT],
1175 jwe.jws.map.len[LJWE_CTXT]);
1182 lws_jwe_destroy(&jwe);
1230 struct lws_jwe jwe;
1234 lws_jwe_init(&jwe, context);
1236 if (lws_jwk_import(&jwe.jwk, NULL, NULL, (char *)ex_a3_key,
1245 &jwe.jws.map, &jwe.jws.map_b64, temp,
1251 n = lws_jwe_auth_and_decrypt(&jwe, lws_concat_temp(temp, temp_len),
1260 if (jwe.jws.map.len[LJWE_CTXT] < sizeof(ex_a3_ptext) ||
1261 lws_timingsafe_bcmp(jwe.jws.map.buf[LJWE_CTXT], ex_a3_ptext,
1265 lwsl_hexdump_notice(jwe.jws.map.buf[LJWE_CTXT],
1266 jwe.jws.map.len[LJWE_CTXT]);
1273 lws_jwe_destroy(&jwe);
1364 struct lws_jwe jwe;
1368 lws_jwe_init(&jwe, context);
1378 lws_jwk_dup_oct(&jwe.jwk, jwa_b2_rawkey, sizeof(jwa_b2_rawkey));
1382 jwe.jws.map.buf[LJWE_IV] = (char *)jwa_b2_iv;
1383 jwe.jws.map.len[LJWE_IV] = sizeof(jwa_b2_iv);
1385 jwe.jws.map.buf[LJWE_CTXT] = buf;
1386 jwe.jws.map.len[LJWE_CTXT] = sizeof(jwa_b2_e);
1388 jwe.jws.map.buf[LJWE_ATAG] = (char *)jwa_b2_tag;
1389 jwe.jws.map.len[LJWE_ATAG] = sizeof(jwa_b2_tag);
1396 if (lws_gencrypto_jwe_alg_to_definition("A128KW", &jwe.jose.alg))
1399 &jwe.jose.enc_alg))
1402 n = lws_jwe_auth_and_decrypt_cbc_hs(&jwe, jwa_b2_rawkey,
1411 if (jwe.jws.map.len[LJWE_CTXT] < sizeof(jwa_b2_ptext) ||
1412 lws_timingsafe_bcmp(jwe.jws.map.buf[LJWE_CTXT],jwa_b2_ptext,
1416 lwsl_hexdump_notice(jwe.jws.map.buf[LJWE_CTXT],
1417 jwe.jws.map.len[LJWE_CTXT]);
1424 lws_jwe_destroy(&jwe);
1520 struct lws_jwe jwe;
1524 lws_jwe_init(&jwe, context);
1534 lws_jwk_dup_oct(&jwe.jwk, jwa_b3_rawkey, sizeof(jwa_b3_rawkey));
1538 jwe.jws.map.buf[LJWE_IV] = (char *)jwa_b3_iv;
1539 jwe.jws.map.len[LJWE_IV] = sizeof(jwa_b3_iv);
1541 jwe.jws.map.buf[LJWE_CTXT] = buf;
1542 jwe.jws.map.len[LJWE_CTXT] = sizeof(jwa_b3_e);
1544 jwe.jws.map.buf[LJWE_ATAG] = (char *)jws_b3_tag;
1545 jwe.jws.map.len[LJWE_ATAG] = sizeof(jws_b3_tag);
1552 if (lws_gencrypto_jwe_alg_to_definition("A128KW", &jwe.jose.alg))
1555 &jwe.jose.enc_alg))
1558 n = lws_jwe_auth_and_decrypt_cbc_hs(&jwe, jwa_b3_rawkey,
1567 if (jwe.jws.map.len[LJWE_CTXT] < sizeof(jwa_b3_ptext) ||
1568 lws_timingsafe_bcmp(jwe.jws.map.buf[LJWE_CTXT],jwa_b3_ptext,
1572 lwsl_hexdump_notice(jwe.jws.map.buf[LJWE_CTXT],
1573 jwe.jws.map.len[LJWE_CTXT]);
1580 lws_jwe_destroy(&jwe);
1638 struct lws_jwe jwe;
1642 lws_jwe_init(&jwe, context);
1653 if (lws_jwe_parse_jose(&jwe.jose, ex_jwa_c_jose, (int)strlen(ex_jwa_c_jose),
1661 * The ephemeral key has been parsed into a jwk "jwe.jose.jwk_ephemeral"
1670 if (lws_jwa_concat_kdf(&jwe, 1, (uint8_t *)p,
1690 lws_jwe_destroy(&jwe);
1790 struct lws_jwe jwe;
1792 lws_jwe_init(&jwe, context);
1796 if (lws_jws_dup_element(&jwe.jws.map, LJWS_JOSE,
1801 if (lws_jwe_parse_jose(&jwe.jose, jose_hdr, (int)strlen(jose_hdr),
1810 if (lws_jwk_import(&jwe.jwk, NULL, NULL, (char *)peer_pubkey,
1821 if (lws_jws_dup_element(&jwe.jws.map, LJWE_CTXT,
1835 n = lws_jwe_encrypt(&jwe, lws_concat_temp(temp, temp_len), &temp_len);
1845 n = lws_jwe_render_flattened(&jwe, compact, sizeof(compact));
1854 n = lws_jwe_render_compact(&jwe, compact, sizeof(compact));
1866 lws_jwe_destroy(&jwe);
1868 lws_jwe_init(&jwe, context);
1870 if (lws_jwk_import(&jwe.jwk, NULL, NULL, (char *)peer_privkey,
1877 if (lws_jws_compact_decode(compact, (int)strlen(compact), &jwe.jws.map,
1878 &jwe.jws.map_b64, temp, &temp_len) != 5) {
1883 n = lws_jwe_auth_and_decrypt(&jwe, lws_concat_temp(temp, temp_len),
1894 lws_jwe_destroy(&jwe);
1967 struct lws_jwe jwe;
1971 lws_jwe_init(&jwe, context);
1973 if (lws_jwk_import(&jwe.jwk, NULL, NULL, key, strlen(key)) < 0) {
1980 &jwe.jws.map, &jwe.jws.map_b64,
1986 n = lws_jwe_auth_and_decrypt(&jwe, lws_concat_temp(temp, temp_len), &temp_len);
1994 if (jwe.jws.map.len[LJWE_CTXT] < strlen(akw_ptext) ||
1995 lws_timingsafe_bcmp(jwe.jws.map.buf[LJWE_CTXT], akw_ptext,
1999 lwsl_hexdump_notice(jwe.jws.map.buf[LJWE_CTXT],
2000 jwe.jws.map.len[LJWE_CTXT]);
2007 lws_jwe_destroy(&jwe);
2022 struct lws_jwe jwe;
2026 lws_jwe_init(&jwe, context);
2028 if (lws_jwk_import(&jwe.jwk, NULL, NULL, key, strlen(key)) < 0) {
2033 if (lws_gencrypto_jwe_alg_to_definition(alg, &jwe.jose.alg)) {
2037 if (lws_gencrypto_jwe_enc_to_definition(enc, &jwe.jose.enc_alg)) {
2044 jwe.jws.map.buf[LJWS_JOSE] = temp;
2045 jwe.jws.map.len[LJWS_JOSE] = (uint32_t)lws_snprintf(temp, (unsigned int)temp_len,
2047 temp_len -= (int)jwe.jws.map.len[LJWS_JOSE];
2054 if (lws_jws_dup_element(&jwe.jws.map, LJWE_CTXT,
2065 n = lws_gencrypto_bits_to_bytes(jwe.jose.enc_alg->keybits_fixed);
2066 if (lws_jws_randomize_element(context, &jwe.jws.map, LJWE_EKEY,
2074 n = lws_jwe_encrypt(&jwe, lws_concat_temp(temp, temp_len),
2081 n = lws_jwe_render_compact(&jwe, compact, (unsigned int)compact_len);
2090 lws_jwe_destroy(&jwe);
2139 struct lws_jwe jwe;
2143 lws_jwe_init(&jwe, context);
2145 if (lws_jwe_parse_jose(&jwe.jose, complete, (int)strlen(complete),
2152 if (jwe.jose.recipients != 2) {
2154 jwe.jose.recipients);
2160 lws_jwe_destroy(&jwe);