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": "VrrkLu5GZsfqALTuLVXovBVOeKoiOaNbtOqZEwveg2U",
"y": "7WR6wQFsGngrlhYhmMldJOxZc9obXJsdzWQe6MBHTls",
"d": "Z7Z_7xUJj_GWMYXcPEzcDm2nlMDTm49UScLksn3gyM4"
}
{
"kty": "EC",
"crv": "P-256",
"x": "VrrkLu5GZsfqALTuLVXovBVOeKoiOaNbtOqZEwveg2U",
"y": "7WR6wQFsGngrlhYhmMldJOxZc9obXJsdzWQe6MBHTls"
}
[256-bit ecdsa public key]
md5: 512fb553be3149467d0b91b276e8c89d
sha256: 6a3ec63690afa7c552561fec3f6de65458f97b4135020b1bb4381a6dcbd229e2
[1] TRUE
JWT also specifies a format for encoding AES/HMAC secrets. Such secret keys are simply raw bytes.
[1] ca 10 c4 e1 3c bb 86 f1 5a eb d1 2e ee 66 d1 fe
{"kty":"oct","k":"yhDE4Ty7hvFa69Eu7mbR_g"}
[1] ca 10 c4 e1 3c bb 86 f1 5a eb d1 2e ee 66 d1 fe