Class: Keystores::Jks::EncryptedPrivateKeyInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/keystores/jks/encrypted_private_key_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ EncryptedPrivateKeyInfo

You can pass either an ASN.1 encryptedPrivateKeyInfo object or the encrypted bytes and the encryption algorithm.

Parameters:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :encoded (String)

    The ASN.1 encoded encrypted private key info

  • :algorithm (String)

    The encryption algorithm

  • :encrypted_data (String)

    The encrypted key bytes



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/keystores/jks/encrypted_private_key_info.rb', line 23

def initialize(opts = {})
  # Parses from encoded private key
  if opts.has_key?(:encoded)
    encoded = opts[:encoded]
    @asn1 = OpenSSL::ASN1.decode(encoded)
    @encrypted_data = @asn1.value[1].value
    @algorithm = @asn1.value[0].value[0].value
    @encoded = encoded
  else
    @algorithm = opts[:algorithm]
    @encrypted_data = opts[:encrypted_data]
    @encoded = encode(@algorithm, @encrypted_data)
  end
end

Instance Attribute Details

#algorithmObject

Returns the value of attribute algorithm.



14
15
16
# File 'lib/keystores/jks/encrypted_private_key_info.rb', line 14

def algorithm
  @algorithm
end

#encodedObject

Returns the value of attribute encoded.



14
15
16
# File 'lib/keystores/jks/encrypted_private_key_info.rb', line 14

def encoded
  @encoded
end

#encrypted_dataObject

Returns the value of attribute encrypted_data.



14
15
16
# File 'lib/keystores/jks/encrypted_private_key_info.rb', line 14

def encrypted_data
  @encrypted_data
end