Class: Mongo::Crypt::Binding Private
- Inherits:
-
Object
- Object
- Mongo::Crypt::Binding
- Extended by:
- FFI::Library
- Defined in:
- build/ruby-driver-master/lib/mongo/crypt/binding.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 Ruby binding for the libmongocrypt C library
Constant Summary collapse
- MIN_LIBMONGOCRYPT_VERSION =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Minimum version of libmongocrypt required by this version of the driver. An attempt to use the driver with any previous version of libmongocrypt will cause a `LoadError`.
Gem::Version.new("1.5.0.alpha")
Class Method Summary collapse
-
.check_ctx_status(context) ⇒ nil
private
Raise a Mongo::Error::CryptError based on the status of the underlying mongocrypt_ctx_t object.
-
.check_kms_ctx_status(kms_context) ⇒ Object
private
If the provided block returns false, raise a CryptError with the status information from the provided KmsContext object.
-
.check_status(handle) ⇒ nil
private
Raise a Mongo::Error::CryptError based on the status of the underlying mongocrypt_t object.
-
.ctx_datakey_init(context) ⇒ Object
private
Initialize the Context to create a data key.
-
.ctx_decrypt_init(context, command) ⇒ Object
private
Initialize the Context for auto-decryption.
-
.ctx_encrypt_init(context, db_name, command) ⇒ Object
private
Initialize the Context for auto-encryption.
-
.ctx_explicit_decrypt_init(context, doc) ⇒ Object
private
Initialize the Context for explicit decryption.
-
.ctx_explicit_encrypt_init(context, doc) ⇒ Object
private
Initialize the Context for explicit encryption.
-
.ctx_finalize(context) ⇒ Object
private
Finalize the state machine represented by the Context.
-
.ctx_kms_done(context) ⇒ Object
private
Indicate to libmongocrypt that it will receive no more KMS replies.
-
.ctx_mongo_feed(context, doc) ⇒ Object
private
Feed a response from the driver back to libmongocrypt.
-
.ctx_mongo_op(context) ⇒ BSON::Document
private
Returns a BSON::Document representing an operation that the driver must perform on behalf of libmongocrypt to get the information it needs in order to continue with encryption/decryption (for example, a filter for a key vault query).
-
.ctx_next_kms_ctx(context) ⇒ Mongo::Crypt::KmsContext | nil
private
Return a new KmsContext object needed by a Context object.
-
.ctx_rewrap_many_datakey_init(context, filter) ⇒ Boolean
private
Initialize a context to rewrap datakeys.
-
.ctx_setopt_algorithm(context, name) ⇒ Object
private
Set the algorithm on the context.
-
.ctx_setopt_contention_factor(context, factor) ⇒ Object
private
Set the contention factor used for explicit encryption.
-
.ctx_setopt_key_alt_names(context, key_alt_names) ⇒ Object
private
Set multiple alternate key names on data key creation.
-
.ctx_setopt_key_encryption_key(context, key_document) ⇒ Object
private
Set key encryption key document for creating a data key.
-
.ctx_setopt_key_id(context, key_id) ⇒ Object
private
Sets the key id option on an explicit encryption context.
-
.ctx_setopt_key_material(context, key_material) ⇒ Object
private
Set set a custom key material to use for encrypting data.
-
.ctx_setopt_query_type(context, query_type) ⇒ Object
private
Set the query type to use for FLE 2 explicit encryption.
-
.init(handle) ⇒ Object
private
Initialize the Mongo::Crypt::Handle object.
-
.kms_ctx_bytes_needed(kms_context) ⇒ Integer
private
Get the number of bytes needed by the KmsContext.
-
.kms_ctx_endpoint(kms_context) ⇒ String | nil
private
Get the hostname with which to connect over TLS to get information about the AWS master key.
-
.kms_ctx_feed(kms_context, bytes) ⇒ Object
private
Feed replies from the KMS back to libmongocrypt.
-
.kms_ctx_get_kms_provider(kms_context) ⇒ Object
private
Get the KMS provider identifier associated with this KMS request.
-
.kms_ctx_message(kms_context) ⇒ String
private
Get the HTTP message needed to fetch the AWS KMS master key from a KmsContext object.
-
.mongocrypt_binary_data(binary) ⇒ FFI::Pointer
private
Get the pointer to the underlying data for the mongocrypt_binary_t.
-
.mongocrypt_binary_destroy(binary) ⇒ nil
private
Destroy the mongocrypt_binary_t object.
-
.mongocrypt_binary_len(binary) ⇒ Integer
private
Get the length of the underlying data array.
-
.mongocrypt_binary_new ⇒ FFI::Pointer
private
Creates a new mongocrypt_binary_t object (a non-owning view of a byte array).
-
.mongocrypt_binary_new_from_data(data, len) ⇒ FFI::Pointer
private
Create a new mongocrypt_binary_t object that maintains a pointer to the specified byte array.
- .mongocrypt_ctx_datakey_init(ctx, filter) ⇒ Object private
-
.mongocrypt_ctx_decrypt_init(ctx, doc) ⇒ Boolean
private
Initializes the ctx for auto-decryption.
-
.mongocrypt_ctx_destroy(ctx) ⇒ nil
private
Destroy the reference to the mongocrypt_ctx_t object.
-
.mongocrypt_ctx_encrypt_init(ctx, db, db_len, cmd) ⇒ Boolean
private
Initializes the ctx for auto-encryption.
-
.mongocrypt_ctx_explicit_decrypt_init(ctx, msg) ⇒ Boolean
private
Initializes the ctx for explicit decryption.
-
.mongocrypt_ctx_explicit_encrypt_init(ctx, msg) ⇒ Boolean
private
Initializes the ctx for explicit encryption.
-
.mongocrypt_ctx_finalize(ctx, op_bson) ⇒ Boolean
private
Perform the final encryption or decryption and return a BSON document.
-
.mongocrypt_ctx_mongo_done(ctx) ⇒ Boolean
private
Indicate to libmongocrypt that the driver is done feeding replies.
-
.mongocrypt_ctx_mongo_feed(ctx, reply) ⇒ Boolean
private
Feed a BSON reply to libmongocrypt.
-
.mongocrypt_ctx_mongo_next_kms_ctx(ctx) ⇒ FFI::Pointer
private
Return a pointer to a mongocrypt_kms_ctx_t object or NULL.
-
.mongocrypt_ctx_mongo_op(ctx, op_bson) ⇒ Boolean
private
Get a BSON operation for the driver to run against the MongoDB collection, the key vault database, or mongocryptd.
-
.mongocrypt_ctx_new(crypt) ⇒ FFI::Pointer
private
Create a new mongocrypt_ctx_t object (a wrapper for the libmongocrypt state machine).
-
.mongocrypt_ctx_setopt_algorithm(ctx, algorithm, len) ⇒ Boolean
private
Set the algorithm used for explicit encryption.
- .mongocrypt_ctx_setopt_contention_factor(ctx, contention_factor) ⇒ Object private
-
.mongocrypt_ctx_setopt_key_alt_name(ctx, binary) ⇒ Boolean
private
When creating a data key, set an alternate name on that key.
-
.mongocrypt_ctx_setopt_key_encryption_key(ctx) ⇒ Boolean
private
Set key encryption key document for creating a data key.
-
.mongocrypt_ctx_setopt_key_id(ctx, key_id) ⇒ Boolean
private
Set the key id used for explicit encryption.
-
.mongocrypt_ctx_setopt_key_material(ctx, binary) ⇒ Boolean
private
When creating a data key, set a custom key material to use for encrypting data.
- .mongocrypt_ctx_setopt_query_type(ctx, mongocrypt_query_type) ⇒ Object private
-
.mongocrypt_ctx_state(ctx) ⇒ Symbol
private
Get the current state of the ctx.
-
.mongocrypt_ctx_status(ctx, status) ⇒ Boolean
private
Set the status information from the mongocrypt_ctx_t object on the mongocrypt_status_t object.
-
.mongocrypt_destroy(crypt) ⇒ nil
private
Destroy the reference the mongocrypt_t object.
-
.mongocrypt_init(crypt) ⇒ Boolean
private
Initialize the mongocrypt_t object.
-
.mongocrypt_kms_ctx_bytes_needed(kms) ⇒ Integer
private
Get the number of bytes needed by the KMS context.
-
.mongocrypt_kms_ctx_done(ctx) ⇒ Boolean
private
Indicate to libmongocrypt that it will receive no more replies from mongocrypt_kms_ctx_t objects.
-
.mongocrypt_kms_ctx_endpoint(kms, endpoint) ⇒ Boolean
private
Get the hostname with which to connect over TLS to get information about the AWS master key.
-
.mongocrypt_kms_ctx_feed(kms, bytes) ⇒ Boolean
private
Feed replies from the KMS back to libmongocrypt.
- .mongocrypt_kms_ctx_get_kms_provider(crypt, kms_providers) ⇒ Object private
-
.mongocrypt_kms_ctx_message(kms, msg) ⇒ Boolean
private
Get the message needed to fetch the AWS KMS master key.
-
.mongocrypt_kms_ctx_status(kms, status) ⇒ Boolean
private
Write status information about the mongocrypt_kms_ctx_t object to the mongocrypt_status_t object.
-
.mongocrypt_setopt_aes_256_ctr(crypt, aes_256_ctr_encrypt, aes_256_ctr_decrypt, ctx) ⇒ Boolean
private
Set a crypto hook for the AES256-CTR operations.
- .mongocrypt_setopt_bypass_query_analysis(crypt) ⇒ Object private
-
.mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs1_v1_5(crypt, sign_rsaes_pkcs1_v1_5, ctx = nil) ⇒ Boolean
private
Set a crypto hook for the RSASSA-PKCS1-v1_5 algorithm with a SHA-256 hash.
-
.mongocrypt_setopt_crypto_hooks(crypt, aes_enc_fn, aes_dec_fn, random_fn, sha_512_fn, sha_256_fn, hash_fn, ctx = nil) ⇒ Boolean
private
Set crypto hooks on the provided mongocrypt object.
- .mongocrypt_setopt_encrypted_field_config_map(crypt, efc_map) ⇒ Object private
-
.mongocrypt_setopt_kms_providers(crypt, kms_providers) ⇒ Object
private
Configure KMS providers with a BSON document.
-
.mongocrypt_setopt_log_handler(crypt, log_fn, log_ctx = nil) ⇒ Boolean
private
Set the handler on the mongocrypt_t object to be called every time libmongocrypt logs a message.
-
.mongocrypt_setopt_schema_map(crypt, schema_map) ⇒ Boolean
private
Sets a local schema map for encryption.
-
.mongocrypt_status(crypt, status) ⇒ Boolean
private
Set the status information from the mongocrypt_t object on the mongocrypt_status_t object.
-
.mongocrypt_status_code(status) ⇒ Integer
private
Return the status error code.
-
.mongocrypt_status_destroy(status) ⇒ nil
private
Destroys the reference to the mongocrypt_status_t object.
-
.mongocrypt_status_message(status, len = nil) ⇒ String
private
Returns the status message.
-
.mongocrypt_status_new ⇒ FFI::Pointer
private
Create a new mongocrypt_status_t object.
-
.mongocrypt_status_ok(status) ⇒ Boolean
private
Returns whether the status is ok or an error.
-
.mongocrypt_status_set(status, type, code, message, len) ⇒ nil
private
Set a message, type, and code on an existing status.
-
.mongocrypt_status_type(status) ⇒ Symbol
private
Indicates the status type.
-
.mongocrypt_version(len) ⇒ String
private
Returns the version string of the libmongocrypt library.
-
.ongocrypt_new ⇒ FFI::Pointer
private
Creates a new mongocrypt_t object.
-
.setopt_aes_256_ctr(handle, aes_ctr_encrypt_cb, aes_ctr_decrypt_cb) ⇒ Object
private
Set a crypto hook for the AES256-CTR operations.
-
.setopt_bypass_query_analysis(handle) ⇒ Object
private
Opt-into skipping query analysis.
-
.setopt_crypto_hook_sign_rsaes_pkcs1_v1_5(handle, rsaes_pkcs_signature_cb) ⇒ Object
private
Set a crypto hook for the RSASSA-PKCS1-v1_5 algorithm with a SHA-256 hash oh the Handle.
-
.setopt_crypto_hooks(handle, aes_encrypt_cb, aes_decrypt_cb, random_cb, hmac_sha_512_cb, hmac_sha_256_cb, hmac_hash_cb) ⇒ Object
private
Set crypto callbacks on the Handle.
-
.setopt_encrypted_field_config_map(handle, efc_map) ⇒ Object
private
Set a local EncryptedFieldConfigMap for encryption.
-
.setopt_kms_providers(handle, kms_providers) ⇒ Object
private
Set KMS providers options on the Mongo::Crypt::Handle object.
-
.setopt_log_handler(handle, log_callback) ⇒ Object
private
Set the logger callback function on the Mongo::Crypt::Handle object.
-
.setopt_schema_map(handle, schema_map_doc) ⇒ Object
private
Set schema map on the Mongo::Crypt::Handle object.
-
.validate_document(data) ⇒ Object
private
Checks that the specified data is a Hash before serializing it to BSON to prevent errors from libmongocrypt.
-
.validate_version(lmc_version) ⇒ Object
private
Validates if provided version of libmongocrypt is valid, i.e.
Instance Method Summary collapse
-
#mongocrypt_crypto_fn(ctx, key, iv, input, output, status) ⇒ Bool
private
A callback to a function that performs AES encryption or decryption.
-
#mongocrypt_hash_fn(ctx, input, output, status) ⇒ Bool
private
A callback to a SHA-256 hash function.
-
#mongocrypt_hmac_fn(ctx, key, input, output, status) ⇒ Bool
private
A callback to a function that performs HMAC SHA-512 or SHA-256.
-
#mongocrypt_log_fn_t(level, message, len, ctx) ⇒ nil
private
A callback to the mongocrypt log function.
-
#mongocrypt_random_fn(ctx, output, count, status) ⇒ Bool
private
A callback to a crypto secure random function.
Class Method Details
.check_ctx_status(context) ⇒ nil
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.
Raise a Mongo::Error::CryptError based on the status of the underlying mongocrypt_ctx_t object.
1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1471 def self.check_ctx_status(context) if block_given? do_raise = !yield else do_raise = true end if do_raise status = Status.new mongocrypt_ctx_status(context.ctx_p, status.ref) status.raise_crypt_error end end |
.check_kms_ctx_status(kms_context) ⇒ 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.
If the provided block returns false, raise a CryptError with the status information from the provided KmsContext object.
1038 1039 1040 1041 1042 1043 1044 1045 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1038 def self.check_kms_ctx_status(kms_context) unless yield status = Status.new mongocrypt_kms_ctx_status(kms_context.kms_ctx_p, status.ref) status.raise_crypt_error(kms: true) end end |
.check_status(handle) ⇒ nil
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.
Raise a Mongo::Error::CryptError based on the status of the underlying mongocrypt_t object.
1458 1459 1460 1461 1462 1463 1464 1465 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1458 def self.check_status(handle) unless yield status = Status.new mongocrypt_status(handle.ref, status.ref) status.raise_crypt_error end end |
.ctx_datakey_init(context) ⇒ 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.
Initialize the Context to create a data key
591 592 593 594 595 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 591 def self.ctx_datakey_init(context) check_ctx_status(context) do mongocrypt_ctx_datakey_init(context.ctx_p) end end |
.ctx_decrypt_init(context, command) ⇒ 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.
Initialize the Context for auto-decryption
718 719 720 721 722 723 724 725 726 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 718 def self.ctx_decrypt_init(context, command) validate_document(command) data = command.to_bson.to_s Binary.wrap_string(data) do |data_p| check_ctx_status(context) do mongocrypt_ctx_decrypt_init(context.ctx_p, data_p) end end end |
.ctx_encrypt_init(context, db_name, command) ⇒ 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.
Initialize the Context for auto-encryption
658 659 660 661 662 663 664 665 666 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 658 def self.ctx_encrypt_init(context, db_name, command) validate_document(command) data = command.to_bson.to_s Binary.wrap_string(data) do |data_p| check_ctx_status(context) do mongocrypt_ctx_encrypt_init(context.ctx_p, db_name, -1, data_p) end end end |
.ctx_explicit_decrypt_init(context, 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.
Initialize the Context for explicit decryption
748 749 750 751 752 753 754 755 756 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 748 def self.ctx_explicit_decrypt_init(context, doc) validate_document(doc) data = doc.to_bson.to_s Binary.wrap_string(data) do |data_p| check_ctx_status(context) do mongocrypt_ctx_explicit_decrypt_init(context.ctx_p, data_p) end end end |
.ctx_explicit_encrypt_init(context, 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.
Initialize the Context for explicit encryption
692 693 694 695 696 697 698 699 700 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 692 def self.ctx_explicit_encrypt_init(context, doc) validate_document(doc) data = doc.to_bson.to_s Binary.wrap_string(data) do |data_p| check_ctx_status(context) do mongocrypt_ctx_explicit_encrypt_init(context.ctx_p, data_p) end end end |
.ctx_finalize(context) ⇒ 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.
Finalize the state machine represented by the Context
1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1084 def self.ctx_finalize(context) binary = Binary.new check_ctx_status(context) do mongocrypt_ctx_finalize(context.ctx_p, binary.ref) end # TODO since the binary references a C pointer, and ByteBuffer is # written in C in MRI, we could omit a copy of the data by making # ByteBuffer reference the string that is owned by libmongocrypt. BSON::Document.from_bson(BSON::ByteBuffer.new(binary.to_s), mode: :bson) end |
.ctx_kms_done(context) ⇒ 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.
Indicate to libmongocrypt that it will receive no more KMS replies.
1061 1062 1063 1064 1065 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1061 def self.ctx_kms_done(context) check_ctx_status(context) do mongocrypt_ctx_kms_done(context.ctx_p) end end |
.ctx_mongo_feed(context, 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.
Feed a response from the driver back to libmongocrypt
828 829 830 831 832 833 834 835 836 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 828 def self.ctx_mongo_feed(context, doc) validate_document(doc) data = doc.to_bson.to_s Binary.wrap_string(data) do |data_p| check_ctx_status(context) do mongocrypt_ctx_mongo_feed(context.ctx_p, data_p) end end end |
.ctx_mongo_op(context) ⇒ BSON::Document
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 BSON::Document representing an operation that the driver must perform on behalf of libmongocrypt to get the information it needs in order to continue with encryption/decryption (for example, a filter for a key vault query).
799 800 801 802 803 804 805 806 807 808 809 810 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 799 def self.ctx_mongo_op(context) binary = Binary.new check_ctx_status(context) do mongocrypt_ctx_mongo_op(context.ctx_p, binary.ref) end # TODO since the binary references a C pointer, and ByteBuffer is # written in C in MRI, we could omit a copy of the data by making # ByteBuffer reference the string that is owned by libmongocrypt. BSON::Document.from_bson(BSON::ByteBuffer.new(binary.to_s), mode: :bson) end |
.ctx_next_kms_ctx(context) ⇒ Mongo::Crypt::KmsContext | nil
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.
Return a new KmsContext object needed by a Context object.
860 861 862 863 864 865 866 867 868 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 860 def self.ctx_next_kms_ctx(context) kms_ctx_p = mongocrypt_ctx_next_kms_ctx(context.ctx_p) if kms_ctx_p.null? nil else KmsContext.new(kms_ctx_p) end end |
.ctx_rewrap_many_datakey_init(context, filter) ⇒ Boolean
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.
Initialize a context to rewrap datakeys.
622 623 624 625 626 627 628 629 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 622 def self.ctx_rewrap_many_datakey_init(context, filter) filter_data = filter.to_bson.to_s Binary.wrap_string(filter_data) do |data_p| check_ctx_status(context) do mongocrypt_ctx_rewrap_many_datakey_init(context.ctx_p, data_p) end end end |
.ctx_setopt_algorithm(context, name) ⇒ 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.
Set the algorithm on the context
535 536 537 538 539 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 535 def self.ctx_setopt_algorithm(context, name) check_ctx_status(context) do mongocrypt_ctx_setopt_algorithm(context.ctx_p, name, -1) end end |
.ctx_setopt_contention_factor(context, factor) ⇒ 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.
Set the contention factor used for explicit encryption. The contention factor is only used for indexed FLE 2 encryption.
1448 1449 1450 1451 1452 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1448 def self.ctx_setopt_contention_factor(context, factor) check_ctx_status(context) do mongocrypt_ctx_setopt_contention_factor(context.ctx_p, factor) end end |
.ctx_setopt_key_alt_names(context, key_alt_names) ⇒ 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.
Set multiple alternate key names on data key creation
466 467 468 469 470 471 472 473 474 475 476 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 466 def self.ctx_setopt_key_alt_names(context, key_alt_names) key_alt_names.each do |key_alt_name| key_alt_name_bson = { :keyAltName => key_alt_name }.to_bson.to_s Binary.wrap_string(key_alt_name_bson) do |key_alt_name_p| check_ctx_status(context) do mongocrypt_ctx_setopt_key_alt_name(context.ctx_p, key_alt_name_p) end end end end |
.ctx_setopt_key_encryption_key(context, key_document) ⇒ 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.
Set key encryption key document for creating a data key.
564 565 566 567 568 569 570 571 572 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 564 def self.ctx_setopt_key_encryption_key(context, key_document) validate_document(key_document) data = key_document.to_bson.to_s Binary.wrap_string(data) do |data_p| check_ctx_status(context) do mongocrypt_ctx_setopt_key_encryption_key(context.ctx_p, data_p) end end end |
.ctx_setopt_key_id(context, key_id) ⇒ 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.
Sets the key id option on an explicit encryption context.
433 434 435 436 437 438 439 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 433 def self.ctx_setopt_key_id(context, key_id) Binary.wrap_string(key_id) do |key_id_p| check_ctx_status(context) do mongocrypt_ctx_setopt_key_id(context.ctx_p, key_id_p) end end end |
.ctx_setopt_key_material(context, key_material) ⇒ 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.
Set set a custom key material to use for
encrypting data.
501 502 503 504 505 506 507 508 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 501 def self.ctx_setopt_key_material(context, key_material) data = {'keyMaterial' => key_material}.to_bson.to_s Binary.wrap_string(data) do |data_p| check_ctx_status(context) do mongocrypt_ctx_setopt_key_material(context.ctx_p, data_p) end end end |
.ctx_setopt_query_type(context, query_type) ⇒ 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.
Set the query type to use for FLE 2 explicit encryption. The query type is only used for indexed FLE 2 encryption.
1416 1417 1418 1419 1420 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1416 def self.ctx_setopt_query_type(context, query_type) check_ctx_status(context) do mongocrypt_ctx_setopt_query_type(context.ctx_p, query_type, -1) end end |
.init(handle) ⇒ 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.
Initialize the Mongo::Crypt::Handle object
373 374 375 376 377 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 373 def self.init(handle) check_status(handle) do mongocrypt_init(handle.ref) end end |
.kms_ctx_bytes_needed(kms_context) ⇒ Integer
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.
Get the number of bytes needed by the KmsContext.
994 995 996 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 994 def self.kms_ctx_bytes_needed(kms_context) mongocrypt_kms_ctx_bytes_needed(kms_context.kms_ctx_p) end |
.kms_ctx_endpoint(kms_context) ⇒ String | nil
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.
Get the hostname with which to connect over TLS to get information about the AWS master key.
970 971 972 973 974 975 976 977 978 979 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 970 def self.kms_ctx_endpoint(kms_context) ptr = FFI::MemoryPointer.new(:pointer, 1) check_kms_ctx_status(kms_context) do mongocrypt_kms_ctx_endpoint(kms_context.kms_ctx_p, ptr) end str_ptr = ptr.read_pointer str_ptr.null? ? nil : str_ptr.read_string.force_encoding('UTF-8') end |
.kms_ctx_feed(kms_context, bytes) ⇒ 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.
Feed replies from the KMS back to libmongocrypt.
1014 1015 1016 1017 1018 1019 1020 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1014 def self.kms_ctx_feed(kms_context, bytes) check_kms_ctx_status(kms_context) do Binary.wrap_string(bytes) do |bytes_p| mongocrypt_kms_ctx_feed(kms_context.kms_ctx_p, bytes_p) end end end |
.kms_ctx_get_kms_provider(kms_context) ⇒ 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.
Get the KMS provider identifier associated with this KMS request.
This is used to conditionally configure TLS connections based on the KMS request. It is useful for KMIP, which authenticates with a client certificate.
901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 901 def self.kms_ctx_get_kms_provider(kms_context) len_ptr = FFI::MemoryPointer.new(:uint32, 1) provider = mongocrypt_kms_ctx_get_kms_provider( kms_context.kms_ctx_p, len_ptr ) if len_ptr.nil? nil else len = if BSON::Environment.jruby? # JRuby FFI implementation does not have `read(type)` method, but it # has this `get_uint32`. len_ptr.get_uint32 else # For MRI we use a documented `read` method - https://www.rubydoc.info/github/ffi/ffi/FFI%2FPointer:read len_ptr.read(:uint32) end provider.read_string(len).to_sym end end |
.kms_ctx_message(kms_context) ⇒ String
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.
Get the HTTP message needed to fetch the AWS KMS master key from a KmsContext object.
941 942 943 944 945 946 947 948 949 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 941 def self.(kms_context) binary = Binary.new check_kms_ctx_status(kms_context) do (kms_context.kms_ctx_p, binary.ref) end return binary.to_s end |
.mongocrypt_binary_data(binary) ⇒ FFI::Pointer
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.
Get the pointer to the underlying data for the mongocrypt_binary_t.
145 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 145 attach_function :mongocrypt_binary_data, [:pointer], :pointer |
.mongocrypt_binary_destroy(binary) ⇒ nil
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.
Destroy the mongocrypt_binary_t object.
161 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 161 attach_function :mongocrypt_binary_destroy, [:pointer], :void |
.mongocrypt_binary_len(binary) ⇒ Integer
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.
Get the length of the underlying data array.
153 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 153 attach_function :mongocrypt_binary_len, [:pointer], :int |
.mongocrypt_binary_new ⇒ FFI::Pointer
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.
Creates a new mongocrypt_binary_t object (a non-owning view of a byte
array).
121 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 121 attach_function :mongocrypt_binary_new, [], :pointer |
.mongocrypt_binary_new_from_data(data, len) ⇒ FFI::Pointer
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 mongocrypt_binary_t object that maintains a pointer to
the specified byte array.
133 134 135 136 137 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 133 attach_function( :mongocrypt_binary_new_from_data, [:pointer, :int], :pointer ) |
.mongocrypt_ctx_datakey_init(ctx, filter) ⇒ 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.
584 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 584 attach_function :mongocrypt_ctx_datakey_init, [:pointer], :bool |
.mongocrypt_ctx_decrypt_init(ctx, doc) ⇒ Boolean
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.
Initializes the ctx for auto-decryption.
710 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 710 attach_function :mongocrypt_ctx_decrypt_init, [:pointer, :pointer], :bool |
.mongocrypt_ctx_destroy(ctx) ⇒ nil
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.
Destroy the reference to the mongocrypt_ctx_t object.
1103 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1103 attach_function :mongocrypt_ctx_destroy, [:pointer], :void |
.mongocrypt_ctx_encrypt_init(ctx, db, db_len, cmd) ⇒ Boolean
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.
This method expects the passed-in BSON to be in the format: { “v”: BSON value to decrypt }.
Initializes the ctx for auto-encryption.
644 645 646 647 648 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 644 attach_function( :mongocrypt_ctx_encrypt_init, [:pointer, :string, :int, :pointer], :bool ) |
.mongocrypt_ctx_explicit_decrypt_init(ctx, msg) ⇒ Boolean
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.
Initializes the ctx for explicit decryption.
736 737 738 739 740 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 736 attach_function( :mongocrypt_ctx_explicit_decrypt_init, [:pointer, :pointer], :bool ) |
.mongocrypt_ctx_explicit_encrypt_init(ctx, msg) ⇒ Boolean
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.
Before calling this method, set a key_id, key_alt_name (optional), and encryption algorithm using the following methods: mongocrypt_ctx_setopt_key_id, mongocrypt_ctx_setopt_key_alt_name, and mongocrypt_ctx_setopt_algorithm.
Initializes the ctx for explicit encryption.
680 681 682 683 684 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 680 attach_function( :mongocrypt_ctx_explicit_encrypt_init, [:pointer, :pointer], :bool ) |
.mongocrypt_ctx_finalize(ctx, op_bson) ⇒ Boolean
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.
Perform the final encryption or decryption and return a BSON document.
1076 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1076 attach_function :mongocrypt_ctx_finalize, [:pointer, :pointer], :void |
.mongocrypt_ctx_mongo_done(ctx) ⇒ Boolean
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.
Indicate to libmongocrypt that the driver is done feeding replies.
844 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 844 attach_function :mongocrypt_ctx_mongo_done, [:pointer], :bool |
.mongocrypt_ctx_mongo_feed(ctx, reply) ⇒ Boolean
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.
Feed a BSON reply to libmongocrypt.
820 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 820 attach_function :mongocrypt_ctx_mongo_feed, [:pointer, :pointer], :bool |
.mongocrypt_ctx_mongo_next_kms_ctx(ctx) ⇒ FFI::Pointer
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.
Return a pointer to a mongocrypt_kms_ctx_t object or NULL.
852 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 852 attach_function :mongocrypt_ctx_next_kms_ctx, [:pointer], :pointer |
.mongocrypt_ctx_mongo_op(ctx, op_bson) ⇒ Boolean
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.
Get a BSON operation for the driver to run against the MongoDB
collection, the key vault database, or mongocryptd.
788 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 788 attach_function :mongocrypt_ctx_mongo_op, [:pointer, :pointer], :bool |
.mongocrypt_ctx_new(crypt) ⇒ FFI::Pointer
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 mongocrypt_ctx_t object (a wrapper for the libmongocrypt
state machine).
404 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 404 attach_function :mongocrypt_ctx_new, [:pointer], :pointer |
.mongocrypt_ctx_setopt_algorithm(ctx, algorithm, len) ⇒ Boolean
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.
Do not initialize ctx before calling this method.
Set the algorithm used for explicit encryption.
521 522 523 524 525 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 521 attach_function( :mongocrypt_ctx_setopt_algorithm, [:pointer, :string, :int], :bool ) |
.mongocrypt_ctx_setopt_contention_factor(ctx, contention_factor) ⇒ 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.
1432 1433 1434 1435 1436 1437 1438 1439 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1432 attach_function( :mongocrypt_ctx_setopt_contention_factor, [ :pointer, :int64 ], :bool ) |
.mongocrypt_ctx_setopt_key_alt_name(ctx, binary) ⇒ Boolean
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.
Do not initialize ctx before calling this method.
When creating a data key, set an alternate name on that key. When
performing explicit encryption, specifying which data key to use for
encryption based on its keyAltName field.
453 454 455 456 457 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 453 attach_function( :mongocrypt_ctx_setopt_key_alt_name, [:pointer, :pointer], :bool ) |
.mongocrypt_ctx_setopt_key_encryption_key(ctx) ⇒ Boolean
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.
Do not initialize ctx before calling this method.
Set key encryption key document for creating a data key.
551 552 553 554 555 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 551 attach_function( :mongocrypt_ctx_setopt_key_encryption_key, [:pointer, :pointer], :bool ) |
.mongocrypt_ctx_setopt_key_id(ctx, key_id) ⇒ Boolean
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.
Do not initialize ctx before calling this method.
Set the key id used for explicit encryption.
425 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 425 attach_function :mongocrypt_ctx_setopt_key_id, [:pointer, :pointer], :bool |
.mongocrypt_ctx_setopt_key_material(ctx, binary) ⇒ Boolean
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.
Do not initialize ctx before calling this method.
When creating a data key, set a custom key material to use for
encrypting data.
488 489 490 491 492 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 488 attach_function( :mongocrypt_ctx_setopt_key_material, [:pointer, :pointer], :bool ) |
.mongocrypt_ctx_setopt_query_type(ctx, mongocrypt_query_type) ⇒ 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.
1399 1400 1401 1402 1403 1404 1405 1406 1407 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1399 attach_function( :mongocrypt_ctx_setopt_query_type, [ :pointer, :string, :int ], :bool ) |
.mongocrypt_ctx_state(ctx) ⇒ Symbol
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.
Get the current state of the ctx.
776 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 776 attach_function :mongocrypt_ctx_state, [:pointer], :mongocrypt_ctx_state |
.mongocrypt_ctx_status(ctx, status) ⇒ Boolean
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.
Set the status information from the mongocrypt_ctx_t object on the
mongocrypt_status_t object.
414 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 414 attach_function :mongocrypt_ctx_status, [:pointer, :pointer], :bool |
.mongocrypt_destroy(crypt) ⇒ nil
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.
Destroy the reference the mongocrypt_t object.
395 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 395 attach_function :mongocrypt_destroy, [:pointer], :void |
.mongocrypt_init(crypt) ⇒ Boolean
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.
Initialize the mongocrypt_t object.
366 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 366 attach_function :mongocrypt_init, [:pointer], :bool |
.mongocrypt_kms_ctx_bytes_needed(kms) ⇒ Integer
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.
Get the number of bytes needed by the KMS context.
987 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 987 attach_function :mongocrypt_kms_ctx_bytes_needed, [:pointer], :int |
.mongocrypt_kms_ctx_done(ctx) ⇒ Boolean
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.
Indicate to libmongocrypt that it will receive no more replies from
mongocrypt_kms_ctx_t objects.
1054 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1054 attach_function :mongocrypt_ctx_kms_done, [:pointer], :bool |
.mongocrypt_kms_ctx_endpoint(kms, endpoint) ⇒ Boolean
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.
Get the hostname with which to connect over TLS to get information about
the AWS master key.
960 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 960 attach_function :mongocrypt_kms_ctx_endpoint, [:pointer, :pointer], :bool |
.mongocrypt_kms_ctx_feed(kms, bytes) ⇒ Boolean
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.
Feed replies from the KMS back to libmongocrypt.
1006 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1006 attach_function :mongocrypt_kms_ctx_feed, [:pointer, :pointer], :bool |
.mongocrypt_kms_ctx_get_kms_provider(crypt, kms_providers) ⇒ 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.
886 887 888 889 890 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 886 attach_function( :mongocrypt_kms_ctx_get_kms_provider, [:pointer, :pointer], :pointer ) |
.mongocrypt_kms_ctx_message(kms, msg) ⇒ Boolean
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.
Get the message needed to fetch the AWS KMS master key.
931 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 931 attach_function :mongocrypt_kms_ctx_message, [:pointer, :pointer], :bool |
.mongocrypt_kms_ctx_status(kms, status) ⇒ Boolean
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.
Write status information about the mongocrypt_kms_ctx_t object
to the mongocrypt_status_t object.
1030 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1030 attach_function :mongocrypt_kms_ctx_status, [:pointer, :pointer], :bool |
.mongocrypt_setopt_aes_256_ctr(crypt, aes_256_ctr_encrypt, aes_256_ctr_decrypt, ctx) ⇒ Boolean
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.
Set a crypto hook for the AES256-CTR operations.
1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1362 attach_function( :mongocrypt_setopt_aes_256_ctr, [ :pointer, :mongocrypt_crypto_fn, :mongocrypt_crypto_fn, :pointer ], :bool ) |
.mongocrypt_setopt_bypass_query_analysis(crypt) ⇒ 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.
1338 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1338 attach_function(:mongocrypt_setopt_bypass_query_analysis, [:pointer], :void) |
.mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs1_v1_5(crypt, sign_rsaes_pkcs1_v1_5, ctx = nil) ⇒ Boolean
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.
Set a crypto hook for the RSASSA-PKCS1-v1_5 algorithm with a SHA-256 hash.
1255 1256 1257 1258 1259 1260 1261 1262 1263 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1255 attach_function( :mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs1_v1_5, [ :pointer, :mongocrypt_hmac_fn, :pointer ], :bool ) |
.mongocrypt_setopt_crypto_hooks(crypt, aes_enc_fn, aes_dec_fn, random_fn, sha_512_fn, sha_256_fn, hash_fn, ctx = nil) ⇒ Boolean
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.
Set crypto hooks on the provided mongocrypt object.
1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1208 attach_function( :mongocrypt_setopt_crypto_hooks, [ :pointer, :mongocrypt_crypto_fn, :mongocrypt_crypto_fn, :mongocrypt_random_fn, :mongocrypt_hmac_fn, :mongocrypt_hmac_fn, :mongocrypt_hash_fn, :pointer ], :bool ) |
.mongocrypt_setopt_encrypted_field_config_map(crypt, efc_map) ⇒ 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.
1297 1298 1299 1300 1301 1302 1303 1304 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1297 attach_function( :mongocrypt_setopt_encrypted_field_config_map, [ :pointer, :pointer ], :bool ) |
.mongocrypt_setopt_kms_providers(crypt, kms_providers) ⇒ 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.
Do not initialize ctx before calling this method.
Configure KMS providers with a BSON document.
310 311 312 313 314 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 310 attach_function( :mongocrypt_setopt_kms_providers, [:pointer, :pointer], :bool ) |
.mongocrypt_setopt_log_handler(crypt, log_fn, log_ctx = nil) ⇒ Boolean
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.
Set the handler on the mongocrypt_t object to be called every time
libmongocrypt logs a message.
281 282 283 284 285 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 281 attach_function( :mongocrypt_setopt_log_handler, [:pointer, :mongocrypt_log_fn_t, :pointer], :bool ) |
.mongocrypt_setopt_schema_map(crypt, schema_map) ⇒ Boolean
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.
Sets a local schema map for encryption.
341 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 341 attach_function :mongocrypt_setopt_schema_map, [:pointer, :pointer], :bool |
.mongocrypt_status(crypt, status) ⇒ Boolean
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.
Set the status information from the mongocrypt_t object on the
mongocrypt_status_t object.
387 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 387 attach_function :mongocrypt_status, [:pointer, :pointer], :bool |
.mongocrypt_status_code(status) ⇒ Integer
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.
Return the status error code.
209 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 209 attach_function :mongocrypt_status_code, [:pointer], :int |
.mongocrypt_status_destroy(status) ⇒ nil
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.
Destroys the reference to the mongocrypt_status_t object.
235 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 235 attach_function :mongocrypt_status_destroy, [:pointer], :void |
.mongocrypt_status_message(status, len = nil) ⇒ String
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 the status message.
219 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 219 attach_function :mongocrypt_status_message, [:pointer, :pointer], :string |
.mongocrypt_status_new ⇒ FFI::Pointer
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 mongocrypt_status_t object.
175 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 175 attach_function :mongocrypt_status_new, [], :pointer |
.mongocrypt_status_ok(status) ⇒ Boolean
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 whether the status is ok or an error.
227 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 227 attach_function :mongocrypt_status_ok, [:pointer], :bool |
.mongocrypt_status_set(status, type, code, message, len) ⇒ nil
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.
Set a message, type, and code on an existing status.
189 190 191 192 193 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 189 attach_function( :mongocrypt_status_set, [:pointer, :status_type, :int, :string, :int], :void ) |
.mongocrypt_status_type(status) ⇒ Symbol
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.
Indicates the status type.
201 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 201 attach_function :mongocrypt_status_type, [:pointer], :status_type |
.mongocrypt_version(len) ⇒ String
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 the version string of the libmongocrypt library.
95 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 95 attach_function :mongocrypt_version, [:pointer], :string |
.ongocrypt_new ⇒ FFI::Pointer
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.
Creates a new mongocrypt_t object.
269 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 269 attach_function :mongocrypt_new, [], :pointer |
.setopt_aes_256_ctr(handle, aes_ctr_encrypt_cb, aes_ctr_decrypt_cb) ⇒ 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.
Set a crypto hook for the AES256-CTR operations.
1380 1381 1382 1383 1384 1385 1386 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1380 def self.setopt_aes_256_ctr(handle, aes_ctr_encrypt_cb, aes_ctr_decrypt_cb) check_status(handle) do mongocrypt_setopt_aes_256_ctr(handle.ref, aes_ctr_encrypt_cb, aes_ctr_decrypt_cb, nil ) end end |
.setopt_bypass_query_analysis(handle) ⇒ 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.
Opt-into skipping query analysis.
If opted in:
-
The csfle shared library will not attempt to be loaded.
-
A mongocrypt_ctx_t will never enter the MONGOCRYPT_CTX_NEED_MARKINGS state.
1347 1348 1349 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1347 def self.setopt_bypass_query_analysis(handle) mongocrypt_setopt_bypass_query_analysis(handle.ref) end |
.setopt_crypto_hook_sign_rsaes_pkcs1_v1_5(handle, rsaes_pkcs_signature_cb) ⇒ 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.
Set a crypto hook for the RSASSA-PKCS1-v1_5 algorithm with
a SHA-256 hash oh the Handle.
1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1272 def self.setopt_crypto_hook_sign_rsaes_pkcs1_v1_5( handle, rsaes_pkcs_signature_cb ) check_status(handle) do mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs1_v1_5( handle.ref, rsaes_pkcs_signature_cb, nil ) end end |
.setopt_crypto_hooks(handle, aes_encrypt_cb, aes_decrypt_cb, random_cb, hmac_sha_512_cb, hmac_sha_256_cb, hmac_hash_cb) ⇒ 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.
Set crypto callbacks on the Handle
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1234 def self.setopt_crypto_hooks(handle, aes_encrypt_cb, aes_decrypt_cb, random_cb, hmac_sha_512_cb, hmac_sha_256_cb, hmac_hash_cb ) check_status(handle) do mongocrypt_setopt_crypto_hooks(handle.ref, aes_encrypt_cb, aes_decrypt_cb, random_cb, hmac_sha_512_cb, hmac_sha_256_cb, hmac_hash_cb, nil ) end end |
.setopt_encrypted_field_config_map(handle, efc_map) ⇒ 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.
Set a local EncryptedFieldConfigMap for encryption.
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1315 def self.setopt_encrypted_field_config_map(handle, efc_map) validate_document(efc_map) data = efc_map.to_bson.to_s Binary.wrap_string(data) do |data_p| check_status(handle) do mongocrypt_setopt_encrypted_field_config_map( handle.ref, data_p ) end end end |
.setopt_kms_providers(handle, kms_providers) ⇒ 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.
Set KMS providers options on the Mongo::Crypt::Handle object
323 324 325 326 327 328 329 330 331 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 323 def self.setopt_kms_providers(handle, kms_providers) validate_document(kms_providers) data = kms_providers.to_bson.to_s Binary.wrap_string(data) do |data_p| check_status(handle) do mongocrypt_setopt_kms_providers(handle.ref, data_p) end end end |
.setopt_log_handler(handle, log_callback) ⇒ 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.
Set the logger callback function on the Mongo::Crypt::Handle object
293 294 295 296 297 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 293 def self.setopt_log_handler(handle, log_callback) check_status(handle) do mongocrypt_setopt_log_handler(handle, log_callback, nil) end end |
.setopt_schema_map(handle, schema_map_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.
Set schema map on the Mongo::Crypt::Handle object
350 351 352 353 354 355 356 357 358 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 350 def self.setopt_schema_map(handle, schema_map_doc) validate_document(schema_map_doc) data = schema_map_doc.to_bson.to_s Binary.wrap_string(data) do |data_p| check_status(handle) do mongocrypt_setopt_schema_map(handle.ref, data_p) end end end |
.validate_document(data) ⇒ 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.
All BSON::Document instances are also Hash instances
Checks that the specified data is a Hash before serializing it to BSON to prevent errors from libmongocrypt
1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1494 def self.validate_document(data) return if data.is_a?(Hash) if data.nil? = "Attempted to pass nil data to libmongocrypt. " + "Data must be a Hash" else = "Attempted to pass invalid data to libmongocrypt: #{data} " + "Data must be a Hash" end raise Error::CryptError.new() end |
.validate_version(lmc_version) ⇒ 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.
Validates if provided version of libmongocrypt is valid, i.e. equal or greater than minimum required version. Raises a LoadError if not.
105 106 107 108 109 110 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 105 def self.validate_version(lmc_version) if (actual_version = Gem::Version.new(lmc_version)) < MIN_LIBMONGOCRYPT_VERSION raise LoadError, "libmongocrypt version #{MIN_LIBMONGOCRYPT_VERSION} or above is required, " + "but version #{actual_version} was found." end end |
Instance Method Details
#mongocrypt_crypto_fn(ctx, key, iv, input, output, status) ⇒ Bool
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.
This defines a method signature for an FFI callback; it is not an instance method on the Binding class.
A callback to a function that performs AES encryption or decryption.
1126 1127 1128 1129 1130 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1126 callback( :mongocrypt_crypto_fn, [:pointer, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer], :bool ) |
#mongocrypt_hash_fn(ctx, input, output, status) ⇒ Bool
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.
This defines a method signature for an FFI callback; it is not an instance method on the Binding class.
A callback to a SHA-256 hash function.
1174 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1174 callback :mongocrypt_hash_fn, [:pointer, :pointer, :pointer, :pointer], :bool |
#mongocrypt_hmac_fn(ctx, key, input, output, status) ⇒ Bool
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.
This defines a method signature for an FFI callback; it is not an instance method on the Binding class.
A callback to a function that performs HMAC SHA-512 or SHA-256.
1151 1152 1153 1154 1155 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1151 callback( :mongocrypt_hmac_fn, [:pointer, :pointer, :pointer, :pointer, :pointer], :bool ) |
#mongocrypt_log_fn_t(level, message, len, ctx) ⇒ nil
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.
This defines a method signature for an FFI callback; it is not an instance method on the Binding class.
A callback to the mongocrypt log function. Set a custom log callback
with the mongocrypt_setopt_log_handler method
262 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 262 callback :mongocrypt_log_fn_t, [:log_level, :string, :int, :pointer], :void |
#mongocrypt_random_fn(ctx, output, count, status) ⇒ Bool
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.
This defines a method signature for an FFI callback; it is not an instance method on the Binding class.
A callback to a crypto secure random function.
1192 |
# File 'build/ruby-driver-master/lib/mongo/crypt/binding.rb', line 1192 callback :mongocrypt_random_fn, [:pointer, :pointer, :int, :pointer], :bool |