Class: CertificateAuthority::Pkcs11KeyMaterial

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from KeyMaterial

from_x509_key_pair, from_x509_public_key

Constructor Details

#initialize(attributes = {}) ⇒ Pkcs11KeyMaterial

Returns a new instance of Pkcs11KeyMaterial.



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

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

Instance Attribute Details

#engineObject

Returns the value of attribute engine.



5
6
7
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 5

def engine
  @engine
end

#openssl_pkcs11_engine_libObject

Returns the value of attribute openssl_pkcs11_engine_lib.



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

def openssl_pkcs11_engine_lib
  @openssl_pkcs11_engine_lib
end

#pinObject

Returns the value of attribute pin.



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

def pin
  @pin
end

#pkcs11_libObject

Returns the value of attribute pkcs11_lib.



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

def pkcs11_lib
  @pkcs11_lib
end

#token_idObject

Returns the value of attribute token_id.



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

def token_id
  @token_id
end

Instance Method Details

#generate_key(modulus_bits = 1024) ⇒ Object



24
25
26
27
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 24

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

#is_in_hardware?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 16

def is_in_hardware?
  true
end

#is_in_memory?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 20

def is_in_memory?
  false
end

#private_keyObject



29
30
31
32
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 29

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

#public_keyObject



34
35
36
37
# File 'lib/certificate_authority/pkcs11_key_material.rb', line 34

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