Lines Matching refs:jwk
42 * These are the entire legal token set for names in jwk.
44 * The first version is used to parse a detached single jwk that don't have any
45 * parent JSON context. The second version is used to parse full jwk objects
144 e->buf = lws_malloc(dec_size, "jwk");
164 e->buf = lws_malloc(dec_size, "jwk");
183 struct lws_jwk *jwk = jps->jwk;
205 if (jps->per_key_cb(jps->jwk, jps->user)) {
214 lws_jwk_destroy(jps->jwk);
222 * Now we saw the whole jwk and know the key type, let'jwk insist
237 !jwk->meta[tok_map[n] & 0xff].buf) ||
239 !jwk->e[tok_map[n] & 0xff].buf))) {
259 if (jwk->kty == LWS_GENCRYPTO_KTY_RSA &&
260 !(((!jwk->e[LWS_GENCRYPTO_RSA_KEYEL_D].buf) &&
261 (!jwk->e[LWS_GENCRYPTO_RSA_KEYEL_P].buf) &&
262 (!jwk->e[LWS_GENCRYPTO_RSA_KEYEL_Q].buf)) ||
263 (jwk->e[LWS_GENCRYPTO_RSA_KEYEL_D].buf &&
264 jwk->e[LWS_GENCRYPTO_RSA_KEYEL_P].buf &&
265 jwk->e[LWS_GENCRYPTO_RSA_KEYEL_Q].buf))
276 if (jwk->kty == LWS_GENCRYPTO_KTY_RSA &&
277 !(((!jwk->e[LWS_GENCRYPTO_RSA_KEYEL_DP].buf) &&
278 (!jwk->e[LWS_GENCRYPTO_RSA_KEYEL_DQ].buf) &&
279 (!jwk->e[LWS_GENCRYPTO_RSA_KEYEL_QI].buf)) ||
280 (jwk->e[LWS_GENCRYPTO_RSA_KEYEL_DP].buf &&
281 jwk->e[LWS_GENCRYPTO_RSA_KEYEL_DQ].buf &&
282 jwk->e[LWS_GENCRYPTO_RSA_KEYEL_QI].buf))
293 if (jwk->kty == LWS_GENCRYPTO_KTY_RSA &&
294 !jwk->e[LWS_GENCRYPTO_RSA_KEYEL_D].buf &&
295 jwk->e[LWS_GENCRYPTO_RSA_KEYEL_DQ].buf) {
301 if ((jwk->kty == LWS_GENCRYPTO_KTY_RSA ||
302 jwk->kty == LWS_GENCRYPTO_KTY_EC) &&
303 jwk->e[LWS_GENCRYPTO_RSA_KEYEL_D].buf)
304 jwk->private_key = 1;
320 * seen. Once kty comes, we confirm it'jwk still possible (ie, it'jwk
321 * not trying to tell us that it'jwk RSA now when we saw a "crv"
329 jwk->kty = LWS_GENCRYPTO_KTY_OCT;
336 jwk->kty = LWS_GENCRYPTO_KTY_RSA;
343 jwk->kty = LWS_GENCRYPTO_KTY_EC;
370 if (_lws_jwk_set_el_jwk(&jwk->meta[idx & 0x7f],
379 if (_lws_jwk_set_el_jwk_b64u(&jwk->e[idx & 0x7f],
383 if (jwk->e[idx & 0x7f].len >
395 if (_lws_jwk_set_el_jwk_b64(&jwk->e[idx & 0x7f],
401 if (_lws_jwk_set_el_jwk(&jwk->e[idx & 0x7f],
410 lwsl_err("%s: jwk elements mismatch\n", __func__);
419 lws_jwk_import(struct lws_jwk *jwk, lws_jwk_key_import_callback cb, void *user,
426 lws_jwk_init_jps(&jps, jwk, cb, user);
436 lws_jwk_destroy(jwk);
440 switch (jwk->kty) {
443 lws_jwk_destroy(jwk);
454 lws_jwk_export(struct lws_jwk *jwk, int flags, char *p, int *len)
469 switch (jwk->kty) {
493 if ((l->meta & 1) && (jwk->meta[l->idx].buf ||
502 l->name, kty_names[jwk->kty]);
508 q = (const char *)jwk->meta[l->idx].buf;
509 q_end = q + jwk->meta[l->idx].len;
553 lws_strnncpy(p, (const char *)jwk->meta[l->idx].buf,
554 jwk->meta[l->idx].len, end - p);
561 if ((!(l->meta & 1)) && jwk->e[l->idx].buf &&
569 if (jwk->kty == LWS_GENCRYPTO_KTY_EC &&
572 (const char *)jwk->e[l->idx].buf,
573 jwk->e[l->idx].len, end - p);
577 (const char *)jwk->e[l->idx].buf,
578 jwk->e[l->idx].len, p, lws_ptr_diff_size_t(end, p) - 4);
599 lws_jwk_load(struct lws_jwk *jwk, const char *filename,
603 char *buf = lws_malloc(buflen, "jwk-load");
613 n = lws_jwk_import(jwk, cb, user, buf, (unsigned int)n);
624 lws_jwk_save(struct lws_jwk *jwk, const char *filename)
627 char *buf = lws_malloc((unsigned int)buflen, "jwk-save");
633 n = lws_jwk_export(jwk, LWSJWKF_EXPORT_PRIVATE, buf, &buflen);