Class: CertificateAuthority::Pkcs11KeyMaterial

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Serialization, ActiveModel::Validations, KeyMaterial
Defined in:
lib/certificate_authority/pkcs11_key_material.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Pkcs11KeyMaterial

Returns a new instance of Pkcs11KeyMaterial.



13
14
15
16
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 13

def initialize(attributes = {})
  @attributes = attributes
  initialize_engine
end

Instance Attribute Details

#engineObject

Returns the value of attribute engine.



7
8
9
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 7

def engine
  @engine
end

#openssl_pkcs11_engine_libObject

Returns the value of attribute openssl_pkcs11_engine_lib.



10
11
12
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 10

def openssl_pkcs11_engine_lib
  @openssl_pkcs11_engine_lib
end

#pinObject

Returns the value of attribute pin.



11
12
13
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 11

def pin
  @pin
end

#pkcs11_libObject

Returns the value of attribute pkcs11_lib.



9
10
11
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 9

def pkcs11_lib
  @pkcs11_lib
end

#token_idObject

Returns the value of attribute token_id.



8
9
10
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 8

def token_id
  @token_id
end

Instance Method Details

#generate_key(modulus_bits = 1024) ⇒ Object



26
27
28
29
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 26

def generate_key(modulus_bits=1024)
  puts "Key generation is not currently supported in hardware"
  nil
end

#is_in_hardware?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 18

def is_in_hardware?
  true
end

#is_in_memory?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 22

def is_in_memory?
  false
end

#private_keyObject



31
32
33
34
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 31

def private_key
  initialize_engine
  self.engine.load_private_key(self.token_id)
end

#public_keyObject



36
37
38
39
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 36

def public_key
  initialize_engine
  self.engine.load_public_key(self.token_id)
end