This repository has been archived on 2023-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
2019-09-13 23:20:47 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class EcurveKey < AsymmetricKey
|
2019-09-15 01:38:32 +00:00
|
|
|
ALGO_CLASS = 'Elliptic curve'
|
2019-09-13 23:22:45 +00:00
|
|
|
CURVES = %w[prime256v1 secp384r1].freeze
|
|
|
|
|
2019-09-13 23:20:47 +00:00
|
|
|
###############
|
|
|
|
# Validations #
|
|
|
|
###############
|
|
|
|
|
2019-09-13 23:22:45 +00:00
|
|
|
validates :curve, inclusion: { in: CURVES }
|
2019-09-13 23:20:47 +00:00
|
|
|
|
|
|
|
validates :bits, absence: true
|
2019-09-14 01:29:13 +00:00
|
|
|
|
|
|
|
###########
|
|
|
|
# Methods #
|
|
|
|
###########
|
|
|
|
|
|
|
|
def algo_class
|
2019-09-15 01:38:32 +00:00
|
|
|
ALGO_CLASS
|
2019-09-14 01:29:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def algo_variant
|
|
|
|
curve
|
|
|
|
end
|
2019-09-13 23:20:47 +00:00
|
|
|
end
|