From 92e8ef1e8d3a00f400afb31bb89586b3e6ccf8e2 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 7 Mar 2022 11:10:41 -0500 Subject: [PATCH] Fix EC (Elliptic-Curve) encryption --- lib/jwe.c | 4 ++-- lib/openssl/ecdhes.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/jwe.c b/lib/jwe.c index 516245bd..26fa4fa7 100644 --- a/lib/jwe.c +++ b/lib/jwe.c @@ -147,8 +147,8 @@ find_alg(jose_cfg_t *cfg, json_t *jwe, json_t *rcp, const json_t *hdr, alg = jose_hook_alg_find(JOSE_HOOK_ALG_KIND_WRAP, name); if (alg) { - h = json_object_get(rcp, "header"); - if (!h && json_object_set_new(rcp, "header", h = json_object()) < 0) + h = json_object_get(rcp, "protected"); + if (!h && json_object_set_new(rcp, "protected", h = json_object()) < 0) return NULL; if (json_object_set_new(h, "alg", json_string(alg->name)) < 0) diff --git a/lib/openssl/ecdhes.c b/lib/openssl/ecdhes.c index c32ddba0..8509d5f8 100644 --- a/lib/openssl/ecdhes.c +++ b/lib/openssl/ecdhes.c @@ -357,8 +357,8 @@ alg_wrap_wrp(const jose_hook_alg_t *alg, jose_cfg_t *cfg, json_t *jwe, if (!hdr) return false; - h = json_object_get(rcp, "header"); - if (!h && json_object_set_new(rcp, "header", h = json_object()) == -1) + h = json_object_get(rcp, "protected"); + if (!h && json_object_set_new(rcp, "protected", h = json_object()) == -1) return false; epk = json_pack("{s:s,s:O}", "kty", "EC", "crv", @@ -401,7 +401,7 @@ alg_wrap_wrp(const jose_hook_alg_t *alg, jose_cfg_t *cfg, json_t *jwe, if (json_object_update(cek, der) < 0) return false; - return add_entity(jwe, rcp, "recipients", "header", "encrypted_key", NULL); + return add_entity(jwe, rcp, "recipients", "protected", "header", "encrypted_key", NULL); } static bool