阅读373 返回首页    go 英雄联盟


EncryptionContext说明__API 参考_密钥管理服务-阿里云

Encryption Context作用

Encryption Context是在KMS的Encrypt、GenerateDataKey、Decrypt这些API中可能会用到的JSON字符串,并且只能是String-String形式的JSON,用于保护数据的完整性。

当在加密(Encrypt、GenerateDataKey)时指定了该参数时,解密(Decrypt)密文时,需要传入等价的参数,才能正确的解密。Encryption Context虽然与解密相关,但是并不会存在密文(CipherBlob)中。

Encryption Context有效值

Encryption Context的有效值是一个总长度在8192个字符数以内的json字符串,并且只能是String-String形式的。当您直接调用API填Encryption Context的时候,请注意转义的问题。

有效的Encryption Context示例

  1. 1. {"ValidKey":"ValidValue"}
  2. 2. {"Key1":"Value1","Key2":"Value2"}

无效的Encryption Context (部分)示例

  1. 1. [{"Key":"Value"}] //json数组
  2. 2. {"Key":12345} //String-int
  3. 3. {"Key":["value1","value2"]} //String-数组

等价的Encryption Context

Encryption Context的本质是一个String-String的map(hashtable), 因此在作为参数时,只需要保证json字符串所表示的key-value含义是一致的,则Encryption Context是等价的。与加密时输入的Encryption Context等价的Encryption Context就可以用于正确的解密,而不用保持完全一致的字符串。

等价的Encryption Context示例

  1. {"Key1":"Value1","Key2":"Value2"} 与 {"Key2":"Value2","Key1":"Value1"} 等价

最后更新:2016-11-24 11:23:49

  上一篇:go 使用RAM实现KMS资源授权__API 参考_密钥管理服务-阿里云
  下一篇:go KMS地域分布__API 参考_密钥管理服务-阿里云