Class: Ccrypto::KeypairConfig

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AlgoConfig

include

Constructor Details

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

Returns a new instance of KeypairConfig.



22
23
24
25
# File 'lib/ccrypto/configs/keypair_config.rb', line 22

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

#provider_configObject

Returns the value of attribute provider_config.



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

def provider_config
  @provider_config
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



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

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



59
60
61
# File 'lib/ccrypto/configs/keypair_config.rb', line 59

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)


31
32
33
# File 'lib/ccrypto/configs/keypair_config.rb', line 31

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

#has_private_key?Boolean

Returns:

  • (Boolean)


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

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)


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

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)


27
28
29
# File 'lib/ccrypto/configs/keypair_config.rb', line 27

def is_default_algo?
  @default
end