JSON Web Keys (JWK) is a format specified in RFC7517 for storing RSA/EC/AES keys in a JSON based format. It can be used to import/export such keys in the browser using the new W3C WebCryptoAPI.
The jose
package makes it easy to read/write such keys
in R for use with JWT or any other functionality from the
openssl
package.
Linking to: OpenSSL 3.0.13 30 Jan 2024
{
"kty": "EC",
"crv": "P-256",
"x": "0k4G_wwYnYCGOgm_5nRVh02w2VNijr9cRmPmxUy110k",
"y": "nqbGHoE-tZ1l7D6ePvdW4pan8DfBRWcop9Fo0geKvfQ",
"d": "eRh0mvRYyv5AL_dnH-JjTAEqaMlPAPoqVCOd-J2tZss"
}
{
"kty": "EC",
"crv": "P-256",
"x": "0k4G_wwYnYCGOgm_5nRVh02w2VNijr9cRmPmxUy110k",
"y": "nqbGHoE-tZ1l7D6ePvdW4pan8DfBRWcop9Fo0geKvfQ"
}
[256-bit ecdsa public key]
md5: d0e44db83b391ff11f6576b660c2fa49
sha256: 9643e292ce9129bb255af3e3b4263365b645d17c0760247def919c86cc72cd92
[1] TRUE
JWT also specifies a format for encoding AES/HMAC secrets. Such secret keys are simply raw bytes.
[1] 0b 92 02 03 15 00 22 9b 2b 38 e1 d7 69 50 2d e0
{"kty":"oct","k":"C5ICAxUAIpsrOOHXaVAt4A"}
[1] 0b 92 02 03 15 00 22 9b 2b 38 e1 d7 69 50 2d e0