Class: SyrupPay::Jwa::ContentEncryptionKeyGenerator

Inherits:
Object
  • Object
show all
Includes:
RandomKeyGen
Defined in:
lib/jose/jwa/enc/content_encryptionkey_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RandomKeyGen

#randomKey

Constructor Details

#initialize(key_length) ⇒ ContentEncryptionKeyGenerator

Returns a new instance of ContentEncryptionKeyGenerator.



15
16
17
# File 'lib/jose/jwa/enc/content_encryptionkey_generator.rb', line 15

def initialize(key_length)
  @key_length = key_length
end

Instance Attribute Details

#cekObject (readonly)

Returns the value of attribute cek.



13
14
15
# File 'lib/jose/jwa/enc/content_encryptionkey_generator.rb', line 13

def cek
  @cek
end

#key_lengthObject (readonly)

Returns the value of attribute key_length.



13
14
15
# File 'lib/jose/jwa/enc/content_encryptionkey_generator.rb', line 13

def key_length
  @key_length
end

Instance Method Details

#generate_random_keyObject



23
24
25
26
27
28
29
# File 'lib/jose/jwa/enc/content_encryptionkey_generator.rb', line 23

def generate_random_key
  if (@cek.nil?)
    @cek = randomKey(@key_length/2)
  end

  @cek
end

#user_encryption_key=(cek) ⇒ Object



19
20
21
# File 'lib/jose/jwa/enc/content_encryptionkey_generator.rb', line 19

def user_encryption_key=(cek)
  @cek = cek
end