libekmfweb: Check length of JWK EC public key coordinates

RFC 7517 requires that the x and y coordinates of a ECC JSON Web Key
(JWK) are specified in its full size of a coordinate for the curve used.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Ingo Franzki
2021-01-29 10:17:09 +01:00
committed by Jan Höppner
parent faf26220a7
commit bf5ca4367d
2 changed files with 22 additions and 0 deletions
+10
View File
@@ -2254,11 +2254,21 @@ int json_web_key_as_pkey(json_object *jwk, int pkey_type, EVP_PKEY **pkey)
rc = json_object_get_base64url(jwk, "x", x, &len);
if (rc != 0)
goto out;
if (len != prime_len) {
/* RFC 7517: Must be full size of a coordinate */
rc = -EINVAL;
goto out;
}
len = prime_len;
rc = json_object_get_base64url(jwk, "y", y, &len);
if (rc != 0)
goto out;
if (len != prime_len) {
/* RFC 7517: Must be full size of a coordinate */
rc = -EINVAL;
goto out;
}
rc = ecc_pub_key_as_pkey(nid, prime_len, x, y, pkey);
if (rc != 0)