struct

Authly::JWKS::PublicKey

Inherits Struct < Value < Object

A public key read from a PEM PUBLIC KEY (SubjectPublicKeyInfo) or RSA PUBLIC KEY (PKCS#1). Private keys are refused outright.

Constants

CURVES = {Bytes[42, 134, 72, 206, 61, 3, 1, 7] => {"P-256", 32}, Bytes[43, 129, 4, 0, 34] => {"P-384", 48}, Bytes[43, 129, 4, 0, 35] => {"P-521", 66}}
EC_OID = Bytes[42, 134, 72, 206, 61, 2, 1]
PEM_BLOCK = /-----BEGIN ([A-Z ]+)-----(.+?)-----END \1-----/m
RSA_OID = Bytes[42, 134, 72, 134, 247, 13, 1, 1, 1]

Constructors

new(members : Hash(String, String))
Source
parse(pem : String) : PublicKey
Source

Instance methods

to_jwk(algorithm : String) : Hash(String, String)

The key must be of the kind the algorithm signs with: RS* an RSA key, ES256/384/512 an EC key on P-256/P-384/P-521. Publishing a key under an algorithm it cannot verify would mislead clients. kid is the RFC 7638 thumbprint, so it follows the key.

Source