Class: OpenSSL::SignatureAlgorithm::ECDSA

Inherits:
Base
  • Object
show all
Defined in:
lib/openssl/signature_algorithm/ecdsa.rb

Defined Under Namespace

Classes: SigningKey, VerifyKey

Constant Summary collapse

BYTE_LENGTH =
8
ACCEPTED_PARAMETERS =
[
  { curve: "prime256v1", hash_function: "SHA256" },
  { curve: "secp384r1", hash_function: "SHA384" },
  { curve: "secp521r1", hash_function: "SHA512" },
  { curve: "secp256k1", hash_function: "SHA256" }
].freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#signing_key, #verify_key

Instance Method Summary collapse

Methods inherited from Base

#sign, #verify

Constructor Details

#initialize(curve: nil, hash_function: nil) ⇒ ECDSA

Returns a new instance of ECDSA.



69
70
71
# File 'lib/openssl/signature_algorithm/ecdsa.rb', line 69

def initialize(curve: nil, hash_function: nil)
  @curve, @hash_function = pick_parameters(curve, hash_function)
end

Instance Attribute Details

#curveObject (readonly)

Returns the value of attribute curve.



67
68
69
# File 'lib/openssl/signature_algorithm/ecdsa.rb', line 67

def curve
  @curve
end

#hash_functionObject (readonly)

Returns the value of attribute hash_function.



67
68
69
# File 'lib/openssl/signature_algorithm/ecdsa.rb', line 67

def hash_function
  @hash_function
end

Instance Method Details

#compatible_verify_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/openssl/signature_algorithm/ecdsa.rb', line 77

def compatible_verify_key?(key)
  super && key.respond_to?(:group) && key.group.curve_name == curve
end

#generate_signing_keyObject



73
74
75
# File 'lib/openssl/signature_algorithm/ecdsa.rb', line 73

def generate_signing_key
  @signing_key = SigningKey.new(curve)
end