Class: Mongo::Crypt::DataKeyContext Private

Inherits:
Context
  • Object
show all
Defined in:
lib/mongo/crypt/data_key_context.rb

Overview

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.

A Context object initialized specifically for the purpose of creating a data key in the key management system.

Instance Attribute Summary

Attributes inherited from Context

#ctx_p

Instance Method Summary collapse

Methods inherited from Context

#run_state_machine, #state

Constructor Details

#initialize(mongocrypt, io, master_key_document, key_alt_names, key_material) ⇒ DataKeyContext

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.

Create a new DataKeyContext object

Parameters:

  • mongocrypt (Mongo::Crypt::Handle)

    a Handle that wraps a mongocrypt_t object used to create a new mongocrypt_ctx_t

  • io (Mongo::Crypt::EncryptionIO)

    An object that performs all driver I/O on behalf of libmongocrypt

  • master_key_document (Mongo::Crypt::KMS::MasterKeyDocument)

    The master key document that contains master encryption key parameters.

  • key_alt_names (Array<String> | nil)

    An optional array of strings specifying alternate names for the new data key.

  • :key_material (String | nil)

    Optional 96 bytes to use as custom key material for the data key being created. If :key_material option is given, the custom key material is used for encrypting and decrypting data.



41
42
43
44
45
46
47
# File 'lib/mongo/crypt/data_key_context.rb', line 41

def initialize(mongocrypt, io, master_key_document, key_alt_names, key_material)
  super(mongocrypt, io)
  Binding.ctx_setopt_key_encryption_key(self, master_key_document.to_document)
  set_key_alt_names(key_alt_names) if key_alt_names
  Binding.ctx_setopt_key_material(self, BSON::Binary.new(key_material)) if key_material
  initialize_ctx
end