Skip to content

Commit

Permalink
Fix EC (Elliptic-Curve) encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and sarroutbi committed Feb 15, 2024
1 parent 76924de commit 92e8ef1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/jwe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lib/openssl/ecdhes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 92e8ef1

Please sign in to comment.