Class: CryptoGost::Signature
- Inherits:
-
Object
- Object
- CryptoGost::Signature
- Defined in:
- lib/crypto_gost/signature.rb
Overview
DigitalSignature
Instance Attribute Summary collapse
-
#r ⇒ Object
readonly
Returns the value of attribute r.
-
#s ⇒ Object
readonly
Returns the value of attribute s.
Class Method Summary collapse
Instance Method Summary collapse
- #encode ⇒ Object
-
#initialize(r:, s:) ⇒ Signature
constructor
A new instance of Signature.
Constructor Details
#initialize(r:, s:) ⇒ Signature
Returns a new instance of Signature.
19 20 21 22 |
# File 'lib/crypto_gost/signature.rb', line 19 def initialize(r:, s:) @r = r @s = s end |
Instance Attribute Details
#r ⇒ Object (readonly)
Returns the value of attribute r.
8 9 10 |
# File 'lib/crypto_gost/signature.rb', line 8 def r @r end |
#s ⇒ Object (readonly)
Returns the value of attribute s.
8 9 10 |
# File 'lib/crypto_gost/signature.rb', line 8 def s @s end |
Class Method Details
.decode(sign) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/crypto_gost/signature.rb', line 11 def decode(sign) asn1 = OpenSSL::ASN1.decode(sign) r = asn1.value[0].value.to_i s = asn1.value[1].value.to_i new(r, s) end |
Instance Method Details
#encode ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/crypto_gost/signature.rb', line 24 def encode asn1 = OpenSSL::ASN1::Sequence.new [ OpenSSL::ASN1::Integer.new(r), OpenSSL::ASN1::Integer.new(s), ] asn1.to_der end |