Class: Ccrypto::KeypairConfig

Inherits:
Object
  • Object
show all
Includes:
AlgoConfig
Defined in:
lib/ccrypto/configs/keypair_config.rb

Direct Known Subclasses

ECCConfig, ED25519Config, RSAConfig, X25519Config

Constant Summary collapse

Algo_Active =
:active
Algo_NotRecommended =
:not_recommended
Algo_Obsolete =
:obsolete
Algo_Broken =
:broken

Instance Attribute Summary collapse

Attributes included from AlgoConfig

#provider_config

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AlgoConfig

include, #provider_info

Constructor Details

#initialize(status = Algo_Active, default = false) ⇒ KeypairConfig

Returns a new instance of KeypairConfig.



20
21
22
23
# File 'lib/ccrypto/configs/keypair_config.rb', line 20

def initialize(status = Algo_Active, default = false)
  @algo_status = status
  @default = default
end

Instance Attribute Details

#algoObject

Returns the value of attribute algo.



8
9
10
# File 'lib/ccrypto/configs/keypair_config.rb', line 8

def algo
  @algo
end

#algo_statusObject (readonly)

Returns the value of attribute algo_status.



11
12
13
# File 'lib/ccrypto/configs/keypair_config.rb', line 11

def algo_status
  @algo_status
end

#defaultObject (readonly)

Returns the value of attribute default.



18
19
20
# File 'lib/ccrypto/configs/keypair_config.rb', line 18

def default
  @default
end

#keypairObject

Returns the value of attribute keypair.



9
10
11
# File 'lib/ccrypto/configs/keypair_config.rb', line 9

def keypair
  @keypair
end

#private_keyObject

Returns the value of attribute private_key.



9
10
11
# File 'lib/ccrypto/configs/keypair_config.rb', line 9

def private_key
  @private_key
end

#public_keyObject

Returns the value of attribute public_key.



9
10
11
# File 'lib/ccrypto/configs/keypair_config.rb', line 9

def public_key
  @public_key
end

Class Method Details

.keypair_purposesObject



49
50
51
52
53
54
55
# File 'lib/ccrypto/configs/keypair_config.rb', line 49

def self.keypair_purposes
  {
    signing: "Keypair for signing and digital signature operation",
    cipher: "Keypair for data encryption operation",
    sign_and_encrypt: "Keypair for both signing and data encryption operation"
  }
end

.supported_keypair_config(purpose = :signing, &block) ⇒ Object



57
58
59
# File 'lib/ccrypto/configs/keypair_config.rb', line 57

def self.supported_keypair_config(purpose = :signing, &block)
  Provider.instance.provider.supported_keypair_config(purpose, &block)
end

Instance Method Details

#has_keypair?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/ccrypto/configs/keypair_config.rb', line 29

def has_keypair?
  (not @keypair.nil?) or not (@privateKey.nil? and @publicKey.nil?)
end

#has_private_key?Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
39
# File 'lib/ccrypto/configs/keypair_config.rb', line 33

def has_private_key?
  if has_keypair?
    not @keypair.private_key.nil?
  else
    not @private_key.nil?
  end
end

#has_public_key?Boolean

Returns:

  • (Boolean)


41
42
43
44
45
46
47
# File 'lib/ccrypto/configs/keypair_config.rb', line 41

def has_public_key?
  if has_keypair?
    not @keypair.public_key.nil?
  else
    not @public_key.nil?
  end
end

#is_default_algo?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/ccrypto/configs/keypair_config.rb', line 25

def is_default_algo?
  @default
end