Skip to content

Commit

Permalink
chore: update to latest version of openssl_ext
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed Dec 9, 2019
1 parent 6b8209b commit c5cbec2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: jwt
version: 1.1.2
version: 1.2.0

authors:
- Potapov Sergey <[email protected]>

dependencies:
openssl_ext:
github: stakach/openssl_ext
version: ~> 1.1

license: MIT
2 changes: 1 addition & 1 deletion spec/integration/algorithms/rsa_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe JWT do
"FLscCAkdAP9lDgeDGwIDAQAB\n" +
"-----END PUBLIC KEY-----\n"

wrong_key = OpenSSL::RSA.new(1024).to_pem
wrong_key = OpenSSL::PKey::RSA.new(1024).to_pem
payload = {"foo" => "bar"}

algorithms = {
Expand Down
8 changes: 4 additions & 4 deletions src/jwt.cr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module JWT
# public key verification for RSA and ECDSA algorithms
case algorithm
when Algorithm::RS256, Algorithm::RS384, Algorithm::RS512
rsa = OpenSSL::RSA.new(key)
rsa = OpenSSL::PKey::RSA.new(key)
digest = OpenSSL::Digest.new("sha#{algorithm.to_s[2..-1]}")
if !rsa.verify(digest, Base64.decode_string(encoded_signature), verify_data)
raise VerificationError.new("Signature verification failed")
Expand Down Expand Up @@ -99,11 +99,11 @@ module JWT
when Algorithm::HS512
OpenSSL::HMAC.digest(:sha512, key, data)
when Algorithm::RS256
OpenSSL::RSA.new(key).sign(OpenSSL::Digest.new("sha256"), data)
OpenSSL::PKey::RSA.new(key).sign(OpenSSL::Digest.new("sha256"), data)
when Algorithm::RS384
OpenSSL::RSA.new(key).sign(OpenSSL::Digest.new("sha384"), data)
OpenSSL::PKey::RSA.new(key).sign(OpenSSL::Digest.new("sha384"), data)
when Algorithm::RS512
OpenSSL::RSA.new(key).sign(OpenSSL::Digest.new("sha512"), data)
OpenSSL::PKey::RSA.new(key).sign(OpenSSL::Digest.new("sha512"), data)
else raise(UnsupportedAlgorithmError.new("Unsupported algorithm: #{algorithm}"))
end
end
Expand Down

0 comments on commit c5cbec2

Please sign in to comment.