类: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 )

    始终为零。



1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
# File 'lib/ Mongo/crypt/bounding.rb', line 1815

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

  return 除非 do_rise

  状态 = 状态.new

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

check_kms_ctx_status (kms_context) ⇒对象

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

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

参数:

引发:



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

def self.check_kms_ctx_status(kms_context)
  return if 产量

  状态 = 状态.new

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

check_status (处理) ⇒ nil

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

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

返回:

  • ( nil )

    始终为零。



1802
1803
1804
1805
1806
1807
1808
1809
# File 'lib/ Mongo/crypt/bounding.rb', line 1802

def self.check_status(处理)
  return if 产量

  状态 = 状态.new

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

crypt_shared_lib_version (处理) ⇒整数

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

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

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

  • 主要版本
  • 次要版本
  • 修订版
  • reserved

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

参数:

返回:

  • ( Integer )

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



1608
1609
1610
# File 'lib/ Mongo/crypt/bounding.rb', line 1608

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

ctx_datakey_init (context) ⇒对象

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

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

参数:

引发:



623
624
625
626
627
# File 'lib/ Mongo/crypt/bounding.rb', line 623

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

ctx_decrypt_init (context, command) ⇒对象

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

初始化自动解密的上下文

参数:

引发:



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

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 )

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

  • 命令 (哈希)

    待加密的命令

引发:



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

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 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

为显式解密初始化上下文

参数:

引发:



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

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 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

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

参数:

引发:



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

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 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

初始化显式加密的上下文

参数:

引发:



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

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 表示的状态机

参数:

引发:



1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
# File 'lib/ Mongo/crypt/bounding.rb', line 1206

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_mode)
end

.ctx_kms_done(context) ⇒ Object

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

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

参数:

引发:



1183
1184
1185
1186
1187
# File 'lib/ Mongo/crypt/bounding.rb', line 1183

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

ctx_mongo_feed (context, doc) ⇒对象

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

将驱动程序的响应反馈给 libmongocrypt

参数:

引发:



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

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::文档,表示驱动程序必须代表 libmongocrypt 执行以获取所需信息以继续加密/解密的操作(示例,用于密钥保管库查询的过滤器)。

参数:

返回:

  • ( BSON::Document )

    驱动程序必须执行的操作

引发:



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

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



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

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文档。

引发:



1681
1682
1683
1684
1685
1686
1687
1688
1689
# File 'lib/ Mongo/crypt/bounding.rb', line 1681

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 )

    初始化是否成功。



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

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"

引发:



567
568
569
570
571
# File 'lib/ Mongo/crypt/bounding.rb', line 567

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 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

注意:

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

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

公共使用。

参数:

引发:



1788
1789
1790
1791
1792
1793
1794
1795
1796
# File 'lib/ Mongo/crypt/bounding.rb', line 1788

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 )

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

引发:



1751
1752
1753
1754
1755
# File 'lib/ Mongo/crypt/bounding.rb', line 1751

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 )

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

引发:



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

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文档,表示带有附加“提供商”字段的密钥加密密钥文档。

引发:



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

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 选项。

参数:

引发:



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

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 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

设置用于加密数据的自定义密钥材料。

参数:

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

    DataKeyContext

  • key_material ( BSON::Binary )

    96字节的自定义密钥材料

引发:



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

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 查询的类型。

引发:



1719
1720
1721
1722
1723
# File 'lib/ Mongo/crypt/bounding.rb', line 1719

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 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。



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

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

get_binary_len_direct (mongocrypt_binary_t) ⇒ 对象

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



183
184
185
# File 'lib/ Mongo/crypt/bounding.rb', line 183

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

init (处理) ⇒对象

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

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

参数:

引发:



405
406
407
408
409
# File 'lib/ Mongo/crypt/bounding.rb', line 405

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

kms_ctx_bytes_needed (kms_context) ⇒整数

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

获取 KmsContext 所需的字节数。

参数:

返回:

  • ( Integer )

    所需字节数



1061
1062
1063
# File 'lib/ Mongo/crypt/bounding.rb', line 1061

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

引发:



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

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 )

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



1146
1147
1148
# File 'lib/ Mongo/crypt/bounding.rb', line 1146

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。

参数:

引发:



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

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对象。



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

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,我们使用已记录的“读取”方法 - https://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 消息

引发:



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

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

  二进制文件.to_s
end

.kms_ctx_setopt_retry_kms(handle, value) ⇒ true, fale

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

启用或禁用KMS重试行为。

参数:

返回:

  • (true, fale)

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



1165
1166
1167
# File 'lib/ Mongo/crypt/bounding.rb', line 1165

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

.kms_ctx_usleep(kms_context) ⇒ Integer

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

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

参数:

返回:

  • ( Integer )

    64 位编码的休眠微秒数。



1129
1130
1131
# File 'lib/ Mongo/crypt/bounding.rb', line 1129

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 )

    指向数据大量的指针。



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

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

mongocrypt_binary_destroy (binary) ⇒ nil

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

销毁 mongocrypt_binary_t对象。

参数:

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

    指向 mongocrypt_binary_t对象的指针。

返回:

  • ( nil )

    始终为零。



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

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

mongocrypt_binary_len (binary) ⇒整数

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

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

参数:

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

    指向 mongocrypt_binary_t对象的指针。

返回:

  • ( Integer )

    数据数组的长度。



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

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

mongocrypt_binary_newFFI::Pointer

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

创建新的 mongocrypt_binary_t 对象(字节数组的非拥有视图)。

返回:

  • ( FFI::Pointer )

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



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

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

mongocrypt_binary_new_from_data (data, len) ⇒ FFI::Pointer

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

创建一个新的 mongocrypt_binary_t 对象,用于维护指向指定字节数组的指针。

参数:

  • 数据 ( FFI::Pointer )

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

  • len ( Integer )

    大量参数的长度。

返回:

  • ( FFI::Pointer )

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



157
158
159
160
161
# File 'lib/ Mongo/crypt/bounding.rb', line 157

附加函数(
  :mongocrypt_binary_new_from_data,
  %i[指针 int],
  :pointer
)

mongocrypt_crypt_shared_lib_version (crypt) ⇒对象

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



1586
1587
1588
1589
1590
# File 'lib/ Mongo/crypt/bounding.rb', line 1586

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

mongocrypt_ctx_datakey_init (ctx, filter) ⇒对象

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



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

附加函数 :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 )

    初始化是否成功。



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

附加函数 :mongocrypt_ctx_decrypt_init, %i[指针 指针], :bool

mongocrypt_ctx_destroy (ctx) ⇒ nil

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

销毁对 mongocrypt_ctx_t对象的引用。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

返回:

  • ( nil )

    始终为零。



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

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

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

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

注意:

此方法要求传入的BSON采用以下格式:{ "v": BSON value tocrypt }。

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

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • db ( string )

    数据库名称。

  • db_len ( Integer )

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

  • cmd ( FFI::Pointer )

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

返回:

  • ( Boolean )

    初始化是否成功。



676
677
678
679
680
# File 'lib/ Mongo/crypt/bounding.rb', line 676

附加函数(
  :mongocrypt_ctx_encrypt_init,
  %i[指针 字符串 int 指针],
  :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 )

    初始化是否成功。



802
803
804
805
806
# File 'lib/ Mongo/crypt/bounding.rb', line 802

附加函数(
  :mongocrypt_ctx_explicit_decrypt_init,
  %i[指针 指针],
  :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 )

    初始化是否成功。



712
713
714
715
716
# File 'lib/ Mongo/crypt/bounding.rb', line 712

附加函数(
  :mongocrypt_ctx_explicit_encrypt_init,
  %i[指针 指针],
  :bool
)

mongocrypt_ctx_finalize (ctx, op_bson) ⇒布尔值

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

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

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • op_bson ( FFI::Pointer )

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

返回:

  • ( Boolean )

    指示操作成功的布尔值。



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

附加函数 :mongocrypt_ctx_finalize, %i[指针 指针], :void

.mongocrypt_ctx_mongo_done(ctx) ⇒ Boolean

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

指示 libmongocrypt 驱动程序已完成提供回复。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

返回:

  • ( Boolean )

    指示操作成功的布尔值。



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

附加函数 :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 )

    指示操作成功的布尔值。



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

附加函数 :mongocrypt_ctx_mongo_feed, %i[指针 指针], :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对象的指针。



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

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

mongocrypt_ctx_mongo_op (ctx, op_bson) ⇒布尔值

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

获取驱动程序的BSON操作,以针对MongoDB集合、密钥保管库数据库或 mongocryptd运行。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • op_bson ( FFI::Pointer )

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

返回:

  • ( Boolean )

    指示操作成功的布尔值。



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

附加函数 :mongocrypt_ctx_mongo_op, %i[指针 指针], :bool

mongocrypt_ctx_new (crypt) ⇒ FFI::Pointer

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

创建一个新的 mongocrypt_ctx_t对象(libmongocrypt 状态机的包装器)。

参数:

  • crypt ( FFI::Pointer )

    指向 mongocrypt_t 对象的指针。

返回:

  • ( FFI::Pointer )

    一个新的 mongocrypt_ctx_t 对象。



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

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

mongocrypt_ctx_provide_kms_providers (ctx, kms_providers) ⇒对象

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



1664
1665
1666
1667
1668
# File 'lib/ Mongo/crypt/bounding.rb', line 1664

附加函数(
  :mongocrypt_ctx_provide_kms_providers,
  %i[指针 指针],
  :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 )

    是否已成功设立该选项。



553
554
555
556
557
# File 'lib/ Mongo/crypt/bounding.rb', line 553

附加函数(
  :mongocrypt_ctx_setopt_algorithm,
  %i[指针 字符串 int],
  :bool
)

mongocrypt_ctx_setopt_algorithm_range (ctx, opts) ⇒对象

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



1770
1771
1772
1773
1774
1775
1776
1777
# File 'lib/ Mongo/crypt/bounding.rb', line 1770

附加函数(
  :mongocrypt_ctx_setopt_algorithm_range,
  %i[
    指针
    指针
  ],
  :bool
)

mongocrypt_ctx_setopt_contention_factor (ctx,contention_factor) ⇒对象

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



1735
1736
1737
1738
1739
1740
1741
1742
# File 'lib/ Mongo/crypt/bounding.rb', line 1735

附加函数(
  :mongocrypt_ctx_setopt_contention_factor,
  %i[
    指针
    int64
  ],
  :bool
)

mongocrypt_ctx_setopt_key_alt_name (ctx, binary) ⇒ Boolean

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

注意:

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

创建数据密钥时,请为该密钥设立备用名称。执行显式加密时,根据 keyAltName字段指定使用哪个数据密钥进行加密。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

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

    指向 mongocrypt_binary_t对象的指针,该对象引用 { "keyAltName": } 格式的BSON文档。

返回:

  • ( Boolean )

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



485
486
487
488
489
# File 'lib/ Mongo/crypt/bounding.rb', line 485

附加函数(
  :mongocrypt_ctx_setopt_key_alt_name,
  %i[指针 指针],
  :bool
)

mongocrypt_ctx_setopt_key_encryption_key (ctx) ⇒布尔值

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

注意:

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

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

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • bin ( FFI::Pointer )

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

返回:

  • ( Boolean )

    是否已成功设立该选项。



583
584
585
586
587
# File 'lib/ Mongo/crypt/bounding.rb', line 583

附加函数(
  :mongocrypt_ctx_setopt_key_encryption_key,
  %i[指针 指针],
  :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 )

    是否已成功设立该选项。



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

附加函数 :mongocrypt_ctx_setopt_key_id, %i[指针 指针], :bool

mongocrypt_ctx_setopt_key_material (ctx, binary) ⇒ Boolean

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

注意:

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

创建数据密钥时,请设立用于加密数据的自定义密钥材料。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

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

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

返回:

  • ( Boolean )

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



520
521
522
523
524
# File 'lib/ Mongo/crypt/bounding.rb', line 520

附加函数(
  :mongocrypt_ctx_setopt_key_material,
  %i[指针 指针],
  :bool
)

mongocrypt_ctx_setopt_query_type (ctx, mongocrypt_query_type) ⇒对象

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



1702
1703
1704
1705
1706
1707
1708
1709
1710
# File 'lib/ Mongo/crypt/bounding.rb', line 1702

附加函数(
  :mongocrypt_ctx_setopt_query_type,
  %i[
    指针
    字符串
    int
  ],
  :bool
)

mongocrypt_ctx_state (ctx) ⇒符号

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

获取 ctx 的当前状态。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

返回:

  • (符号)

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



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

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

mongocrypt_ctx_status (ctx, status) ⇒ Boolean

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

在 mongocrypt_status_t对象上设置来自 mongocrypt_ctx_t对象的状态信息。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t对象的指针。

返回:

  • ( Boolean )

    状态是否已成功设置。



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

附加函数 :mongocrypt_ctx_status, %i[指针 指针], :bool

mongocrypt_destroy (crypt) ⇒ nil

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

销毁对 mongocrypt_t 对象的引用。

参数:

  • crypt ( FFI::Pointer )

    指向 mongocrypt_t 对象的指针。

返回:

  • ( nil )

    始终为零。



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

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

mongocrypt_init (crypt) ⇒布尔值

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

初始化 mongocrypt_t对象。

参数:

  • crypt ( FFI::Pointer )

    指向 mongocrypt_t 对象的指针。

返回:

  • ( Boolean )

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



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

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

mongocrypt_kms_ctx_bytes_needed ( KMS ) ⇒整数

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

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

参数:

  • KMS ( FFI::Pointer )

    mongocrypt_kms_ctx_t对象。

返回:

  • ( Integer )

    所需的字节数。



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

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

.mongocrypt_kms_ctx_done(ctx) ⇒ Boolean

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

指示 libmongocrypt,它将不再收到来自 mongocrypt_kms_ctx_t 对象的回复。

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

返回:

  • ( Boolean )

    操作是否成功。



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

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

mongocrypt_kms_ctx_endpoint ( KMS , endpoint) ⇒ Boolean

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

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

参数:

  • KMS ( FFI::Pointer )

    指向 mongocrypt_kms_ctx_t对象的指针。

  • 端点 ( FFI::Pointer )

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

返回:

  • ( Boolean )

    操作是否成功。



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

附加函数 :mongocrypt_kms_ctx_endpoint, %i[指针 指针], :bool

.mongocrypt_kms_ctx_fail(ctx) ⇒ Object

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



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

附加函数 :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 )

    操作是否成功。



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

附加函数 :mongocrypt_kms_ctx_feed, %i[指针 指针], :bool

mongocrypt_kms_ctx_get_kms_provider (crypt, kms_providers) ⇒对象

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



953
954
955
956
957
# File 'lib/ Mongo/crypt/bounding.rb', line 953

附加函数(
  :mongocrypt_kms_ctx_get_kms_provider,
  %i[指针 指针],
  :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 )

    操作是否成功。



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

附加函数 :mongocrypt_kms_ctx_message, %i[指针 指针], :bool

mongocrypt_kms_ctx_status ( KMS , status) ⇒布尔值

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

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

参数:

  • KMS ( FFI::Pointer )

    指向 mongocrypt_kms_ctx_t 对象的指针。

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t对象的指针。

返回:

  • ( Boolean )

    操作是否成功。



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

附加函数 :mongocrypt_kms_ctx_status, %i[指针 指针], :bool

.mongocrypt_kms_ctx_usleep(ctx) ⇒ int64

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

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

参数:

  • ctx ( FFI::Pointer )

    指向 mongocrypt_ctx_t对象的指针。

返回:

  • ( int64 )

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



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

附加函数 :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 )

    是否成功设置此选项。



1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
# File 'lib/ Mongo/crypt/bounding.rb', line 1482

附加函数(
  :mongocrypt_setopt_aes_256_ctr,
  %i[
    指针
    mongocrypt_crypto_fn
    mongocrypt_crypto_fn
    指针
  ],
  :bool
)

mongocrypt_setopt_append_crypt_shared_lib_search_path (crypt, path) ⇒对象

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



1519
1520
1521
1522
1523
1524
1525
1526
# File 'lib/ Mongo/crypt/bounding.rb', line 1519

附加函数(
  :mongocrypt_setopt_append_crypt_shared_lib_search_path,
  %i[
    指针
    字符串
  ],
  :void
)

mongocrypt_setopt_bypass_query_analysis (crypt) ⇒对象

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



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

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

    是否成功设置此选项。



1375
1376
1377
1378
1379
1380
1381
1382
1383
# File 'lib/ Mongo/crypt/bounding.rb', line 1375

附加函数(
  :mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs 1 _v 1 _ 5,
  %i[
    指针
    mongocrypt_hmac_fn
    指针
  ],
  :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 )

    是否成功设置此选项。



1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
# File 'lib/ Mongo/crypt/bounding.rb', line 1330

附加函数(
  :mongocrypt_setopt_crypto_hooks,
  %i[
    指针
    mongocrypt_crypto_fn
    mongocrypt_crypto_fn
    mongocrypt_random_fn
    mongocrypt_hmac_fn
    mongocrypt_hmac_fn
    mongocrypt_hash_fn
    指针
  ],
  :bool
)

mongocrypt_setopt_encrypted_field_config_map (crypt, efc_map) ⇒对象

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



1417
1418
1419
1420
1421
1422
1423
1424
# File 'lib/ Mongo/crypt/bounding.rb', line 1417

附加函数(
  :mongocrypt_setopt_encrypted_field_config_map,
  %i[
    指针
    指针
  ],
  :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 文档。



342
343
344
345
346
# File 'lib/ Mongo/crypt/bounding.rb', line 342

附加函数(
  :mongocrypt_setopt_kms_providers,
  %i[指针 指针],
  :bool
)

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

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

将 mongocrypt_t 对象上的处理程序设置为在每次 libmongocrypt 记录消息时调用。

参数:

  • crypt ( FFI::Pointer )

    指向 mongocrypt_t 对象的指针。

  • log_fn (方法)

    日志记录回调方法。

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

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

返回:

  • ( Boolean )

    是否设置回调成功。



313
314
315
316
317
# File 'lib/ Mongo/crypt/bounding.rb', line 313

附加函数(
  :mongocrypt_setopt_log_handler,
  %i[指针 mongocrypt_log_fn_t 指针],
  :bool
)

mongocrypt_setopt_retry_kms (crypt, 启用) ⇒ 对象

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



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

附加函数 :mongocrypt_setopt_retry_kms, %i[指针 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 )

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



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

附加函数 :mongocrypt_setopt_schema_map, %i[指针 指针], :bool

mongocrypt_setopt_set_crypt_shared_lib_path_override (crypt, path) ⇒对象

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



1548
1549
1550
1551
1552
1553
1554
1555
# File 'lib/ Mongo/crypt/bounding.rb', line 1548

附加函数(
  :mongocrypt_setopt_set_crypt_shared_lib_path_override,
  %i[
    指针
    字符串
  ],
  :void
)

mongocrypt_setopt_use_need_kms_credentials_state (crypt) ⇒对象

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



1627
1628
1629
1630
1631
# File 'lib/ Mongo/crypt/bounding.rb', line 1627

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

mongocrypt_status (crypt, status) ⇒ Boolean

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

在 mongocrypt_status_t对象上设置 mongocrypt_t对象的状态信息。

参数:

  • crypt ( FFI::Pointer )

    指向 mongocrypt_t 对象的指针。

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t对象的指针。

返回:

  • ( Boolean )

    状态是否已成功设置。



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

附加函数 :mongocrypt_status, %i[指针 指针], :bool

mongocrypt_status_code (status) ⇒整数

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

返回状态错误代码。

参数:

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t 的指针。

返回:

  • ( Integer )

    状态代码。



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

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

mongocrypt_status_destroy (status) ⇒ nil

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

销毁对 mongocrypt_status_t 对象的引用。

参数:

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t 的指针。

返回:

  • ( nil )

    始终为零。



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

附加函数 :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 )

    状态消息。



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

附加函数 :mongocrypt_status_message, %i[指针 指针], : 细绳

mongocrypt_status_newFFI::Pointer

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

创建新的 mongocrypt_status_t 对象。

返回:

  • ( FFI::Pointer )

    指向新的 mongocrypt_status_ts 的指针。



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

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

mongocrypt_status_ok (status) ⇒布尔值

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

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

参数:

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t 的指针。

返回:

  • ( Boolean )

    状态是否正常。



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

附加函数 :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 )

    始终为零。



221
222
223
224
225
# File 'lib/ Mongo/crypt/bounding.rb', line 221

附加函数(
  :mongocrypt_status_set,
  %i[指针 status_type int 字符串 int],
  :void
)

.mongocrypt_status_type(status) ⇒ Symbol

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

指示状态类型。

参数:

  • 状态 ( FFI::Pointer )

    指向 mongocrypt_status_t 的指针。

返回:

  • (符号)

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



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

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

mongocrypt_version (len) ⇒ string

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

返回 libmongocrypt 库的版本string 。

参数:

  • len ( FFI::Pointer | nil )

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

返回:

  • ( string )

    libmongocrypt 的版本string 。



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

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

ongocrypt_newFFI::Pointer

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

创建新的 mongocrypt_t对象。

返回:

  • ( FFI::Pointer )

    指向新 mongocrypt_t对象的指针。



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

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

.parse_version(version) ⇒ Gem::Version

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

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

参数:

  • 版本 ( string )

    表示版本号的string 。

返回:

  • (Gem::Version)

    版本号

引发:

  • ( ArgumentError )

    如果无法解析string 。



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

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 解密方法

引发:



1500
1501
1502
1503
1504
1505
# File 'lib/ Mongo/crypt/bounding.rb', line 1500

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 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

在搜索路径中追加一个搜索目录,用于加载 crypt_shared 动态库。

参数:



1533
1534
1535
1536
1537
# File 'lib/ Mongo/crypt/bounding.rb', line 1533

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 状态。

参数:



1467
1468
1469
# File 'lib/ Mongo/crypt/bounding.rb', line 1467

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 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

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

参数:

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

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

引发:



1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
# File 'lib/ Mongo/crypt/bounding.rb', line 1392

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哈希方法

引发:



1356
1357
1358
1359
1360
1361
1362
1363
1364
# File 'lib/ Mongo/crypt/bounding.rb', line 1356

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 文档。

引发:



1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
# File 'lib/ Mongo/crypt/bounding.rb', line 1435

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文档。

引发:



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

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对象上设置记录器回调函数

参数:

引发:



325
326
327
328
329
# File 'lib/ Mongo/crypt/bounding.rb', line 325

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 对象的模式映射

引发:



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

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 共享库的单个覆盖路径。

参数:



1561
1562
1563
1564
1565
# File 'lib/ Mongo/crypt/bounding.rb', line 1561

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。

参数:



1645
1646
1647
# File 'lib/ Mongo/crypt/bounding.rb', line 1645

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 的数据

引发:



1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
# File 'lib/ Mongo/crypt/bounding.rb', line 1838

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

  message = if 数据.nil?
              ' 尝试将 nil 数据传递给 libmongocrypt。 ' +
                'Data must be a Hash'
            else
              "尝试将无效数据传递给 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 )

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



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

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 )

    加密/解密是否成功。



1248
1249
1250
1251
1252
# File 'lib/ Mongo/crypt/bounding.rb', line 1248

callback(
  :mongocrypt_crypto_fn,
  %i[指针 指针 指针 指针 指针 指针 指针],
  :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 )

    哈希是否成功。



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

callback :mongocrypt_hash_fn, %i[指针 指针 指针 指针], :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 是否成功。



1273
1274
1275
1276
1277
# File 'lib/ Mongo/crypt/bounding.rb', line 1273

callback(
  :mongocrypt_hmac_fn,
  %i[指针 指针 指针 指针 指针],
  :bool
)

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

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

注意:

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

对 mongocrypt日志函数的回调。使用 mongocrypt_setopt_log_handler 方法设置自定义日志回调

参数:

  • 等级 (符号)

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

  • message ( string )

    日志消息

  • len ( Integer )

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

  • ctx ( FFI::Pointer | nil )

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

返回:

  • ( nil )

    始终为零。



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

callback :mongocrypt_log_fn_t, %i[log_level 字符串 int 指针], :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 )

    哈希是否成功。



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

callback :mongocrypt_random_fn, %i[指针 指针 int 指针], :bool