File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
lib/openssl/signature_algorithm
spec/openssl/signature_algorithm Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ def verify(*args)
45
45
ACCEPTED_PARAMETERS = [
46
46
{ curve : "prime256v1" , hash_function : "SHA256" } ,
47
47
{ curve : "secp384r1" , hash_function : "SHA384" } ,
48
- { curve : "secp521r1" , hash_function : "SHA512" }
48
+ { curve : "secp521r1" , hash_function : "SHA512" } ,
49
+ { curve : "secp256k1" , hash_function : "SHA256" }
49
50
] . freeze
50
51
51
52
attr_reader :curve , :hash_function
Original file line number Diff line number Diff line change 133
133
end
134
134
end
135
135
136
+ context "secp256k1 curve" do
137
+ let ( :algorithm_parameters ) { { curve : "secp256k1" } }
138
+
139
+ it "picks SHA256" do
140
+ expect ( signer_algorithm . hash_function ) . to eq ( "SHA256" )
141
+ end
142
+
143
+ it "works" do
144
+ # Signer sends verify key to Verifier
145
+ verify_key_string = signing_key . verify_key . serialize
146
+
147
+ # Verifier
148
+ verifier_algorithm . verify_key = OpenSSL ::SignatureAlgorithm ::ECDSA ::VerifyKey . deserialize ( verify_key_string )
149
+ expect ( verifier_algorithm . verify ( signature , to_be_signed ) ) . to be_truthy
150
+ end
151
+ end
152
+
136
153
context "when signer and verifier algorithms are different" do
137
154
let ( :signer_algorithm ) { OpenSSL ::SignatureAlgorithm ::ECDSA . new ( curve : "secp384r1" ) }
138
155
let ( :verifier_algorithm ) { OpenSSL ::SignatureAlgorithm ::ECDSA . new ( curve : "secp521r1" ) }
You can’t perform that action at this time.
0 commit comments