Class: CryptoGost::Create
- Inherits:
-
Object
- Object
- CryptoGost::Create
- Defined in:
- lib/crypto_gost/create.rb
Overview
DigitalSignature
Instance Attribute Summary collapse
-
#create_hash ⇒ Object
readonly
Returns the value of attribute create_hash.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#public_key ⇒ Object
readonly
Returns the value of attribute public_key.
-
#signature_adapter ⇒ Object
readonly
Returns the value of attribute signature_adapter.
Instance Method Summary collapse
- #call(private_key) ⇒ Object
-
#initialize(message, group, signature_adapter: Signature, create_hash: Stribog::CreateHash) ⇒ Create
constructor
A new instance of Create.
Constructor Details
#initialize(message, group, signature_adapter: Signature, create_hash: Stribog::CreateHash) ⇒ Create
Returns a new instance of Create.
11 12 13 14 15 16 17 |
# File 'lib/crypto_gost/create.rb', line 11 def initialize(, group, signature_adapter: Signature, create_hash: Stribog::CreateHash) @signature_adapter = signature_adapter @create_hash = create_hash @message = @group = group end |
Instance Attribute Details
#create_hash ⇒ Object (readonly)
Returns the value of attribute create_hash.
9 10 11 |
# File 'lib/crypto_gost/create.rb', line 9 def create_hash @create_hash end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
9 10 11 |
# File 'lib/crypto_gost/create.rb', line 9 def group @group end |
#public_key ⇒ Object (readonly)
Returns the value of attribute public_key.
9 10 11 |
# File 'lib/crypto_gost/create.rb', line 9 def public_key @public_key end |
#signature_adapter ⇒ Object (readonly)
Returns the value of attribute signature_adapter.
9 10 11 |
# File 'lib/crypto_gost/create.rb', line 9 def signature_adapter @signature_adapter end |
Instance Method Details
#call(private_key) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/crypto_gost/create.rb', line 19 def call(private_key) @private_key = private_key loop do rand_val = SecureRandom.random_number(1..group.order) r = r_func(rand_val) s = s_func(rand_val, private_key) break new_signature(r: r, s: s) if !r.zero? || !s.zero? end end |