类:Mongo::Crypt::Binding Private

继承:
对象
  • 对象
显示全部
扩展方式:
FFI::Library
定义于:
lib/ Mongo/crypt/bounding.rb

Overview

此类是私有 API 的一部分。 应尽可能避免使用此类,因为它将来可能会被删除或更改。

libmongocrypt C库的Ruby绑定

常量摘要折叠

MIN_LIBMONGOCRYPT_VERSION =

此常量是私有 API 的一部分。 应尽可能避免使用此常量,因为它将来可能会被删除或更改。

此版本的驾驶员所需的最低 libmongocrypt 版本。 尝试将该驾驶员与任何以前版本的 libmongocrypt 一起使用都会导致“LoadError”。

Gem::版本.new(" 1.12.0 ")

类方法摘要折叠

实例方法摘要折叠

类方法详细信息

.check_ctx_status(context) ⇒ nil

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

根据底层 mongocrypt_ctx_t 对象的状态引发 Mongo::Error::CryptError。

返回:

  • ( nil )

    始终为零。



1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
# File 'lib/ Mongo/crypt/bounding.rb', line 1821

def self.check_ctx_status(上下文)
  if block_given?
    do_rise = !产量
  else
    do_rise = true
  end

  if do_rise
    状态 = 状态.new

    mongocrypt_ctx_status(上下文.ctx_p, 状态.ref)
    状态.Raise_crypt_error
  end
end

check_kms_ctx_status (kms_context) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

如果提供的区块返回 false,则使用所提供的 KmsContext 对象中的状态信息引发 CryptError。

参数:

引发:



1107
1108
1109
1110
1111
1112
1113
1114
# File 'lib/ Mongo/crypt/bounding.rb', line 1107

def self.check_kms_ctx_status(kms_context)
  除非 产量
    状态 = 状态.new

    mongocrypt_kms_ctx_status(kms_context.kms_ctx_p, 状态.ref)
    状态.Raise_crypt_error(KMS : true)
  end
end

check_status (处理) ⇒ nil

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

根据根本的mongocrypt_t对象的状态引发 Mongo::Error::CryptError 。

返回:

  • ( nil )

    始终为零。



1808
1809
1810
1811
1812
1813
1814
1815
# File 'lib/ Mongo/crypt/bounding.rb', line 1808

def self.check_status(处理)
  除非 产量
    状态 = 状态.new

    mongocrypt_status(处理.ref, 状态.ref)
    状态.Raise_crypt_error
  end
end

crypt_shared_lib_version (处理) ⇒整数

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

获取64位常量,对已加载的 crypt_shared 库的版本进行编码(如果可用)。

版本从高到低编码为四个16位数字:

  • 主要版本

  • 次要版本

  • 修订版

  • reserved

示例,版本6.2.1将编码为: 0 x 0006 ' 0002 ' 0001 ' 0000

参数:

返回:

  • ( Integer )

    64位编码的版本号,该版本编码为四个 16 位整数,如果未加载 crypt_shared 库,则为零。



1614
1615
1616
# File 'lib/ Mongo/crypt/bounding.rb', line 1614

def self.crypt_shared_lib_version(处理)
  mongocrypt_crypt_shared_lib_version(处理.ref)
end

ctx_datakey_init (context) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

初始化上下文以创建数据密钥

参数:

引发:



625
626
627
628
629
# File 'lib/ Mongo/crypt/bounding.rb', line 625

def self.ctx_datakey_init(上下文)
  check_ctx_status(上下文) do
    mongocrypt_ctx_datakey_init(上下文.ctx_p)
  end
end

ctx_decrypt_init (context, command) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

初始化自动解密的上下文

参数:

引发:



786
787
788
789
790
791
792
793
794
# File 'lib/ Mongo/crypt/bounding.rb', line 786

def self.ctx_decrypt_init(上下文, 命令)
  validate_document(命令)
  数据 = 命令.to_bson.to_s
  二进制文件.wrapp_string(数据) do |data_p|
    check_ctx_status(上下文) do
      mongocrypt_ctx_decrypt_init(上下文.ctx_p, data_p)
    end
  end
end

ctx_encrypt_init (context, db_name, command) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

初始化自动加密的上下文

参数:

  • 上下文 ( Mongo::Crypt::Context )
  • db_name ( string )

    正在执行加密命令的数据库的名称

  • 命令 (哈希)

    待加密的命令

引发:



692
693
694
695
696
697
698
699
700
# File 'lib/ Mongo/crypt/bounding.rb', line 692

def self.ctx_encrypt_init(上下文, db_name, 命令)
  validate_document(命令)
  数据 = 命令.to_bson.to_s
  二进制文件.wrapp_string(数据) do |data_p|
    check_ctx_status(上下文) do
      mongocrypt_ctx_encrypt_init(上下文.ctx_p, db_name, -1, data_p)
    end
  end
end

.ctx_explicit_decrypt_init(context, doc) ⇒ Object

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

为显式解密初始化上下文

参数:

引发:



816
817
818
819
820
821
822
823
824
# File 'lib/ Mongo/crypt/bounding.rb', line 816

def self.ctx_explicit_decrypt_init(上下文, doc)
  validate_document(doc)
  数据 = doc.to_bson.to_s
  二进制文件.wrapp_string(数据) do |data_p|
    check_ctx_status(上下文) do
      mongocrypt_ctx_explicit_decrypt_init(上下文.ctx_p, data_p)
    end
  end
end

ctx_explicit_encrypt_expression_init (context, doc) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

初始化显式表达式加密的上下文。

参数:

引发:



760
761
762
763
764
765
766
767
768
# File 'lib/ Mongo/crypt/bounding.rb', line 760

def self.ctx_explicit_encrypt_expression_init(上下文, doc)
  validate_document(doc)
  数据 = doc.to_bson.to_s
  二进制文件.wrapp_string(数据) do |data_p|
    check_ctx_status(上下文) do
      mongocrypt_ctx_explicit_encrypt_expression_init(上下文.ctx_p, data_p)
    end
  end
end

.ctx_explicit_encrypt_init(context, doc) ⇒ Object

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

初始化显式加密的上下文

参数:

引发:



726
727
728
729
730
731
732
733
734
# File 'lib/ Mongo/crypt/bounding.rb', line 726

def self.ctx_explicit_encrypt_init(上下文, doc)
  validate_document(doc)
  数据 = doc.to_bson.to_s
  二进制文件.wrapp_string(数据) do |data_p|
    check_ctx_status(上下文) do
      mongocrypt_ctx_explicit_encrypt_init(上下文.ctx_p, data_p)
    end
  end
end

ctx_finalize (context) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

最终确定 Context 表示的状态机

参数:

引发:



1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
# File 'lib/ Mongo/crypt/bounding.rb', line 1209

def self.ctx_finalize(上下文)
  二进制文件 = 二进制文件.new

  check_ctx_status(上下文) do
    mongocrypt_ctx_finalize(上下文.ctx_p, 二进制文件.ref)
  end

  # TODO,因为二进制文件引用了C指针,而 ByteBuffer 是
  # 在 MRI 中用 C 语言编写,我们可以省略数据副本,方法是
  # ByteBuffer 引用 libmongocrypt 拥有的string 。
  BSON::文档.from_bson(BSON::ByteBuffer.new(二进制文件.to_s), 模式: :bson)
end

.ctx_kms_done(context) ⇒ Object

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

向 libmongocrypt 表明它将不再收到KMS回复。

参数:

引发:



1186
1187
1188
1189
1190
# File 'lib/ Mongo/crypt/bounding.rb', line 1186

def self.ctx_kms_done(上下文)
  check_ctx_status(上下文) do
    mongocrypt_ctx_kms_done(上下文.ctx_p)
  end
end

ctx_mongo_feed (context, doc) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

将驾驶员的响应反馈给 libmongocrypt

参数:

引发:



897
898
899
900
901
902
903
904
905
# File 'lib/ Mongo/crypt/bounding.rb', line 897

def self.ctx_mongo_feed(上下文, doc)
  validate_document(doc)
  数据 = doc.to_bson.to_s
  二进制文件.wrapp_string(数据) do |data_p|
    check_ctx_status(上下文) do
      mongocrypt_ctx_mongo_feed(上下文.ctx_p, data_p)
    end
  end
end

.ctx_mongo_op(context) ⇒ BSON::Document

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

返回一个BSON::Document,表示驾驶员必须代表 libmongocrypt 执行以获取所需信息以继续加密/解密的操作(示例,用于密钥保管库查询的过滤)。

参数:

返回:

  • ( BSON::Document )

    驾驶员必须执行的操作

引发:



868
869
870
871
872
873
874
875
876
877
878
879
# File 'lib/ Mongo/crypt/bounding.rb', line 868

def self.ctx_mongo_op(上下文)
  二进制文件 = 二进制文件.new

  check_ctx_status(上下文) do
    mongocrypt_ctx_mongo_op(上下文.ctx_p, 二进制文件.ref)
  end

  # TODO,因为二进制文件引用了C指针,而 ByteBuffer 是
  # 在 MRI 中用 C 语言编写,我们可以省略数据副本,方法是
  # ByteBuffer 引用 libmongocrypt 拥有的string 。
  BSON::文档.from_bson(BSON::ByteBuffer.new(二进制文件.to_s), 模式: :bson)
end

.ctx_next_kms_ctx(context) ⇒ Mongo::Crypt::KmsContext | nil

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

返回 Context对象所需的新 KmsContext对象。

参数:

返回:

  • ( Mongo::Crypt::KmsContext | nil )

    获取Amazon Web Services主密钥所需的 KmsContext;如果不需要 KmsContext,则返回 nil



929
930
931
932
933
934
935
936
937
# File 'lib/ Mongo/crypt/bounding.rb', line 929

def self.ctx_next_kms_ctx(上下文)
  kms_ctx_p = mongocrypt_ctx_next_kms_ctx(上下文.ctx_p)

  if kms_ctx_p.null?
    nil
  else
    KmsContext.new(kms_ctx_p)
  end
end

ctx_provide_kms_providers (context, kms_providers) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

为响应 MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS 状态而调用,以设立每个上下文的KMS提供商设置。 它们遵循与“mongocrypt_setopt_kms_providers”相同的格式。 如果BSON输入中不存在密钥,则使用初始化时为 mongocrypt_t 配置的KMS提供商设置。

参数:

  • 上下文 ( Mongo::Crypt::Context )

    加密上下文。

  • kms_providers ( BSON::Document )

    将KMS提供商名称映射到凭证的BSON文档。

引发:



1687
1688
1689
1690
1691
1692
1693
1694
1695
# File 'lib/ Mongo/crypt/bounding.rb', line 1687

def self.ctx_provide_kms_providers(上下文, kms_providers)
  validate_document(kms_providers)
  数据 = kms_providers.to_bson.to_s
  二进制文件.wrapp_string(数据) do |data_p|
    check_ctx_status(上下文) do
      mongocrypt_ctx_provide_kms_providers(上下文.ctx_p, data_p)
    end
  end
end

ctx_rewrap_many_datakey_init (context, 过滤) ⇒ Boolean

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

初始化上下文以重新包装数据键。

参数:

  • 上下文 ( Mongo::Crypt::Context )
  • 筛选器 ( BSON::Document )

    BSON文档,表示过滤,用于在密钥保管库集合上执行查找命令,以检索要重新包装的数据密钥。

返回:

  • ( Boolean )

    初始化是否成功。



656
657
658
659
660
661
662
663
# File 'lib/ Mongo/crypt/bounding.rb', line 656

def self.ctx_rewrap_many_datakey_init(上下文, 筛选器)
  filter_data = 筛选器.to_bson.to_s
  二进制文件.wrapp_string(filter_data) do |data_p|
    check_ctx_status(上下文) do
      mongocrypt_ctx_rewrap_many_datakey_init(上下文.ctx_p, data_p)
    end
  end
end

ctx_setopt_algorithm (context, name) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

根据上下文设置算法

参数:

  • 上下文 ( Mongo::Crypt::Context )
  • 名称 ( string )

    算法名称。 有效值为:

    • “AEAD_AES_ 256 _CBC_HMAC_SHA_ 512 -Deterministic”

    • “AEAD_AES_ 256 _CBC_HMAC_SHA_ 512 -Random”

引发:



569
570
571
572
573
# File 'lib/ Mongo/crypt/bounding.rb', line 569

def self.ctx_setopt_algorithm(上下文, 名称)
  check_ctx_status(上下文) do
    mongocrypt_ctx_setopt_algorithm(上下文.ctx_p, 名称, -1)
  end
end

ctx_setopt_algorithm_range (context, opts) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

范围算法仅处于实验阶段。 它不适用于

设置使用“范围”算法进行显式加密的选项。

公共使用。

参数:

引发:



1794
1795
1796
1797
1798
1799
1800
1801
1802
# File 'lib/ Mongo/crypt/bounding.rb', line 1794

def self.ctx_setopt_algorithm_range(上下文, opts)
  validate_document(opts)
  数据 = opts.to_bson.to_s
  二进制文件.wrapp_string(数据) do |data_p|
    check_ctx_status(上下文) do
      mongocrypt_ctx_setopt_algorithm_range(上下文.ctx_p, data_p)
    end
  end
end

ctx_setopt_contention_factor (context,factor) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

设置用于显式加密的争用因子。 争用因子仅用于索引式 FLE 2加密。

参数:

  • 上下文 ( Mongo::Crypt::Context )

    显式加密上下文。

  • 因素 ( Integer )

    用于显式加密的争用因子。

引发:



1757
1758
1759
1760
1761
# File 'lib/ Mongo/crypt/bounding.rb', line 1757

def self.ctx_setopt_contention_factor(上下文, 因素)
  check_ctx_status(上下文) do
    mongocrypt_ctx_setopt_contention_factor(上下文.ctx_p, 因素)
  end
end

ctx_setopt_key_alt_names (context, key_alt_names) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

在创建数据密钥时设置多个备用密钥名称

参数:

  • 上下文 ( Mongo::Crypt::Context )

    DataKeyContext

  • key_alt_names ( Array )

    字符串形式的备用键名称数组

引发:



500
501
502
503
504
505
506
507
508
509
510
# File 'lib/ Mongo/crypt/bounding.rb', line 500

def self.ctx_setopt_key_alt_names(上下文, key_alt_names)
  key_alt_names. do |key_alt_name|
    key_alt_name_bson = { :keyAltName => key_alt_name }.to_bson.to_s

    二进制文件.wrapp_string(key_alt_name_bson) do |key_alt_name_p|
      check_ctx_status(上下文) do
        mongocrypt_ctx_setopt_key_alt_name(上下文.ctx_p, key_alt_name_p)
      end
    end
  end
end

ctx_setopt_key_encryption_key (context, key_document) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

设置用于创建数据密钥的密钥加密密钥文档。

参数:

  • 上下文 ( Mongo::Crypt::Context )
  • key_document ( BSON::Document )

    BSON文档,表示带有附加“提供商”字段的密钥加密密钥文档。

引发:



598
599
600
601
602
603
604
605
606
# File 'lib/ Mongo/crypt/bounding.rb', line 598

def self.ctx_setopt_key_encryption_key(上下文, key_document)
  validate_document(key_document)
  数据 = key_document.to_bson.to_s
  二进制文件.wrapp_string(数据) do |data_p|
    check_ctx_status(上下文) do
      mongocrypt_ctx_setopt_key_encryption_key(上下文.ctx_p, data_p)
    end
  end
end

.ctx_setopt_key_id(context, key_id) ⇒ Object

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

在显式加密上下文中设置密钥 ID 选项。

参数:

引发:



467
468
469
470
471
472
473
# File 'lib/ Mongo/crypt/bounding.rb', line 467

def self.ctx_setopt_key_id(上下文, key_id)
  二进制文件.wrapp_string(key_id) do |key_id_p|
    check_ctx_status(上下文) do
      mongocrypt_ctx_setopt_key_id(上下文.ctx_p, key_id_p)
    end
  end
end

ctx_setopt_key_material (context, key_material) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

设立自定义密钥材料以用于

encrypting data.

参数:

  • 上下文 ( Mongo::Crypt::Context )

    DataKeyContext

  • key_material ( BSON::Binary )

    96字节的自定义密钥材料

引发:



535
536
537
538
539
540
541
542
# File 'lib/ Mongo/crypt/bounding.rb', line 535

def self.ctx_setopt_key_material(上下文, key_material)
  数据 = {' keyMaterial ' => key_material}.to_bson.to_s
  二进制文件.wrapp_string(数据) do |data_p|
    check_ctx_status(上下文) do
      mongocrypt_ctx_setopt_key_material(上下文.ctx_p, data_p)
    end
  end
end

ctx_setopt_query_type (context, query_type) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

设置用于 FLE 2显式加密的查询类型。 查询类型仅用于索引 FLE 2加密。

参数:

  • 上下文 ( Mongo::Crypt::Context )

    显式加密上下文。

  • :mongocrypt_query_type ( string )

    query_type 查询的类型。

引发:



1725
1726
1727
1728
1729
# File 'lib/ Mongo/crypt/bounding.rb', line 1725

def self.ctx_setopt_query_type(上下文, query_type)
  check_ctx_status(上下文) do
    mongocrypt_ctx_setopt_query_type(上下文.ctx_p, query_type, -1)
  end
end

get_binary_data_direct (mongocrypt_binary_t) ⇒ 对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



181
182
183
# File 'lib/ Mongo/crypt/bounding.rb', line 181

def self.get_binary_data_direct(mongocrypt_binary_t)
  mongocrypt_binary_t.get_pointer(0)
end

get_binary_len_direct (mongocrypt_binary_t) ⇒ 对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



185
186
187
# File 'lib/ Mongo/crypt/bounding.rb', line 185

def self.get_binary_len_direct(mongocrypt_binary_t)
  mongocrypt_binary_t.get_uint32(FFI::NativeType::POINTER.size)
end

init (处理) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

初始化 Mongo::Crypt::Handle对象

参数:

引发:



407
408
409
410
411
# File 'lib/ Mongo/crypt/bounding.rb', line 407

def self.init(处理)
  check_status(处理) do
    mongocrypt_init(处理.ref)
  end
end

kms_ctx_bytes_needed (kms_context) ⇒整数

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

获取 KmsContext 所需的字节数。

参数:

返回:

  • ( Integer )

    所需字节数



1063
1064
1065
# File 'lib/ Mongo/crypt/bounding.rb', line 1063

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

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

获取通过 TLS 连接的主机名,以获取有关Amazon Web Services主密钥的信息。

参数:

返回:

  • ( string | nil )

    主机名;如果不存在,则为 nil

引发:



1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
# File 'lib/ Mongo/crypt/bounding.rb', line 1039

def self.kms_ctx_endpoint(kms_context)
  ptr = FFI::内存指针.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_fail (kms_context) ⇒ true , false

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

检查是否可以重试上次失败的KMS上下文请求。

参数:

返回:

  • ( true , false )

    是否可以重试失败的请求。



1148
1149
1150
# File 'lib/ Mongo/crypt/bounding.rb', line 1148

def self.kms_ctx_fail(kms_context)
  mongocrypt_kms_ctx_fail(kms_context.kms_ctx_p)
end

kms_ctx_feed (kms_context, bytes) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

将KMS的回复反馈回 libmongocrypt。

参数:

引发:



1083
1084
1085
1086
1087
1088
1089
# File 'lib/ Mongo/crypt/bounding.rb', line 1083

def self.kms_ctx_feed(kms_context, 字节)
  check_kms_ctx_status(kms_context) do
    二进制文件.wrapp_string(字节) do |bytes_p|
      mongocrypt_kms_ctx_feed(kms_context.kms_ctx_p, bytes_p)
    end
  end
end

kms_ctx_get_kms_provider (kms_context) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

获取与此KMS请求关联的KMS提供商标识符。

用于根据KMS请求有条件地配置 TLS 连接。 它对于 KMIP 非常有用,因为它使用客户端证书进行身份验证。

参数:

  • KMS ( FFI::Pointer )

    指针 mongocrypt_kms_ctx_t对象。



970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
# File 'lib/ Mongo/crypt/bounding.rb', line 970

def self.kms_ctx_get_kms_provider(kms_context)
  len_ptr = FFI::内存指针.new(:uint 32, 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实施没有“read(type)”方法,但它
      # 有这个 `get_uint 32 `。
      len_ptr.get_uint32
    else
      # 对于 MRI,我们使用已记录的“读取”方法 - http://www.Rubydoc.info/github/ffi/ffi/FFI% 2 FPointer:read
      len_ptr.(:uint 32)
    end
    provider.read_string(len).to_sym
  end
end

kms_ctx_message (kms_context) ⇒ string

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

HTTP获取从Amazon Web ServicesKMS KmsContext对象获取 主密钥所需的 消息。

参数:

返回:

  • ( string )

    HTTP 消息

引发:



1010
1011
1012
1013
1014
1015
1016
1017
1018
# File 'lib/ Mongo/crypt/bounding.rb', line 1010

def self.kms_ctx_message(kms_context)
  二进制文件 = 二进制文件.new

  check_kms_ctx_status(kms_context) do
    mongocrypt_kms_ctx_message(kms_context.kms_ctx_p, 二进制文件.ref)
  end

  return 二进制文件.to_s
end

.kms_ctx_setopt_retry_kms(handle, value) ⇒ true, fale

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

启用或禁用KMS重试行为。

参数:

返回:

  • (true, fale)

    true 表示已设立该选项,否则为 false。



1167
1168
1169
# File 'lib/ Mongo/crypt/bounding.rb', line 1167

def self.kms_ctx_setopt_retry_kms(处理, )
  mongocrypt_setopt_retry_kms(处理.ref, )
end

.kms_ctx_usleep(kms_context) ⇒ Integer

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

返回在为给定KMS上下文发送KMS请求之前处于休眠状态的毫秒数。

参数:

返回:

  • ( Integer )

    64 位编码的休眠微秒数。



1131
1132
1133
# File 'lib/ Mongo/crypt/bounding.rb', line 1131

def self.kms_ctx_usleep(kms_context)
  mongocrypt_kms_ctx_usleep(kms_context.kms_ctx_p)
end

mongocrypt_binary_data (binary) ⇒ FFI::Pointer

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

获取指向 mongocrypt_binary_t根本的数据的指针。

参数:

  • 二进制文件 ( FFI::Pointer )

    指向 mongocrypt_binary_t对象的指针。

返回:

  • ( FFI::Pointer )

    指向数据大量的指针。



171
# File 'lib/ Mongo/crypt/bounding.rb', line 171

附加函数 :mongocrypt_binary_data, [:pointer], :pointer

mongocrypt_binary_destroy (binary) ⇒ nil

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

销毁 mongocrypt_binary_t对象。

参数:

  • 二进制文件 ( FFI::Pointer )

    指向 mongocrypt_binary_t对象的指针。

返回:

  • ( nil )

    始终为零。



195
# File 'lib/ Mongo/crypt/bounding.rb', line 195

附加函数 :mongocrypt_binary_destroy, [:pointer], :void

mongocrypt_binary_len (binary) ⇒整数

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

获取基础数据数组的长度。

参数:

  • 二进制文件 ( FFI::Pointer )

    指向 mongocrypt_binary_t对象的指针。

返回:

  • ( Integer )

    数据数组的长度。



179
# File 'lib/ Mongo/crypt/bounding.rb', line 179

附加函数 :mongocrypt_binary_len, [:pointer], :int

mongocrypt_binary_newFFI::Pointer

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

创建一个新的 mongocrypt_binary_t对象(字节的非拥有视图)

array).

返回:

  • ( FFI::Pointer )

    指向新创建的 mongocrypt_binary_t对象的指针。



147
# File 'lib/ Mongo/crypt/bounding.rb', line 147

附加函数 :mongocrypt_binary_new, [], :pointer

mongocrypt_binary_new_from_data (data, len) ⇒ FFI::Pointer

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

创建一个新的 mongocrypt_binary_t 对象,该对象维护一个指向

the specified byte array.

参数:

  • 数据 ( FFI::Pointer )

    指向字节大量的指针;不会复制数据,且数据的寿命必须比 mongocrypt_binary_t对象的寿命长。

  • len ( Integer )

    大量参数的长度。

返回:

  • ( FFI::Pointer )

    指向新创建的 mongocrypt_binary_t对象的指针。



159
160
161
162
163
# File 'lib/ Mongo/crypt/bounding.rb', line 159

附加函数(
  :mongocrypt_binary_new_from_data,
  [:pointer, :int],
  :pointer
)

mongocrypt_crypt_shared_lib_version (crypt) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



1592
1593
1594
1595
1596
# File 'lib/ Mongo/crypt/bounding.rb', line 1592

附加函数(
  :mongocrypt_crypt_shared_lib_version,
  [ :pointer ],
  :uint 64
)

mongocrypt_ctx_datakey_init (ctx, filter) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



618
# File 'lib/ Mongo/crypt/bounding.rb', line 618

附加函数 :mongocrypt_ctx_datakey_init, [:pointer], :bool

.mongocrypt_ctx_decrypt_init(ctx, doc) ⇒ Boolean

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

初始化 ctx 以进行自动解密。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • doc ( FFI::Pointer )

    指向 mongocrypt_binary_t对象的指针,该对象引用要解密为BSON二进制string的文档。

返回:

  • ( Boolean )

    初始化是否成功。



778
# File 'lib/ Mongo/crypt/bounding.rb', line 778

附加函数 :mongocrypt_ctx_decrypt_init, [:pointer, :pointer], :bool

mongocrypt_ctx_destroy (ctx) ⇒ nil

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

销毁对 mongocrypt_ctx_t对象的引用。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

返回:

  • ( nil )

    始终为零。



1228
# File 'lib/ Mongo/crypt/bounding.rb', line 1228

附加函数 :mongocrypt_ctx_destroy, [:pointer], :void

.mongocrypt_ctx_encrypt_init(ctx, db, db_len, cmd) ⇒ Boolean

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

此方法要求传入的BSON采用以下格式:{ “v”: 要解密的BSON值 }。

初始化 ctx 以进行自动加密。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • db ( string )

    数据库名称。

  • db_len ( Integer )

    数据库名称参数的长度(或 -1,表示以 null 结尾的string )。

  • cmd ( FFI::Pointer )

    指向 mongocrypt_binary_t对象的指针,该对象将数据库命令作为二进制string引用。

返回:

  • ( Boolean )

    初始化是否成功。



678
679
680
681
682
# File 'lib/ Mongo/crypt/bounding.rb', line 678

附加函数(
  :mongocrypt_ctx_encrypt_init,
  [:pointer, : 细绳, :int, :pointer],
  :bool
)

.mongocrypt_ctx_explicit_decrypt_init(ctx, msg) ⇒ Boolean

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

为显式解密初始化 ctx。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • msg ( FFI::Pointer )

    指向 mongocrypt_binary_t对象的指针,该对象引用要解密为BSON二进制string的消息。

返回:

  • ( Boolean )

    初始化是否成功。



804
805
806
807
808
# File 'lib/ Mongo/crypt/bounding.rb', line 804

附加函数(
  :mongocrypt_ctx_explicit_decrypt_init,
  [:pointer, :pointer],
  :bool
)

.mongocrypt_ctx_explicit_encrypt_init(ctx, msg) ⇒ Boolean

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

在调用该方法之前,请使用以下方法设立key_id、key_alt_name(可选)和加密算法:mongocrypt_ctx_setopt_key_id、mongocrypt_ctx_setopt_key_alt_name 和 mongocrypt_ctx_setopt_algorithm。

为显式表达式加密初始化 ctx。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • msg ( FFI::Pointer )

    指向 mongocrypt_binary_t对象的指针,该对象以二进制string形式引用要加密的消息。

返回:

  • ( Boolean )

    初始化是否成功。



714
715
716
717
718
# File 'lib/ Mongo/crypt/bounding.rb', line 714

附加函数(
  :mongocrypt_ctx_explicit_encrypt_init,
  [:pointer, :pointer],
  :bool
)

mongocrypt_ctx_finalize (ctx, op_bson) ⇒布尔值

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

执行最终的加密或解密,并返回BSON文档。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • op_bson ( FFI::Pointer )

    (输出参数)指向 mongocrypt_binary_t对象的指针,该对象将引用最终加密的BSON文档。

返回:

  • ( Boolean )

    指示操作成功的布尔值。



1201
# File 'lib/ Mongo/crypt/bounding.rb', line 1201

附加函数 :mongocrypt_ctx_finalize, [:pointer, :pointer], :void

.mongocrypt_ctx_mongo_done(ctx) ⇒ Boolean

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

指示 libmongocrypt驾驶员已完成提供回复。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

返回:

  • ( Boolean )

    指示操作成功的布尔值。



913
# File 'lib/ Mongo/crypt/bounding.rb', line 913

附加函数 :mongocrypt_ctx_mongo_done, [:pointer], :bool

mongocrypt_ctx_mongo_feed (ctx,reply) ⇒布尔值

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

将BSON回复发送给 libmongocrypt。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • 回复 ( FFI::Pointer )

    一个 mongocrypt_binary_t对象,用于引用对 libmongocrypt 源的BSON回复。

返回:

  • ( Boolean )

    指示操作成功的布尔值。



889
# File 'lib/ Mongo/crypt/bounding.rb', line 889

附加函数 :mongocrypt_ctx_mongo_feed, [:pointer, :pointer], :bool

mongocrypt_ctx_mongo_next_kms_ctx (ctx) ⇒ FFI::Pointer

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

返回指向 mongocrypt_kms_ctx_t对象的指针或 NULL。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

返回:

  • ( FFI::Pointer )

    指向 mongocrypt_kms_ctx_t对象的指针。



921
# File 'lib/ Mongo/crypt/bounding.rb', line 921

附加函数 :mongocrypt_ctx_next_kms_ctx, [:pointer], :pointer

mongocrypt_ctx_mongo_op (ctx, op_bson) ⇒布尔值

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

获取驾驶员的BSON操作以针对MongoDB运行

collection, the key vault database, or mongocryptd.

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • op_bson ( FFI::Pointer )

    (输出参数)指向 mongocrypt_binary_t对象的指针,该对象将引用 libmongocrypt 写入的BSON操作。

返回:

  • ( Boolean )

    指示操作成功的布尔值。



857
# File 'lib/ Mongo/crypt/bounding.rb', line 857

附加函数 :mongocrypt_ctx_mongo_op, [:pointer, :pointer], :bool

mongocrypt_ctx_new (crypt) ⇒ FFI::Pointer

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

创建一个新的 mongocrypt_ctx_t对象(libmongocrypt

state machine).

参数:

  • crypt ( FFI::Pointer )

    指向 mongocrypt_t 对象的指针。

返回:

  • ( FFI::Pointer )

    一个新的 mongocrypt_ctx_t 对象。



第 438 章
# File 'lib/ Mongo/crypt/bounding.rb', line 438

附加函数 :mongocrypt_ctx_new, [:pointer], :pointer

mongocrypt_ctx_provide_kms_providers (ctx, kms_providers) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



1670
1671
1672
1673
1674
# File 'lib/ Mongo/crypt/bounding.rb', line 1670

附加函数(
  :mongocrypt_ctx_provide_kms_providers,
  [ :pointer, :pointer ],
  :bool
)

mongocrypt_ctx_setopt_algorithm (ctx, 算法, len) ⇒ Boolean

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

在调用此方法之前,请勿初始化 ctx。

设置用于显式加密的算法。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • 算法 ( string )

    算法名称。 有效值为:

    • “AEAD_AES_ 256 _CBC_HMAC_SHA_ 512 -Deterministic”

    • “AEAD_AES_ 256 _CBC_HMAC_SHA_ 512 -Random”

  • len ( Integer )

    算法string的长度。

返回:

  • ( Boolean )

    是否已成功设立该选项。



555
556
557
558
559
# File 'lib/ Mongo/crypt/bounding.rb', line 555

附加函数(
  :mongocrypt_ctx_setopt_algorithm,
  [:pointer, : 细绳, :int],
  :bool
)

mongocrypt_ctx_setopt_algorithm_range (ctx, opts) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



1776
1777
1778
1779
1780
1781
1782
1783
# File 'lib/ Mongo/crypt/bounding.rb', line 1776

附加函数(
  :mongocrypt_ctx_setopt_algorithm_range,
  [
    :pointer,
    :pointer
  ],
  :bool
)

mongocrypt_ctx_setopt_contention_factor (ctx,contention_factor) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



1741
1742
1743
1744
1745
1746
1747
1748
# File 'lib/ Mongo/crypt/bounding.rb', line 1741

附加函数(
  :mongocrypt_ctx_setopt_contention_factor,
  [
    :pointer,
    :int 64
  ],
  :bool
)

mongocrypt_ctx_setopt_key_alt_name (ctx, binary) ⇒ Boolean

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

在调用此方法之前,请勿初始化 ctx。

创建数据密钥时,请为该密钥设立备用名称。 何时

performing explicit encryption, specifying which data key to use for
encryption based on its keyAltName field.

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • 二进制文件 ( FFI::Pointer )

    指向 mongocrypt_binary_t对象的指针,该对象引用 { “keyAltName”: < BSON UTF 8 value> } 格式的BSON文档。

返回:

  • ( Boolean )

    是否已成功设立备用名称。



487
488
489
490
491
# File 'lib/ Mongo/crypt/bounding.rb', line 487

附加函数(
  :mongocrypt_ctx_setopt_key_alt_name,
  [:pointer, :pointer],
  :bool
)

mongocrypt_ctx_setopt_key_encryption_key (ctx) ⇒布尔值

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

在调用此方法之前,请勿初始化 ctx。

设置用于创建数据密钥的密钥加密密钥文档。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • bin ( FFI::Pointer )

    指向 mongocrypt_binary_t对象的指针,该对象引用表示密钥加密密钥文档的BSON文档以及附加的“提供商”字段。

返回:

  • ( Boolean )

    是否已成功设立该选项。



585
586
587
588
589
# File 'lib/ Mongo/crypt/bounding.rb', line 585

附加函数(
  :mongocrypt_ctx_setopt_key_encryption_key,
  [:pointer, :pointer],
  :bool
)

.mongocrypt_ctx_setopt_key_id(ctx, key_id) ⇒ Boolean

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

在调用此方法之前,请勿初始化 ctx。

设置用于显式加密的密钥 ID。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • key_id ( FFI::Pointer )

    指向引用16字节密钥 ID 的 mongocrypt_binary_t对象的指针。

返回:

  • ( Boolean )

    是否已成功设立该选项。



第 459 章
# File 'lib/ Mongo/crypt/bounding.rb', line 459

附加函数 :mongocrypt_ctx_setopt_key_id, [:pointer, :pointer], :bool

mongocrypt_ctx_setopt_key_material (ctx, binary) ⇒ Boolean

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

在调用此方法之前,请勿初始化 ctx。

创建数据密钥材料时,设立要用于

encrypting data.

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • 二进制文件 ( FFI::Pointer )

    指向 mongocrypt_binary_t对象的指针,该对象引用要使用的数据加密密钥。

返回:

  • ( Boolean )

    是否已成功设置自定义密钥材料。



522
523
524
525
526
# File 'lib/ Mongo/crypt/bounding.rb', line 522

附加函数(
  :mongocrypt_ctx_setopt_key_material,
  [:pointer, :pointer],
  :bool
)

mongocrypt_ctx_setopt_query_type (ctx, mongocrypt_query_type) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



1708
1709
1710
1711
1712
1713
1714
1715
1716
# File 'lib/ Mongo/crypt/bounding.rb', line 1708

附加函数(
  :mongocrypt_ctx_setopt_query_type,
  [
    :pointer,
    : 细绳,
    :int
  ],
  :bool
)

mongocrypt_ctx_state (ctx) ⇒符号

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

获取 ctx 的当前状态。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

返回:

  • (符号)

    当前状态将是 mongocrypt_ctx_state 枚举定义的值之一。



845
# File 'lib/ Mongo/crypt/bounding.rb', line 845

附加函数 :mongocrypt_ctx_state, [:pointer], :mongocrypt_ctx_state

mongocrypt_ctx_status (ctx, status) ⇒ Boolean

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

设置来自 mongocrypt_ctx_t对象的状态信息

mongocrypt_status_t object.

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t对象的指针。

返回:

  • ( Boolean )

    状态是否已成功设置。



第 448 章
# File 'lib/ Mongo/crypt/bounding.rb', line 448

附加函数 :mongocrypt_ctx_status, [:pointer, :pointer], :bool

mongocrypt_destroy (crypt) ⇒ nil

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

销毁对 mongocrypt_t 对象的引用。

参数:

  • crypt ( FFI::Pointer )

    指向 mongocrypt_t 对象的指针。

返回:

  • ( nil )

    始终为零。



429
# File 'lib/ Mongo/crypt/bounding.rb', line 429

附加函数 :mongocrypt_destroy, [:pointer], :void

mongocrypt_init (crypt) ⇒布尔值

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

初始化 mongocrypt_t对象。

参数:

  • crypt ( FFI::Pointer )

    指向 mongocrypt_t 对象的指针。

返回:

  • ( Boolean )

    返回 crypt 是否已成功初始化。



400
# File 'lib/ Mongo/crypt/bounding.rb', line 400

附加函数 :mongocrypt_init, [:pointer], :bool

mongocrypt_kms_ctx_bytes_needed ( KMS ) ⇒整数

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

获取KMS上下文所需的字节数。

参数:

  • KMS ( FFI::Pointer )

    mongocrypt_kms_ctx_t对象。

返回:

  • ( Integer )

    所需的字节数。



1056
# File 'lib/ Mongo/crypt/bounding.rb', line 1056

附加函数 :mongocrypt_kms_ctx_bytes_needed, [:pointer], :int

.mongocrypt_kms_ctx_done(ctx) ⇒ Boolean

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

向 libmongocrypt 指示它将不再收到以下回复:

mongocrypt_kms_ctx_t objects.

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

返回:

  • ( Boolean )

    操作是否成功。



1179
# File 'lib/ Mongo/crypt/bounding.rb', line 1179

附加函数 :mongocrypt_ctx_kms_done, [:pointer], :bool

mongocrypt_kms_ctx_endpoint ( KMS , endpoint) ⇒ Boolean

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

获取通过 TLS 连接的主机名,以获取以下内容的信息:

the AWS master key.

参数:

  • KMS ( FFI::Pointer )

    指向 mongocrypt_kms_ctx_t对象的指针。

  • 端点 ( FFI::Pointer )

    (输出参数)libmongocrypt 将写入端点string的指针。

返回:

  • ( Boolean )

    操作是否成功。



1029
# File 'lib/ Mongo/crypt/bounding.rb', line 1029

附加函数 :mongocrypt_kms_ctx_endpoint, [:pointer, :pointer], :bool

.mongocrypt_kms_ctx_fail(ctx) ⇒ Object

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



1142
# File 'lib/ Mongo/crypt/bounding.rb', line 1142

附加函数 :mongocrypt_kms_ctx_fail, [:pointer], :bool

mongocrypt_kms_ctx_feed ( KMS , bytes) ⇒布尔值

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

将KMS的回复反馈回 libmongocrypt。

参数:

  • KMS ( FFI::Pointer )

    指向 mongocrypt_kms_ctx_t 对象的指针。

  • 字节 ( FFI::Pointer )

    指向 mongocrypt_binary_t 对象的指针,该对象引用来自 KMS 的响应。

返回:

  • ( Boolean )

    操作是否成功。



1075
# File 'lib/ Mongo/crypt/bounding.rb', line 1075

附加函数 :mongocrypt_kms_ctx_feed, [:pointer, :pointer], :bool

mongocrypt_kms_ctx_get_kms_provider (crypt, kms_providers) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



955
956
957
958
959
# File 'lib/ Mongo/crypt/bounding.rb', line 955

附加函数(
  :mongocrypt_kms_ctx_get_kms_provider,
  [:pointer, :pointer],
  :pointer
)

mongocrypt_kms_ctx_message ( KMS , msg) ⇒布尔值

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

获取获取Amazon Web Services KMS主密钥所需的消息。

参数:

  • KMS ( FFI::Pointer )

    指向 mongocrypt_kms_ctx_t 对象的指针

  • msg ( FFI::Pointer )

    (outparam) 指向 mongocrypt_binary_t对象的指针,libmongocrypt 写入该对象的消息位置将位于该对象中。

返回:

  • ( Boolean )

    操作是否成功。



1000
# File 'lib/ Mongo/crypt/bounding.rb', line 1000

附加函数 :mongocrypt_kms_ctx_message, [:pointer, :pointer], :bool

mongocrypt_kms_ctx_status ( KMS , status) ⇒布尔值

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

写入有关 mongocrypt_kms_ctx_t对象的状态信息

to the mongocrypt_status_t object.

参数:

  • KMS ( FFI::Pointer )

    指向 mongocrypt_kms_ctx_t 对象的指针。

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t对象的指针。

返回:

  • ( Boolean )

    操作是否成功。



1099
# File 'lib/ Mongo/crypt/bounding.rb', line 1099

附加函数 :mongocrypt_kms_ctx_status, [:pointer, :pointer], :bool

.mongocrypt_kms_ctx_usleep(ctx) ⇒ int64

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

指示发送KMS请求之前的休眠时间。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

返回:

  • ( int64 )

    休眠时长的 64 位编码微秒数。



1123
# File 'lib/ Mongo/crypt/bounding.rb', line 1123

附加函数 :mongocrypt_kms_ctx_usleep, [:pointer], :int 64

mongocrypt_setopt_aes_ 256 _ctr (crypt, aes_ 256 _ctr_encrypt, aes_ 256 _ctr_decrypt, ctx) ⇒布尔值

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

为 AES 256 -CTR 操作设置加密钩子。

参数:

  • crypt ( FFI::Pointer )

    指向 mongocrypt_t 对象的指针。

  • aes_enc_fn ( Proc )

    一种 AES-CTR加密方法。

  • aes_dec_fn ( Proc )

    一种 AES-CTR 解密方法。

  • ctx ( FFI::Pointer | nil )

    指向上下文对象的可选指针,启用钩子时可能已设立该对象。

返回:

  • ( Boolean )

    是否成功设置此选项。



1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
# File 'lib/ Mongo/crypt/bounding.rb', line 1487

附加函数(
  :mongocrypt_setopt_aes_256_ctr,
  [
    :pointer,
    :mongocrypt_crypto_fn,
    :mongocrypt_crypto_fn,
    :pointer
  ],
  :bool
)

mongocrypt_setopt_append_crypt_shared_lib_search_path (crypt, path) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



1525
1526
1527
1528
1529
1530
1531
1532
# File 'lib/ Mongo/crypt/bounding.rb', line 1525

附加函数(
  :mongocrypt_setopt_append_crypt_shared_lib_search_path,
  [
    :pointer,
    : 细绳,
  ],
  :void
)

mongocrypt_setopt_bypass_query_analysis (crypt) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



1463
# File 'lib/ Mongo/crypt/bounding.rb', line 1463

附加函数(:mongocrypt_setopt_bypass_query_analysis, [:pointer], :void)

mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs 1 _v 1 _ 5 (crypt, sign_rsaes_pkcs 1 _v 1 _ 5 , ctx = nil) ⇒布尔值

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

使用 SHA- 256哈希为 RSASSA-PKCS 1 -v 1 _ 5算法设置加密钩子。

参数:

  • crypt ( FFI::Pointer )

    指向 mongocrypt_t 对象的指针。

  • sign_rsaes_pkcs 1 _v 1 _ 5 ( Proc )

    RSASSA-PKCS 1 -v 1 _ 5签名方法。

  • ctx ( FFI::Pointer | nil ) (默认为: nil

    指向上下文对象的可选指针,启用钩子时可能已设立该对象。

返回:

  • ( Boolean )

    是否成功设置此选项。



1380
1381
1382
1383
1384
1385
1386
1387
1388
# File 'lib/ Mongo/crypt/bounding.rb', line 1380

附加函数(
  :mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs 1 _v 1 _ 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

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

在提供的 mongocrypt对象上设置加密钩子。

参数:

  • crypt ( FFI::Pointer )

    指向 mongocrypt_t 对象的指针。

  • aes_enc_fn ( Proc )

    一种 AES加密方法。

  • aes_dec_fn ( Proc )

    一种 AES 解密方法。

  • random_fn ( Proc )

    一种随机方法。

  • sha_ 512 _fn ( Proc )

    HMAC SHA- 512方法。

  • sha_ 256 _fn ( Proc )

    HMAC SHA- 256方法。

  • hash_fn ( Proc )

    SHA- 256哈希方法。

  • ctx ( FFI::Pointer | nil ) (默认为: nil

    指向上下文对象的可选指针,启用钩子时可能已设立该对象。

返回:

  • ( Boolean )

    是否成功设置此选项。



1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
# File 'lib/ Mongo/crypt/bounding.rb', line 1333

附加函数(
  :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) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



1422
1423
1424
1425
1426
1427
1428
1429
# File 'lib/ Mongo/crypt/bounding.rb', line 1422

附加函数(
  :mongocrypt_setopt_encrypted_field_config_map,
  [
    :pointer,
    :pointer
  ],
  :bool
)

mongocrypt_setopt_kms_providers (crypt, kms_providers) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

在调用此方法之前,请勿初始化 ctx。

使用BSON文档配置KMS提供商。

参数:

  • crypt ( FFI::Pointer )

    指向 mongocrypt_t 对象的指针。

  • kms_providers ( FFI::Pointer )

    指向 mongocrypt_binary_t 对象的指针,该对象引用将 KMS 提供程序名称映射到凭证的 BSON 文档。



344
345
346
347
348
# File 'lib/ Mongo/crypt/bounding.rb', line 344

附加函数(
  :mongocrypt_setopt_kms_providers,
  [:pointer, :pointer],
  :bool
)

mongocrypt_setopt_log_handler (crypt, log_fn, log_ctx = nil) ⇒ Boolean

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

将 mongocrypt_t对象上的处理程序设置为

libmongocrypt logs a message.

参数:

  • crypt ( FFI::Pointer )

    指向 mongocrypt_t 对象的指针。

  • log_fn (方法)

    日志记录回调方法。

  • log_ctx ( FFI::Pointer | nil ) (默认为: nil

    指向上下文的可选指针,将在每次调用时传递到日志回调中。

返回:

  • ( Boolean )

    是否设置回调成功。



315
316
317
318
319
# File 'lib/ Mongo/crypt/bounding.rb', line 315

附加函数(
  :mongocrypt_setopt_log_handler,
  [:pointer, :mongocrypt_log_fn_t, :pointer],
  :bool
)

mongocrypt_setopt_retry_kms (crypt, 启用) ⇒ 对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



1160
# File 'lib/ Mongo/crypt/bounding.rb', line 1160

附加函数 :mongocrypt_setopt_retry_kms, [:pointer, :bool], :bool

mongocrypt_setopt_schema_map (crypt, schema_map) ⇒布尔值

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

设置用于加密的本地模式映射。

参数:

  • crypt ( FFI::Pointer )

    指向 mongocrypt_t 对象的指针。

  • schema_map ( FFI::Pointer )

    指向 mongocrypt_binary_t 的指针。对象,该对象将以BSON二进制string的形式引用模式映射。

返回:

  • ( Boolean )

    返回是否成功设立该选项。



375
# File 'lib/ Mongo/crypt/bounding.rb', line 375

附加函数 :mongocrypt_setopt_schema_map, [:pointer, :pointer], :bool

mongocrypt_setopt_set_crypt_shared_lib_path_override (crypt, path) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



1554
1555
1556
1557
1558
1559
1560
1561
# File 'lib/ Mongo/crypt/bounding.rb', line 1554

附加函数(
  :mongocrypt_setopt_set_crypt_shared_lib_path_override,
  [
    :pointer,
    : 细绳,
  ],
  :void
)

mongocrypt_setopt_use_need_kms_credentials_state (crypt) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



1633
1634
1635
1636
1637
# File 'lib/ Mongo/crypt/bounding.rb', line 1633

附加函数(
  :mongocrypt_setopt_use_need_kms_credentials_state,
  [ :pointer ],
  :void
)

mongocrypt_status (crypt, status) ⇒ Boolean

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

设置来自 mongocrypt_t对象的状态信息

mongocrypt_status_t object.

参数:

  • crypt ( FFI::Pointer )

    指向 mongocrypt_t 对象的指针。

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t对象的指针。

返回:

  • ( Boolean )

    状态是否已成功设置。



第 421 章
# File 'lib/ Mongo/crypt/bounding.rb', line 421

附加函数 :mongocrypt_status, [:pointer, :pointer], :bool

mongocrypt_status_code (status) ⇒整数

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

返回状态错误代码。

参数:

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t 的指针。

返回:

  • ( Integer )

    状态代码。



243
# File 'lib/ Mongo/crypt/bounding.rb', line 243

附加函数 :mongocrypt_status_code, [:pointer], :int

mongocrypt_status_destroy (status) ⇒ nil

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

销毁对 mongocrypt_status_t 对象的引用。

参数:

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t 的指针。

返回:

  • ( nil )

    始终为零。



269
# File 'lib/ Mongo/crypt/bounding.rb', line 269

附加函数 :mongocrypt_status_destroy, [:pointer], :void

.mongocrypt_status_message(status, len = nil) ⇒ String

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

返回状态消息。

参数:

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t 的指针。

  • len ( FFI::Pointer | nil ) (默认为: nil

    (输出参数)指向 uint32 的可选指针,返回string的长度将写入其中。

返回:

  • ( string )

    状态消息。



253
# File 'lib/ Mongo/crypt/bounding.rb', line 253

附加函数 :mongocrypt_status_message, [:pointer, :pointer], : 细绳

mongocrypt_status_newFFI::Pointer

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

创建新的 mongocrypt_status_t 对象。

返回:

  • ( FFI::Pointer )

    指向新的 mongocrypt_status_ts 的指针。



209
# File 'lib/ Mongo/crypt/bounding.rb', line 209

附加函数 :mongocrypt_status_new, [], :pointer

mongocrypt_status_ok (status) ⇒布尔值

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

返回状态是正常还是错误。

参数:

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t 的指针。

返回:

  • ( Boolean )

    状态是否正常。



261
# File 'lib/ Mongo/crypt/bounding.rb', line 261

附加函数 :mongocrypt_status_ok, [:pointer], :bool

mongocrypt_status_set (status, type, code, message, len) ⇒ nil

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

在现有状态上设置消息、类型和代码。

参数:

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t 的指针。

  • 类型 (符号)

    状态类型;可能的值由 status_type 枚举定义。

  • 代码 ( Integer )

    状态代码。

  • message ( string )

    状态消息。

  • len ( Integer )

    消息参数的长度(或 -1,表示以 null 结尾的string )。

返回:

  • ( nil )

    始终为零。



223
224
225
226
227
# File 'lib/ Mongo/crypt/bounding.rb', line 223

附加函数(
  :mongocrypt_status_set,
  [:pointer, :status_type, :int, : 细绳, :int],
  :void
)

.mongocrypt_status_type(status) ⇒ Symbol

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

指示状态类型。

参数:

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t 的指针。

返回:

  • (符号)

    状态类型(由 status_type枚举定义)。



235
# File 'lib/ Mongo/crypt/bounding.rb', line 235

附加函数 :mongocrypt_status_type, [:pointer], :status_type

mongocrypt_version (len) ⇒ string

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

返回 libmongocrypt 库的版本string 。

参数:

  • len ( FFI::Pointer | nil )

    (输出参数)指向 uint8 的可选指针,该指针将引用返回string的长度。

返回:

  • ( string )

    libmongocrypt 的版本string 。



95
# File 'lib/ Mongo/crypt/bounding.rb', line 95

附加函数 :mongocrypt_version, [:pointer], : 细绳

ongocrypt_newFFI::Pointer

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

创建新的 mongocrypt_t对象。

返回:

  • ( FFI::Pointer )

    指向新 mongocrypt_t对象的指针。



303
# File 'lib/ Mongo/crypt/bounding.rb', line 303

附加函数 :mongocrypt_new, [], :pointer

.parse_version(version) ⇒ Gem::Version

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

给定一个表示版本号的string ,将其解析为一个 Gem::Version对象。 这会通过执行一些自定义解析来处理string不是 Gem::Version 支持的格式的情况。

参数:

  • 版本 ( string )

    表示版本号的string 。

返回:

  • (Gem::Version)

    版本号

引发:

  • ( ArgumentError )

    如果无法解析string 。



108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/ Mongo/crypt/bounding.rb', line 108

def self.parse_version(版本)
  Gem::版本.new(版本)
救援 ArgumentError
  匹配 = 版本.匹配(/\A(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)?(-[A-Za-z\+\d]+)?\z/)
  提高 ArgumentError.new("格式不正确的版本号string #{ version } ") if 匹配.nil?

  Gem::版本.new(
    [
      匹配[:major],
      匹配[:minor],
      匹配[:patch]
    ].连接 (JOIN)('  ')
  )
end

setopt_aes_ 256 _ctr (处理, aes_ctr_encrypt_cb, aes_ctr_decrypt_cb) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

为 AES 256 -CTR 操作设置加密钩子。

参数:

  • 处理 ( Mongo::Crypt::Handle )
  • aes_encrypt_cb (方法)

    AES-CTR加密方法

  • aes_decrypt_cb (方法)

    一种 AES-CTR 解密方法

引发:



1505
1506
1507
1508
1509
1510
1511
# File 'lib/ Mongo/crypt/bounding.rb', line 1505

def self.setopt_aes_ 256 _ctr(处理, aes_ctr_encrypt_cb, aes_ctr_decrypt_cb)
  check_status(处理) do
    mongocrypt_setopt_aes_ 256 _ctr(处理.ref,
      aes_ctr_encrypt_cb, aes_ctr_decrypt_cb, nil
    )
  end
end

setopt_append_crypt_shared_lib_search_path (handle, path) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

将额外的Atlas Search目录附加到Atlas Search路径以进行加载

the crypt_shared dynamic library.

参数:



1539
1540
1541
1542
1543
# File 'lib/ Mongo/crypt/bounding.rb', line 1539

def self.setopt_append_crypt_shared_lib_search_path(处理, 路径)
  check_status(处理) do
    mongocrypt_setopt_append_crypt_shared_lib_search_path(处理.ref, 路径)
  end
end

setopt_bypass_query_analysis (handle) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

选择跳过查询分析。

如果选择了:

  • 不会尝试加载 csfle 共享库。

  • mongocrypt_ctx_t 永远不会进入 MONGOCRYPT_CTX_NEED_MARKINGS 状态。

参数:



1472
1473
1474
# File 'lib/ Mongo/crypt/bounding.rb', line 1472

def self.setopt_bypass_query_analysis(处理)
  mongocrypt_setopt_bypass_query_analysis(处理.ref)
end

setopt_crypto_hook_sign_rsaes_pkcs 1 _v 1 _ 5 (处理, rsaes_pkcs_signature_cb) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

为 RSASSA-PKCS 1 -v 1 _ 5算法设置加密钩子

a SHA-256 hash oh the Handle.

参数:

  • 处理 ( Mongo::Crypt::Handle )
  • rsaes_pkcs_signature_cb (方法)

    RSASSA-PKCS 1 -v 1 _ 5签名方法。

引发:



1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
# File 'lib/ Mongo/crypt/bounding.rb', line 1397

def self.setopt_crypto_hook_sign_rsaes_pkcs 1 _v 1 _ 5(
  处理,
  rsaes_pkcs_signature_cb
)
  check_status(处理) do
    mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs 1 _v 1 _ 5(
      处理.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) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

在句柄上设置加密回调

参数:

  • 处理 ( Mongo::Crypt::Handle )
  • aes_encrypt_cb (方法)

    AES加密方法

  • aes_decrypt_cb (方法)

    一种 AES 解密方法

  • random_cb (方法)

    返回随机字节string的方法

  • hmac_sha_ 512 _cb (方法)

    HMAC SHA- 512方法

  • hmac_sha_ 256 _cb (方法)

    HMAC SHA- 256方法

  • hmac_hash_cb (方法)

    SHA- 256哈希方法

引发:



1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
# File 'lib/ Mongo/crypt/bounding.rb', line 1359

def self.setopt_crypto_hooks(处理,
  aes_encrypt_cb, aes_decrypt_cb, random_cb,
  hmac_sha_ 512 _cb, hmac_sha_ 256 _cb, hmac_hash_cb
)
  check_status(处理) do
    mongocrypt_setopt_crypto_hooks(处理.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 (处理, efc_map) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

设置用于加密的本地 EncryptedFieldConfigMap。

参数:

  • 处理 ( Mongo::Crypt::Handle )
  • efc_map ( BSON::Document )

    表示用户提供的 EncryptedFieldConfigMap 的BSON文档。 键是集合命名空间,值是 EncryptedFieldConfigMap 文档。

引发:



1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
# File 'lib/ Mongo/crypt/bounding.rb', line 1440

def self.setopt_crypted_field_config_map(处理, efc_map)
  validate_document(efc_map)
  数据 = efc_map.to_bson.to_s
  二进制文件.wrapp_string(数据) do |data_p|
    check_status(处理) do
      mongocrypt_setopt_encrypted_field_config_map(
        处理.ref,
        data_p
      )
    end
  end
end

setopt_kms_providers (处理, kms_providers) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

在 Mongo::Crypt::Handle对象上设置KMS提供程序选项

参数:

  • 处理 ( Mongo::Crypt::Handle )
  • kms_providers ( BSON::Document )

    将KMS提供商名称映射到凭证的BSON文档。

引发:



357
358
359
360
361
362
363
364
365
# File 'lib/ Mongo/crypt/bounding.rb', line 357

def self.setopt_kms_providers(处理, kms_providers)
  validate_document(kms_providers)
  数据 = kms_providers.to_bson.to_s
  二进制文件.wrapp_string(数据) do |data_p|
    check_status(处理) do
      mongocrypt_setopt_kms_providers(处理.ref, data_p)
    end
  end
end

setopt_log_handler (处理, log_callback) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

在 Mongo::Crypt::Handle对象上设置记录器回调函数

参数:

引发:



327
328
329
330
331
# File 'lib/ Mongo/crypt/bounding.rb', line 327

def self.setopt_log_handler(处理, log_callback)
  check_status(处理) do
    mongocrypt_setopt_log_handler(处理, log_callback, nil)
  end
end

setopt_schema_map (处理, schema_map_doc) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

在 Mongo::Crypt::Handle对象上设置模式映射

参数:

  • 处理 ( Mongo::Crypt::Handle )
  • schema_map_doc ( BSON::Document )

    作为 BSON::Document 对象的模式映射

引发:



384
385
386
387
388
389
390
391
392
# File 'lib/ Mongo/crypt/bounding.rb', line 384

def self.setopt_schema_map(处理, schema_map_doc)
  validate_document(schema_map_doc)
  数据 = schema_map_doc.to_bson.to_s
  二进制文件.wrapp_string(数据) do |data_p|
    check_status(处理) do
      mongocrypt_setopt_schema_map(处理.ref, data_p)
    end
  end
end

setopt_set_crypt_shared_lib_path_override (handle, path) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

设置用于加载 crypt 共享库的单个覆盖路径。

参数:



1567
1568
1569
1570
1571
# File 'lib/ Mongo/crypt/bounding.rb', line 1567

def self.setopt_set_crypt_shared_lib_path_override(处理, 路径)
  check_status(处理) do
    mongocrypt_setopt_set_crypt_shared_lib_path_override(处理.ref, 路径)
  end
end

setopt_use_need_kms_credentials_state (处理) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

选择处理 MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS 状态。

如果设置,在进入 MONGOCRYPT_CTX_NEED_KMS 状态之前,上下文可能会进入 MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS 状态,然后等待通过“mongocrypt_ctx_provide_kms_providers”提供凭证。

仅当在“mongocrypt_setopt_kms_providers”中为 KMS 提供程序设置了空文档时,上下文才会进入 MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS。

参数:



1651
1652
1653
# File 'lib/ Mongo/crypt/bounding.rb', line 1651

def self.setopt_use_need_kms_credentials_state(处理)
  mongocrypt_setopt_use_need_kms_credentials_state(处理.ref)
end

.validate_document(data) ⇒ Object

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

所有BSON::Document 实例也是哈希实例

在将指定数据序列化为BSON之前检查其是否为哈希,以防止 libmongocrypt 出错

参数:

  • 数据 ( Object )

    要传递给 libmongocrypt 的数据

引发:



1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
# File 'lib/ Mongo/crypt/bounding.rb', line 1844

def self.validate_document(数据)
  return if 数据.is_a?(哈希)

  if 数据.nil?
    message = "尝试将 nil 数据传递给 libmongocrypt。 " +
      " Data must be a Hash "
  else
    message = "尝试将无效数据传递给 libmongocrypt: #{ data } " +
      " Data must be a Hash "
  end

  提高 错误::CryptError.new(message)
end

.validate_version(lmc_version) ⇒ Object

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

验证提供的 libmongocrypt 版本是否有效,即等于或大于所需的最低版本。 如果没有,则引发 LoadError。

参数:

  • lmc_version ( string )

    表示 libmongocrypt 版本的string 。

引发:

  • ( LoadError )

    如果给定版本低于所需的最低版本。



131
132
133
134
135
136
# File 'lib/ Mongo/crypt/bounding.rb', line 131

def self.validate_version(lmc_version)
  if (实际版本 = parse_version(lmc_version)) < MIN_LIBMongOCRYPT_VERSION
    提高 LoadError, "需要 libmongocrypt 版本#{ MIN_LIBMongOCRYPT_VERSION }或更高版本, " +
      但找到了版本#{ actual_version }  
  end
end

实例方法详细信息

#mongocrypt_crypto_fn(ctx, key, iv, input, output, status) ⇒ Bool

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

这定义了 FFI回调的方法签名;它不是 Binding 类的实例方法。

对执行 AES加密或解密的函数的回调。

参数:

  • ctx ( FFI::Pointer | nil )

    指向上下文对象的可选指针,启用钩子时可能已设立该对象。

  • key ( FFI::Pointer )

    指向 mongocrypt_binary_t 对象的指针,该对象引用32字节 AES 加密密钥。

  • iv ( FFI::Pointer )

    指向引用16字节 AES IV 的 mongocrypt_binary_t 对象的指针。

  • 输入 ( FFI::Pointer )

    指向 mongocrypt_binary_t对象的指针,该对象引用要加密/解密的值。

  • 输出 ( FFI::Pointer )

    (输出参数)指向 mongocrypt_binary_t对象的指针将引用 libmongocrypt 写入的加密/解密值。

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t 对象的指针,如果加密失败,将向该对象写入错误消息。

返回:

  • ( Bool )

    加密/解密是否成功。



1251
1252
1253
1254
1255
# File 'lib/ Mongo/crypt/bounding.rb', line 1251

callback(
  :mongocrypt_crypto_fn,
  [:pointer, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer],
  :bool
)

# mongocrypt_hash_fn (ctx, input, output, status) ⇒ Bool

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

这定义了 FFI回调的方法签名;它不是 Binding 类的实例方法。

对 SHA- 256哈希函数的回调。

参数:

  • ctx ( FFI::Pointer | nil )

    指向上下文对象的可选指针,启用钩子时可能已设立该对象。

  • 输入 ( FFI::Pointer )

    指向 mongocrypt_binary_t对象的指针,该对象引用要进行哈希处理的值。

  • 输出 ( FFI::Pointer )

    (输出参数)指向 mongocrypt_binary_t对象的指针将引用 libmongocrypt 写入的输出值。

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t 对象的指针,如果加密失败,将向该对象写入错误消息。

返回:

  • ( Bool )

    哈希是否成功。



1299
# File 'lib/ Mongo/crypt/bounding.rb', line 1299

callback :mongocrypt_hash_fn, [:pointer, :pointer, :pointer, :pointer], :bool

# mongocrypt_hmac_fn (ctx, key, input, output, status) ⇒ Bool

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

这定义了 FFI回调的方法签名;它不是 Binding 类的实例方法。

对执行 HMAC SHA- 512或 SHA- 256的函数的回调。

参数:

  • ctx ( FFI::Pointer | nil )

    指向上下文对象的可选指针,启用钩子时可能已设立该对象。

  • key ( FFI::Pointer )

    指向 mongocrypt_binary_t对象的指针,该对象引用32字节 HMAC SHA加密密钥。

  • 输入 ( FFI::Pointer )

    指向引用输入值的 mongocrypt_binary_t 对象的指针。

  • 输出 ( FFI::Pointer )

    (输出参数)指向 mongocrypt_binary_t对象的指针将引用 libmongocrypt 写入的输出值。

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t 对象的指针,如果加密失败,将向该对象写入错误消息。

返回:

  • ( Bool )

    HMAC-SHA 是否成功。



1276
1277
1278
1279
1280
# File 'lib/ Mongo/crypt/bounding.rb', line 1276

callback(
  :mongocrypt_hmac_fn,
  [:pointer, :pointer, :pointer, :pointer, :pointer],
  :bool
)

# mongocrypt_log_fn_t (level, message, len, ctx) ⇒ nil

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

这定义了 FFI回调的方法签名;它不是 Binding 类的实例方法。

对 mongocrypt日志函数的回调。 设置自定义日志回调

with the mongocrypt_setopt_log_handler method

参数:

  • 等级 (符号)

    日志级别;由 log_level枚举定义的可能值

  • message ( string )

    日志消息

  • len ( Integer )

    消息参数的长度,如果string以 null 结尾,则为 -1

  • ctx ( FFI::Pointer | nil )

    设立此回调时指向上下文对象的可选指针

返回:

  • ( nil )

    始终为零。



296
# File 'lib/ Mongo/crypt/bounding.rb', line 296

callback :mongocrypt_log_fn_t, [:log_level, : 细绳, :int, :pointer], :void

# mongocrypt_random_fn (ctx, output, count, status) ⇒ Bool

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

这定义了 FFI回调的方法签名;它不是 Binding 类的实例方法。

对加密安全随机函数的回调。

参数:

  • ctx ( FFI::Pointer | nil )

    指向上下文对象的可选指针,启用钩子时可能已设立该对象。

  • 输出 ( FFI::Pointer )

    (输出参数)指向 mongocrypt_binary_t对象的指针将引用 libmongocrypt 写入的输出值。

  • 数数 ( Integer )

    要返回的随机字节数。

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t 对象的指针,如果加密失败,将向该对象写入错误消息。

返回:

  • ( Bool )

    哈希是否成功。



1317
# File 'lib/ Mongo/crypt/bounding.rb', line 1317

callback :mongocrypt_random_fn, [:pointer, :pointer, :int, :pointer], :bool