lib/ccrypto/configs/keypair_config.rb in ccrypto-0.1.3 vs lib/ccrypto/configs/keypair_config.rb in ccrypto-0.2.0
- old
+ new
@@ -15,11 +15,11 @@
Algo_Obsolete = :obsolete
Algo_Broken = :broken
attr_reader :default
- attr_accessor :native_config
+ attr_accessor :provider_config
def initialize(status = Algo_Active, default = false)
@algo_status = status
@default = default
end
@@ -62,42 +62,59 @@
end # KeypairConfig
class ECCConfig < KeypairConfig
- def self.name
- "Elliptic Curve (ECC)"
+ def self.algo_name
+ "Elliptic Curve (ECC) (Classical - Signing and Encryption)"
end
- attr_accessor :curve
+ def self.algo_key
+ :ecc
+ end
+
+ attr_reader :curve
def initialize(curve = nil, status = Algo_Active, default = false)
- @algo = :ecc
+ @algo = self.class.algo_key
@curve = curve || :prime256v1
@curve = @curve.to_sym if not @curve.is_a?(Symbol)
super(status, default)
end
+ def param
+ @curve
+ end
+
def to_s
- "#{@curve}"
+ "ECC - #{@curve}"
end
def self.supported_curves(&block)
Provider.instance.provider.algo_instance(*[ECCConfig], &block).supported_curves
end
end # ECCConfig
class RSAConfig < KeypairConfig
- def self.name
- "RSA"
+ def self.algo_name
+ "RSA (Classical - Signing and Encryption)"
end
- attr_accessor :keysize
+ def self.algo_key
+ :rsa
+ end
+
+ attr_reader :keysize
def initialize(keysize = 2048, status = Algo_Active, default = false)
+ @algo = self.class.algo_key
@keysize = keysize
super(status, default)
end
+ def param
+ @keysize
+ end
+
def to_s
"RSA-#{keysize} bits"
end
def self.supported_keysizes(&block)
@@ -105,27 +122,89 @@
end
end # RSAConfig
# ED25519 for data signature
class ED25519Config < KeypairConfig
- def self.name
- "ED25519 (Signing Only)"
+ def self.algo_name
+ "ED25519 (Classical - Signing Only)"
end
+ def self.algo_key
+ :ed25519
+ end
+
def initialize
- algo = :ed25519
+ @algo = self.class.algo_key
super(Algo_Active, true)
end
+
+ def param
+ nil
+ end
end
# X25519 for key exchange
class X25519Config < KeypairConfig
- def self.name
+ def self.algo_name
"X25519 (Data Encipherment only)"
end
+
+ def self.algo_key
+ :x25519
+ end
+
def initialize
- algo = :x25519
+ @algo = self.class.algo_key
super(Algo_Active, true)
+ end
+
+ def param
+ nil
+ end
+ end
+
+ # PQ Crystal Kyber
+ class CrystalKyberConfig < KeypairConfig
+ def self.algo_name
+ "Crystal Kyber (PQC - Signing)"
+ end
+ def self.algo_key
+ :crystal_kyber
+ end
+
+ attr_reader :param
+ def initialize(kyberParam, default = false)
+ @param = kyberParam
+ @algo = self.class.algo_key
+ super(Algo_Active, default)
+ end
+
+ def to_s
+ "PQ Crystal Kyber #{@param}"
+ end
+ end
+
+ # PQ Crystal Dlithium
+ class CrystalDilithiumConfig < KeypairConfig
+ # has unintended consequences during YAML dump and load
+ #def self.name
+ # "PQ Crystal Dilithium Family (for Signing)"
+ #end
+ def self.algo_name
+ "Crystal Dilithium (PQC - Encryption)"
+ end
+ def self.algo_key
+ :crystal_dilithium
+ end
+ attr_reader :param
+ def initialize(param, default = false)
+ @param = param
+ @algo = self.class.algo_key
+ super(Algo_Active, default)
+ end
+
+ def to_s
+ "PQ Crystal Dilithium #{@param}"
end
end
end