类:Mongo::Crypt::ExplicitEncrypter Private
- 继承:
-
对象
- 对象
- Mongo::Crypt::ExplicitEncrypter
- 扩展方式:
- 可转发
- 定义于:
- lib/ Mongo/crypt/explicit_encrypter.rb
Overview
此类是私有 API 的一部分。 应尽可能避免使用此类,因为它将来可能会被删除或更改。
ExplicitEncrypter 是执行显式加密操作并处理所有关联选项和实例变量的对象。
实例方法摘要折叠
-
# add_key_alt_name ( ID , key_alt_name) ⇒ BSON::Document | nil
private
在具有给定 ID 的密钥保管库集合中为密钥添加 key_alt_name。
-
# create_and_insert_data_key (master_key_document, key_alt_names, key_material = nil) ⇒ BSON::Binary
private
生成用于加密/解密的数据密钥,并将该密钥存储在 KMS 集合中。
-
#解密(值) ⇒ 对象
private
对已加密的值进行解密。
-
# delete_key (ID) ="Operation::Result"
private
从密钥保管库集合中删除具有给定 ID 的密钥。
-
# encrypt (value, options) ⇒ BSON::Binary
private
使用指定的加密密钥和算法加密值。
-
# encrypt_expression (expression, options) ⇒ BSON::Binary
private
加密匹配表达式或聚合表达式以查询范围索引。
-
#get_key(id) ⇒ BSON::Document | nil
private
查找具有给定 ID 的单个键。
-
#get_key_by_alt_name(key_alt_name) ⇒ BSON::Document | nil
private
返回密钥保管库集合中具有给定 key_alt_name 的密钥。
-
# get_keys ⇒ Collection::View
private
返回密钥保管库集合中的所有密钥。
-
#initialize (key_vault_client, key_vault_namespace, kms_providers, kms_tls_options, timeout_ms = nil) ⇒ ExplicitEncrypter
构造函数
private
创建一个新的 ExplicitEncrypter 对象。
-
#remove_key_alt_name(id, key_alt_name) ⇒ BSON::Document | nil
private
从密钥保管库集合中具有给定 ID 的密钥中删除 key_alt_name。
-
# rewrap_many_data_key (filter, opts = {}) ⇒ Crypt::RewrapManyDataKeyResult
private
解密多个数据密钥,并使用新的 master_key(重新)加密它们;如果未给出新密钥,则使用当前的 master_key。
构造函数详情
#initialize (key_vault_client, key_vault_namespace, kms_providers, kms_tls_options, timeout_ms = nil) ⇒ ExplicitEncrypter
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
创建一个新的 ExplicitEncrypter 对象。
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ Mongo/crypt/explicit_encrypter.rb', line 40 def 初始化(key_vault_client, key_vault_namespace, kms_providers, , timeout_ms = nil) Crypt.validate_ffi! @crypt_handle = 句柄.new( kms_providers, , explicit_encryption_only: true ) @encryption_io = EncryptionIO.new( key_vault_client: key_vault_client, metadata_client: nil, key_vault_namespace: key_vault_namespace ) @timeout_ms = timeout_ms end |
实例方法详细信息
# add_key_alt_name ( ID , key_alt_name) ⇒ BSON::Document | nil
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
在具有给定 ID 的密钥保管库集合中为密钥添加 key_alt_name。
203 204 205 |
# File 'lib/ Mongo/crypt/explicit_encrypter.rb', line 203 def add_key_alt_name(id, key_alt_name) @encryption_io.add_key_alt_name(id, key_alt_name, timeout_ms: @timeout_ms) end |
# create_and_insert_data_key (master_key_document, key_alt_names, key_material = nil) ⇒ BSON::Binary
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
生成用于加密/解密的数据密钥,并将该密钥存储在 KMS 集合中。 生成的密钥使用 KMS 主密钥进行加密。
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ Mongo/crypt/explicit_encrypter.rb', line 70 def create_and_insert_data_key(master_key_document, key_alt_names, key_material = nil) data_key_document = Crypt::DataKeyContext.new( @crypt_handle, @encryption_io, master_key_document, key_alt_names, key_material ).run_state_machine(timeout_holder) @encryption_io.insert_data_key( data_key_document, timeout_ms: timeout_holder.剩余超时毫秒! ).Inserted_id end |
#解密(值) ⇒对象
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
对已加密的值进行解密
188 189 190 191 192 193 194 |
# File 'lib/ Mongo/crypt/explicit_encrypter.rb', line 188 def 解密(值) Crypt::ExplicitDecryptionContext.new( @crypt_handle, @encryption_io, { v: 值 } ).run_state_machine(timeout_holder)[' v '] end |
# delete_key ( ID ) = "Operation::Result"
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
从密钥保管库集合中删除具有给定 ID 的密钥。
213 214 215 |
# File 'lib/ Mongo/crypt/explicit_encrypter.rb', line 213 def delete_key(id) @encryption_io.delete_key(id, timeout_ms: @timeout_ms) end |
# encrypt (value, options) ⇒ BSON::Binary
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
:key_id 和 :key_alt_name 选项是互斥的。 只需一次即可执行显式加密。
使用指定的加密密钥和算法加密值
如果加密算法设立为“Indexed”。 应设立查询类型
only if encryption algorithm is set to "Indexed". The only allowed
value is "equality".
113 114 115 116 117 118 119 120 |
# File 'lib/ Mongo/crypt/explicit_encrypter.rb', line 113 def 加密(值, ) Crypt::ExplicitEncryptionContext.new( @crypt_handle, @encryption_io, { v: 值 }, ).run_state_machine(timeout_holder)[' v '] end |
# encrypt_expression (表达式, options) ⇒ BSON::Binary
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
范围算法仅处于实验阶段。 它不是
:key_id 和 :key_alt_name 选项是互斥的。 只需一次即可执行显式加密。
加密匹配表达式或聚合表达式以查询范围索引。
仅当 queryType 为“范围”且算法为“ Range ”时才支持。 @note:Range算法仅处于实验阶段。 这不是为了
for public use. It is subject to breaking changes.
# @param [ Hash ] 供公众使用的选项。
173 174 175 176 177 178 179 180 |
# File 'lib/ Mongo/crypt/explicit_encrypter.rb', line 173 def encrypt_expression(表达式(expression), ) Crypt::ExplicitEncryptionExpressionContext.new( @crypt_handle, @encryption_io, { v: 表达式(expression) }, ).run_state_machine(timeout_holder)[' v '] end |
#get_key(id) ⇒ BSON::Document | nil
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
查找具有给定 ID 的单个键。
223 224 225 |
# File 'lib/ Mongo/crypt/explicit_encrypter.rb', line 223 def get_key(id) @encryption_io.get_key(id, timeout_ms: @timeout_ms) end |
# get_key_by_alt_name (key_alt_name) ⇒ BSON::Document | nil
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
返回密钥保管库集合中具有给定 key_alt_name 的密钥。
233 234 235 |
# File 'lib/ Mongo/crypt/explicit_encrypter.rb', line 233 def get_key_by_alt_name(key_alt_name) @encryption_io.get_key_by_alt_name(key_alt_name, timeout_ms: @timeout_ms) end |
# get_keys ⇒ Collection::View
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
返回密钥保管库集合中的所有密钥。
rubocop:disable Naming/AccessorMethodName 此方法的名称在 FLE 规范中定义
242 243 244 |
# File 'lib/ Mongo/crypt/explicit_encrypter.rb', line 242 def get_keys @encryption_io.get_keys(timeout_ms: @timeout_ms) end |
# remove_key_alt_name ( ID , key_alt_name) ⇒ BSON::Document | nil
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
从密钥保管库集合中具有给定 ID 的密钥中删除 key_alt_name。
254 255 256 |
# File 'lib/ Mongo/crypt/explicit_encrypter.rb', line 254 def remove_key_alt_name(id, key_alt_name) @encryption_io.remove_key_alt_name(id, key_alt_name, timeout_ms: @timeout_ms) end |
# rewrap_many_data_key (过滤, opts = {}) ⇒ Crypt::RewrapManyDataKeyResult
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
解密多个数据密钥并使用新的 master_key(重新)加密它们,
or with their current master_key if a new one is not given.
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/ Mongo/crypt/explicit_encrypter.rb', line 269 def rewrap_many_data_key(筛选器, opts = {}) (opts) master_key_document = master_key_for_provider(opts) rewrap_result = Crypt::RewrapManyDataKeyContext.new( @crypt_handle, @encryption_io, 筛选器, master_key_document ).run_state_machine(timeout_holder) return RewrapManyDataKeyResult.new(nil) if rewrap_result.nil? 更新 = update_from_data_key_documents(rewrap_result.获取(' v ')) RewrapManyDataKeyResult.new( @encryption_io.update_data_keys(更新, timeout_ms: @timeout_ms) ) end |