Class: Mongo::Crypt::ExplicitEncryptionContext Private

Inherits:
Context
  • Object
show all
Defined in:
lib/mongo/crypt/explicit_encryption_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 for explicit encryption

Direct Known Subclasses

ExplicitEncryptionExpressionContext

Instance Attribute Summary

Attributes inherited from Context

#ctx_p

Instance Method Summary collapse

Methods inherited from Context

#bson_mode, #run_state_machine, #state

Constructor Details

#initialize(mongocrypt, io, doc, options = {}) ⇒ ExplicitEncryptionContext

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.

Note:

The Range algorithm is experimental only. It is not intended for

Note:

The "substring" query type is unstable and subject to backwards

Create a new ExplicitEncryptionContext object

public use. breaking changes.

Parameters:

  • mongocrypt (Mongo::Crypt::Handle)

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

  • io (ClientEncryption::IO)

    A instance of the IO class that implements driver I/O methods required to run the state machine

  • doc (BSON::Document)

    A document to encrypt

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

Options Hash (options):

  • :key_id (BSON::Binary)

    A BSON::Binary object of type :uuid representing the UUID of the data key to use for encryption.

  • :key_alt_name (String)

    The alternate name of the data key that will be used to encrypt the value.

  • :algorithm (String)

    The algorithm used to encrypt the value. Valid algorithms are "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic", "AEAD_AES_256_CBC_HMAC_SHA_512-Random", "Indexed", "Unindexed", "Range", "String".

  • :contention_factor (Integer | nil)

    Contention factor to be applied if encryption algorithm is set to "Indexed", "Range", or "String". If not provided, it defaults to a value of 0. Contention factor should be set only if encryption algorithm is set to "Indexed", "Range", or "String".

  • query_type (String | nil)

    Query type to be applied if encryption algorithm is set to "Indexed", "Range", or "String". Allowed values are "equality", "range", "prefix", "suffix", and "substring".

  • :range_opts (Hash | nil)

    Specifies index options for a Queryable Encryption field supporting "range" queries. Allowed options are:

    • :min
    • :max
    • :trim_factor
    • :sparsity
    • :precision min, max, trim_factor, sparsity, and precision must match the values set in the encryptedFields of the destination collection. For double and decimal128, min/max/precision must all be set, or all be unset.
  • :string_opts (Hash | nil)

    Specifies index options for a Queryable Encryption field supporting "prefix", "suffix", or "substring" queries (algorithm "String"). Allowed options are:

    • :case_sensitive
    • :diacritic_sensitive
    • :prefix (Hash with :str_min_query_length, :str_max_query_length)
    • :suffix (Hash with :str_min_query_length, :str_max_query_length)
    • :substring (Hash with :str_max_length, :str_min_query_length, :str_max_query_length) The options must match the values set in the encryptedFields of the destination collection.

Raises:



79
80
81
82
83
84
# File 'lib/mongo/crypt/explicit_encryption_context.rb', line 79

def initialize(mongocrypt, io, doc, options = {})
  super(mongocrypt, io)
  set_key_opts(options)
  set_algorithm_opts(options)
  init(doc)
end

Instance Method Details

#init(doc) ⇒ Object

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.



86
87
88
# File 'lib/mongo/crypt/explicit_encryption_context.rb', line 86

def init(doc)
  Binding.ctx_explicit_encrypt_init(self, doc)
end