/third_party/libwebsockets/lib/jose/jwe/enc/ |
H A D | aescbc.c | 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 in lws_jwe_encrypt_cbc_hs() [all...] |
H A D | aeskw.c | 47 if (jwe->jws.jwk->kty != LWS_GENCRYPTO_KTY_OCT) { in lws_jwe_encrypt_aeskw_cbc_hs() 48 lwsl_err("%s: unexpected kty %d\n", __func__, jwe->jws.jwk->kty); in lws_jwe_encrypt_aeskw_cbc_hs() 55 if (lws_jws_encode_b64_element(&jwe->jws.map_b64, LJWE_JOSE, in lws_jwe_encrypt_aeskw_cbc_hs() 57 jwe->jws.map.buf[LJWE_JOSE], in lws_jwe_encrypt_aeskw_cbc_hs() 58 jwe->jws.map.len[LJWE_JOSE])) in lws_jwe_encrypt_aeskw_cbc_hs() 63 if (lws_jws_alloc_element(&jwe->jws.map, LJWE_ATAG, temp + (ot - *temp_len), in lws_jwe_encrypt_aeskw_cbc_hs() 67 if (lws_jws_alloc_element(&jwe->jws.map, LJWE_IV, temp + (ot - *temp_len), in lws_jwe_encrypt_aeskw_cbc_hs() 75 n = lws_jwe_encrypt_cbc_hs(jwe, (uint8_t *)jwe->jws.map.buf[LJWE_EKEY], in lws_jwe_encrypt_aeskw_cbc_hs() 76 (uint8_t *)jwe->jws.map_b64.buf[LJWE_JOSE], in lws_jwe_encrypt_aeskw_cbc_hs() 77 (int)jwe->jws in lws_jwe_encrypt_aeskw_cbc_hs() [all...] |
H A D | aesgcm.c | 64 if (jwe->jws.map.len[LJWE_ATAG] != LWS_AESGCM_TAG) { in lws_jwe_encrypt_gcm() 66 __func__, jwe->jws.map.len[LJWE_ATAG]); in lws_jwe_encrypt_gcm() 70 if (jwe->jws.map.len[LJWE_IV] != LWS_AESGCM_IV) { /* MUST be 96-bit */ in lws_jwe_encrypt_gcm() 72 jwe->jws.map.len[LJWE_IV]); in lws_jwe_encrypt_gcm() 90 (uint8_t *)jwe->jws.map.buf[LJWE_IV], in lws_jwe_encrypt_gcm() 91 (uint8_t *)jwe->jws.map.buf[LJWE_ATAG], &ivs, in lws_jwe_encrypt_gcm() 99 n = lws_genaes_crypt(&aesctx, (uint8_t *)jwe->jws.map.buf[LJWE_CTXT], in lws_jwe_encrypt_gcm() 100 jwe->jws.map.len[LJWE_CTXT], in lws_jwe_encrypt_gcm() 101 (uint8_t *)jwe->jws.map.buf[LJWE_CTXT], in lws_jwe_encrypt_gcm() 102 (uint8_t *)jwe->jws in lws_jwe_encrypt_gcm() [all...] |
/third_party/libwebsockets/lib/jose/jwe/ |
H A D | jwe-rsa-aescbc.c | 31 * - jwe->jws.map LJWE_JOSE contains the ASCII JOSE header 32 * - jwe->jws.map LJWE_EKEY contains cek of enc_alg hmac length 33 * - jwe->jws.map LJWE_CTXT contains the plaintext 37 * - jwe->jws.map LJWE_ATAG contains the tag 38 * - jwe->jws.map LJWE_IV contains the new random IV that was used 39 * - jwe->jws.map LJWE_EKEY contains the encrypted CEK 40 * - jwe->jws.map LJWE_CTXT contains the ciphertext 54 if (jwe->jws.jwk->kty != LWS_GENCRYPTO_KTY_RSA) { in lws_jwe_encrypt_rsa_aes_cbc_hs() 55 lwsl_err("%s: unexpected kty %d\n", __func__, jwe->jws.jwk->kty); in lws_jwe_encrypt_rsa_aes_cbc_hs() 66 if (lws_jws_encode_b64_element(&jwe->jws in lws_jwe_encrypt_rsa_aes_cbc_hs() [all...] |
H A D | jwe-rsa-aesgcm.c | 38 if (jwe->jws.jwk->kty != LWS_GENCRYPTO_KTY_RSA) { in lws_jwe_encrypt_rsa_aes_gcm() 39 lwsl_err("%s: wrong kty %d\n", __func__, jwe->jws.jwk->kty); in lws_jwe_encrypt_rsa_aes_gcm() 46 if (lws_jws_randomize_element(jwe->jws.context, &jwe->jws.map, LJWE_IV, in lws_jwe_encrypt_rsa_aes_gcm() 51 if (lws_jws_alloc_element(&jwe->jws.map, LJWE_ATAG, in lws_jwe_encrypt_rsa_aes_gcm() 58 if (lws_jws_encode_b64_element(&jwe->jws.map_b64, LJWE_JOSE, in lws_jwe_encrypt_rsa_aes_gcm() 60 jwe->jws.map.buf[LJWE_JOSE], in lws_jwe_encrypt_rsa_aes_gcm() 61 jwe->jws.map.len[LJWE_JOSE])) in lws_jwe_encrypt_rsa_aes_gcm() 70 if (lws_get_random(jwe->jws.context, jwe->cek, (unsigned int)ekbytes) != in lws_jwe_encrypt_rsa_aes_gcm() 78 if (lws_jws_dup_element(&jwe->jws in lws_jwe_encrypt_rsa_aes_gcm() [all...] |
H A D | jwe-ecdh-es-aeskw.c | 187 * - The jwe->jws.jwk is the PEER - the encryption consumer's - public key. 211 if (jwe->jws.jwk->kty != LWS_GENCRYPTO_KTY_EC) { in lws_jwe_encrypt_ecdh() 212 lwsl_err("%s: unexpected kty %d\n", __func__, jwe->jws.jwk->kty); in lws_jwe_encrypt_ecdh() 222 if (lws_genecdh_create(&ecctx, jwe->jws.context, NULL)) in lws_jwe_encrypt_ecdh() 227 jwe->jws.jwk->e[LWS_GENCRYPTO_EC_KEYEL_CRV].buf, in lws_jwe_encrypt_ecdh() 232 if (lws_genecdh_set_key(&ecctx, jwe->jws.jwk->e, LDHS_THEIRS)) { in lws_jwe_encrypt_ecdh() 296 if (lws_get_random(jwe->jws.context, cek, (unsigned int)enc_hlen) != in lws_jwe_encrypt_ecdh() 317 (void *)jwe->jws.map.buf[LJWE_EKEY], in lws_jwe_encrypt_ecdh() 329 jwe->jws.map.len[LJWE_EKEY] = (unsigned int)enc_hlen + 8; in lws_jwe_encrypt_ecdh() 338 jwe->jws in lws_jwe_encrypt_ecdh() [all...] |
H A D | jwe.c | 52 struct lws_jws *jws; member 102 * the jws signature is actually over the b64 content not the plaintext, in lws_jwe_json_cb() 106 if (!args->jws->map_b64.buf[m]) { in lws_jwe_json_cb() 107 args->jws->map_b64.buf[m] = args->temp; in lws_jwe_json_cb() 108 args->jws->map_b64.len[m] = 0; in lws_jwe_json_cb() 114 args->jws->map_b64.len[m] += ctx->npos; in lws_jwe_json_cb() 117 args->jws->map.buf[m] = args->temp; in lws_jwe_json_cb() 120 (const char *)args->jws->map_b64.buf[m], in lws_jwe_json_cb() 121 (int)args->jws->map_b64.len[m], in lws_jwe_json_cb() 130 args->jws in lws_jwe_json_cb() 553 struct lws_jws jws; lws_jwe_create_packet() local [all...] |
/third_party/libwebsockets/minimal-examples/crypto/minimal-crypto-jws/ |
H A D | main.c | 2 * lws-crypto-jws 28 struct lws_jws jws; in main() local 50 lws_jws_init(&jws, &jwk, context); in main() 57 lwsl_err("format: -s \"<jws cipher alg>\", eg, " in main() 65 if (lws_jws_alloc_element(&jws.map, LJWS_JOSE, in main() 72 jws.map.len[LJWS_JOSE] = (uint32_t) in main() 73 lws_snprintf((char *)jws.map.buf[LJWS_JOSE], in main() 103 jws.map.buf[LJWS_PYLD] = in; in main() 104 jws.map.len[LJWS_PYLD] = (unsigned int)n; in main() 106 if (lws_jws_encode_b64_element(&jws in main() [all...] |
/third_party/libwebsockets/minimal-examples/api-tests/api-test-jose/ |
H A D | jws.c | 2 * lws-api-test-jose - RFC7515 jws tests 124 struct lws_jws jws; in test_jws_HS256() local 128 lws_jws_init(&jws, &jwk, context); in test_jws_HS256() 207 lws_jws_destroy(&jws); in test_jws_HS256() 221 lws_jws_destroy(&jws); in test_jws_HS256() 281 struct lws_jws jws; in test_jws_RS256() local 286 lws_jws_init(&jws, &jwk, context); in test_jws_RS256() 318 &jws.map_b64) != 3) { in test_jws_RS256() 332 if (lws_jws_b64_compact_map(in, l, &jws.map_b64) != 3) { in test_jws_RS256() 338 n = lws_jws_sign_from_b64(&jose, &jws, in test_jws_RS256() 416 struct lws_jws jws; test_jws_ES256() local 578 struct lws_jws jws; test_jws_ES512() local [all...] |
H A D | jwe.c | 84 /* converts a compact serialization to jws b64 + decoded maps */ in test_jwe_a1() 86 &jwe.jws.map, &jwe.jws.map_b64, temp, in test_jwe_a1() 101 if (jwe.jws.map.len[LJWE_CTXT] < strlen(ex_a1_ptext) || in test_jwe_a1() 102 lws_timingsafe_bcmp(jwe.jws.map.buf[LJWE_CTXT], ex_a1_ptext, in test_jwe_a1() 106 lwsl_hexdump_notice(jwe.jws.map.buf[LJWE_CTXT], in test_jwe_a1() 107 jwe.jws.map.len[LJWE_CTXT]); in test_jwe_a1() 136 jwe.jws.map.buf[LJWS_JOSE] = temp; in test_jwe_a1() 137 jwe.jws.map.len[LJWS_JOSE] = (uint32_t)lws_snprintf(temp, (unsigned int)temp_len, in test_jwe_a1() 139 temp_len -= (int)jwe.jws in test_jwe_a1() [all...] |
/third_party/libwebsockets/lib/jose/jws/ |
H A D | jws.c | 26 #include "private-lib-jose-jws.h" 57 struct lws_jws *jws; member 104 * the jws signature is actually over the b64 content not the plaintext, in lws_jws_json_cb() 108 if (!args->jws->map_b64.buf[m]) { in lws_jws_json_cb() 109 args->jws->map_b64.buf[m] = args->temp; in lws_jws_json_cb() 110 args->jws->map_b64.len[m] = 0; in lws_jws_json_cb() 116 args->jws->map_b64.len[m] += ctx->npos; in lws_jws_json_cb() 119 args->jws->map.buf[m] = args->temp; in lws_jws_json_cb() 122 (const char *)args->jws->map_b64.buf[m], in lws_jws_json_cb() 123 (int)args->jws in lws_jws_json_cb() 139 lws_jws_json_parse(struct lws_jws *jws, const uint8_t *buf, int len, char *temp, int *temp_len) lws_jws_json_parse() argument 164 lws_jws_init(struct lws_jws *jws, struct lws_jwk *jwk, struct lws_context *context) lws_jws_init() argument 185 lws_jws_destroy(struct lws_jws *jws) lws_jws_destroy() argument 725 lws_jws_sig_confirm_json(const char *in, size_t len, struct lws_jws *jws, struct lws_jwk *jwk, struct lws_context *context, char *temp, int *temp_len) lws_jws_sig_confirm_json() argument 741 lws_jws_sign_from_b64(struct lws_jose *jose, struct lws_jws *jws, char *b64_sig, size_t sig_len) lws_jws_sign_from_b64() argument 892 lws_jws_write_flattened_json(struct lws_jws *jws, char *flattened, size_t len) lws_jws_write_flattened_json() argument 927 lws_jws_write_compact(struct lws_jws *jws, char *compact, size_t len) lws_jws_write_compact() argument 961 struct lws_jws jws; lws_jwt_signed_validate() local 1047 struct lws_jws jws; lws_jwt_vsign_via_info() local [all...] |
/third_party/libwebsockets/minimal-examples/crypto/minimal-crypto-jwe/ |
H A D | main.c | 137 if (lws_jws_alloc_element(&jwe.jws.map, LJWS_JOSE, in main() 145 jwe.jws.map.len[LJWS_JOSE] = (uint32_t)lws_snprintf( in main() 146 (char *)jwe.jws.map.buf[LJWS_JOSE], (unsigned int)temp_len, in main() 181 jwe.jws.map.buf[LJWE_CTXT] = in; in main() 182 jwe.jws.map.len[LJWE_CTXT] = (uint32_t)n; in main() 190 if (lws_jws_randomize_element(context, &jwe.jws.map, LJWE_EKEY, in main() 244 * held in jws in main() 246 if (lws_jws_compact_decode(in, n, &jwe.jws.map, in main() 247 &jwe.jws.map_b64, in main() 257 * (information on the ciphers) and the jws (plaintex in main() [all...] |
/third_party/libwebsockets/include/libwebsockets/ |
H A D | lws-jws.h | 25 /*! \defgroup jws JSON Web Signature 74 /* jws EC signatures do not have ASN.1 in them, meaning they're incompatible 79 * lws_jws_init() - initialize a jws for use 81 * \param jws: pointer to the jws to initialize 82 * \param jwk: the jwk to use with this jws 86 lws_jws_init(struct lws_jws *jws, struct lws_jwk *jwk, 90 * lws_jws_destroy() - scrub a jws 92 * \param jws: pointer to the jws t [all...] |
H A D | lws-jwe.h | 47 struct lws_jws jws; member 93 * \param jws: jws / jwe context... .map and .map_b64 must be filled already 95 * This is a high level JWE decrypt api that takes a jws with the maps 97 * plaintext in jws.map.buf[LJWE_CTXT] and its length in jws.map.len[LJWE_CTXT]. 99 * In the jws, the following fields must have been set by the caller 119 * \param jws: the JWE elements, pointer to jwk etc
|
/third_party/libwebsockets/plugins/acme-client/ |
H A D | protocol_lws_acme_client.c | 214 struct lws_jws jws; in jws_create_packet() local 217 lws_jws_init(&jws, &jwe->jwk, context); in jws_create_packet() 264 jws.map_b64.buf[LJWS_JOSE] = p1; in jws_create_packet() 270 jws.map_b64.len[LJWS_JOSE] = (uint32_t)n; in jws_create_packet() 274 jws.map_b64.buf[LJWS_PYLD] = p1; in jws_create_packet() 280 jws.map_b64.len[LJWS_PYLD] = (uint32_t)n; in jws_create_packet() 289 n = lws_jws_sign_from_b64(&jwe->jose, &jws, p1, lws_ptr_diff_size_t(end1, p1)); in jws_create_packet() 295 jws.map_b64.buf[LJWS_SIG] = p1; in jws_create_packet() 296 jws.map_b64.len[LJWS_SIG] = (uint32_t)n; in jws_create_packet() 306 lws_jws_destroy(&jws); in jws_create_packet() [all...] |
/third_party/libwebsockets/include/ |
H A D | libwebsockets.h | 671 #include <libwebsockets/lws-jws.h>
|