Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into support-ed25518
Browse files Browse the repository at this point in the history
  • Loading branch information
anakinj committed Aug 4, 2024
2 parents 13f12c5 + daaa740 commit c9b05d1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/jwt/eddsa/algo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ module JWT
module EdDSA
# EdDSA algorithm implementation
module Algo
include JWT::JWA::Algorithm
include JWT::JWA::SignatureAlgorithm

register_algorithm("EdDSA")
register_algorithm("ED25519")

class << self
def sign(_algorithm, msg, key)
def sign(_alg, msg, key)
unless key.is_a?(Ed25519::SigningKey)
raise_sign_error!("Key given is a #{key.class} but needs to be a Ed25519::SigningKey")
end

key.sign(msg)
end

def verify(_algorithm, public_key, signing_input, signature)
def verify(_alg, public_key, signing_input, signature)
unless public_key.is_a?(Ed25519::VerifyKey)
raise_verify_error!("Key given is a #{public_key.class} but needs to be a Ed25519::VerifyKey")
end
Expand All @@ -27,6 +27,10 @@ def verify(_algorithm, public_key, signing_input, signature)
rescue Ed25519::VerifyError
false
end

def header(*)
{ "alg" => "EdDSA" }
end
end
end
end
Expand Down

0 comments on commit c9b05d1

Please sign in to comment.