@@ -20,7 +20,7 @@ class Signature
2020 PublicKey ::ALGO_RSA_SHA2_512 ,
2121 ]
2222
23- attr_reader :sigversion , :namespace , :signature , :reserved , :hashalgorithm
23+ attr_reader :sigversion , :namespace , :signature , :reserved , :hash_algorithm
2424
2525 # Parses a PEM armored SSH signature.
2626 # pem - A PEM encoded SSH signature.
@@ -47,13 +47,13 @@ def self.parse_blob(blob)
4747 new ( **data )
4848 end
4949
50- def initialize ( sigversion :, publickey :, namespace :, reserved :, hashalgorithm :, signature :)
50+ def initialize ( sigversion :, publickey :, namespace :, reserved :, hash_algorithm :, signature :)
5151 if sigversion > MAX_SUPPORTED_VERSION || sigversion < MIN_SUPPORTED_VERSION
5252 raise UnsupportedError , "Signature version is not supported"
5353 end
5454
55- unless SUPPORTED_HASH_ALGORITHMS . has_key? ( hashalgorithm )
56- raise UnsupportedError , "Hash algorithm #{ hashalgorithm } is not supported."
55+ unless SUPPORTED_HASH_ALGORITHMS . has_key? ( hash_algorithm )
56+ raise UnsupportedError , "Hash algorithm #{ hash_algorithm } is not supported."
5757 end
5858
5959 # Spec: empty namespaces are not permitted.
@@ -66,13 +66,13 @@ def initialize(sigversion:, publickey:, namespace:, reserved:, hashalgorithm:, s
6666 @publickey = publickey
6767 @namespace = namespace
6868 @reserved = reserved
69- @hashalgorithm = hashalgorithm
69+ @hash_algorithm = hash_algorithm
7070 @signature = signature
7171 end
7272
7373 def verify ( signed_data )
7474 key = public_key
75- digest_algorithm = SUPPORTED_HASH_ALGORITHMS [ @hashalgorithm ]
75+ digest_algorithm = SUPPORTED_HASH_ALGORITHMS [ @hash_algorithm ]
7676
7777 if key . is_a? ( PublicKey ::RSA )
7878 sig_algo , * = Encoding . decode_signature ( @signature )
@@ -85,14 +85,14 @@ def verify(signed_data)
8585 end
8686 end
8787
88- raise AlgorithmError , "Unsupported digest algorithm #{ @hashalgorithm } " if digest_algorithm . nil?
88+ raise AlgorithmError , "Unsupported digest algorithm #{ @hash_algorithm } " if digest_algorithm . nil?
8989
9090 message_digest = digest_algorithm . digest ( signed_data )
9191 blob =
9292 SIGNATURE_PREAMBLE +
9393 Encoding . encode_string ( @namespace ) +
9494 Encoding . encode_string ( @reserved || "" ) +
95- Encoding . encode_string ( @hashalgorithm ) +
95+ Encoding . encode_string ( @hash_algorithm ) +
9696 Encoding . encode_string ( message_digest )
9797
9898 key . verify ( blob , @signature )
0 commit comments