Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JWKs for pre 2.3 rubies #382

Merged
merged 1 commit into from Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/test.yml
Expand Up @@ -24,10 +24,12 @@ jobs:
- gemfiles/rbnacl.gemfile
experimental: [false]
include:
# - ruby: 2.1
# experimental: true
# - ruby: 2.2
# experimental: true
- ruby: 2.1
gemfile: 'gemfiles/rbnacl.gemfile'
experimental: false
- ruby: 2.2
gemfile: 'gemfiles/rbnacl.gemfile'
experimental: false
- ruby: 2.7
coverage: "true"
gemfile: 'gemfiles/rbnacl.gemfile'
Expand Down
8 changes: 4 additions & 4 deletions lib/jwt/jwk/ec.rb
Expand Up @@ -70,11 +70,11 @@ def keypair_components(ec_keypair)
end

def encode_octets(octets)
::Base64.urlsafe_encode64(octets, padding: false)
::JWT::Base64.url_encode(octets)
end

def encode_open_ssl_bn(key_part)
::Base64.urlsafe_encode64(key_part.to_s(BINARY), padding: false)
::JWT::Base64.url_encode(key_part.to_s(BINARY))
end

class << self
Expand Down Expand Up @@ -136,11 +136,11 @@ def ec_pkey(jwk_crv, jwk_x, jwk_y, jwk_d)
end

def decode_octets(jwk_data)
::Base64.urlsafe_decode64(jwk_data)
::JWT::Base64.url_decode(jwk_data)
end

def decode_open_ssl_bn(jwk_data)
OpenSSL::BN.new(::Base64.urlsafe_decode64(jwk_data), BINARY)
OpenSSL::BN.new(::JWT::Base64.url_decode(jwk_data), BINARY)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/jwt/jwk/rsa.rb
Expand Up @@ -54,7 +54,7 @@ def append_private_parts(the_hash)
end

def encode_open_ssl_bn(key_part)
::Base64.urlsafe_encode64(key_part.to_s(BINARY), padding: false)
::JWT::Base64.url_encode(key_part.to_s(BINARY))
end

class << self
Expand Down Expand Up @@ -107,7 +107,7 @@ def populate_key(rsa_key, rsa_parameters) # rubocop:disable Metrics/CyclomaticCo
def decode_open_ssl_bn(jwk_data)
return nil unless jwk_data

OpenSSL::BN.new(::Base64.urlsafe_decode64(jwk_data), BINARY)
OpenSSL::BN.new(::JWT::Base64.url_decode(jwk_data), BINARY)
end
end
end
Expand Down