class JWT::JWK::RSA
Constants
- BINARY
- KTY
Attributes
keypair[R]
Public Class Methods
import(jwk_data)
click to toggle source
# File lib/jwt/jwk/rsa.rb, line 38 def self.import(jwk_data) imported_key = OpenSSL::PKey::RSA.new imported_key.set_key(OpenSSL::BN.new(::Base64.urlsafe_decode64(jwk_data[:n]), BINARY), OpenSSL::BN.new(::Base64.urlsafe_decode64(jwk_data[:e]), BINARY), nil) self.new(imported_key) end
new(keypair)
click to toggle source
# File lib/jwt/jwk/rsa.rb, line 17 def initialize(keypair) raise ArgumentError, 'keypair must be of type OpenSSL::PKey::RSA' unless keypair.is_a?(OpenSSL::PKey::RSA) @keypair = keypair end
Public Instance Methods
export()
click to toggle source
# File lib/jwt/jwk/rsa.rb, line 29 def export { kty: KTY, n: ::Base64.urlsafe_encode64(public_key.n.to_s(BINARY), padding: false), e: ::Base64.urlsafe_encode64(public_key.e.to_s(BINARY), padding: false), kid: kid } end
kid()
click to toggle source
# File lib/jwt/jwk/rsa.rb, line 23 def kid sequence = OpenSSL::ASN1::Sequence([OpenSSL::ASN1::Integer.new(public_key.n), OpenSSL::ASN1::Integer.new(public_key.e)]) OpenSSL::Digest::SHA256.hexdigest(sequence.to_der) end