Class: Aws::S3::Encryption::DefaultCipherProvider Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-resources/services/s3/encryption/default_cipher_provider.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ DefaultCipherProvider

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of DefaultCipherProvider.



9
10
11
# File 'lib/aws-sdk-resources/services/s3/encryption/default_cipher_provider.rb', line 9

def initialize(options = {})
  @key_provider = options[:key_provider]
end

Instance Method Details

#decryption_cipher(envelope) ⇒ Cipher

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Given an encryption envelope, returns a decryption cipher.

Returns:

  • (Cipher)

    Given an encryption envelope, returns a decryption cipher.



27
28
29
30
31
32
# File 'lib/aws-sdk-resources/services/s3/encryption/default_cipher_provider.rb', line 27

def decryption_cipher(envelope)
  master_key = @key_provider.key_for(envelope['x-amz-matdesc'])
  key = Utils.decrypt(master_key, decode64(envelope['x-amz-key']))
  iv = decode64(envelope['x-amz-iv'])
  Utils.aes_decryption_cipher(:CBC, key, iv)
end

#encryption_cipherArray<Hash,Cipher>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Creates an returns a new encryption envelope and encryption cipher.

Returns:

  • (Array<Hash,Cipher>)

    Creates an returns a new encryption envelope and encryption cipher.



15
16
17
18
19
20
21
22
23
# File 'lib/aws-sdk-resources/services/s3/encryption/default_cipher_provider.rb', line 15

def encryption_cipher
  cipher = Utils.aes_encryption_cipher(:CBC)
  envelope = {
    'x-amz-key' => encode64(encrypt(envelope_key(cipher))),
    'x-amz-iv' => encode64(envelope_iv(cipher)),
    'x-amz-matdesc' => materials_description,
  }
  [envelope, cipher]
end