Module: EllipticCurve::Ecdsa
- Defined in:
- lib/ecdsa.rb
Class Method Summary collapse
- .sign(message, privateKey, hashfunc = nil) ⇒ Object
- .verify(message, signature, publicKey, hashfunc = nil) ⇒ Object
Class Method Details
.sign(message, privateKey, hashfunc = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ecdsa.rb', line 10 def self.sign(, privateKey, hashfunc=nil) if hashfunc.nil? = Digest::SHA256.digest() else = hashfunc() end signature = privateKey.openSslPrivateKey.dsa_sign_asn1() return Signature.new(signature) end |
.verify(message, signature, publicKey, hashfunc = nil) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/ecdsa.rb', line 21 def self.verify(, signature, publicKey, hashfunc=nil) if hashfunc.nil? = Digest::SHA256.digest() else = hashfunc() end return publicKey.openSslPublicKey.dsa_verify_asn1(, signature.toDer()) end |