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": "o3IORxSyiATK8O0TlLhl0wDILCN48Mlvx4N1pLcCgLE",
"y": "JUIrPIbCQtGT652jIPpsXIkClWrtojxi80w10fGtCc8",
"d": "3Pz4jerMshoG0V8-6eTheBybaVYR4-I4Lj3V6UMJTnU"
}
{
"kty": "EC",
"crv": "P-256",
"x": "o3IORxSyiATK8O0TlLhl0wDILCN48Mlvx4N1pLcCgLE",
"y": "JUIrPIbCQtGT652jIPpsXIkClWrtojxi80w10fGtCc8"
}
[256-bit ecdsa public key]
md5: f7279e786da2ad52164a8ffd5bd1a37f
sha256: 0269375eb2bac4a4d37ac14850ace73ed5954824882ffc0704f0dc0ee31aad44
[1] TRUE
JWT also specifies a format for encoding AES/HMAC secrets. Such secret keys are simply raw bytes.
[1] b9 d3 12 95 4d 76 dc ab 1e db d5 3f f2 f3 17 25
{"kty":"oct","k":"udMSlU123Kse29U_8vMXJQ"}
[1] b9 d3 12 95 4d 76 dc ab 1e db d5 3f f2 f3 17 25