使用 CloudHSM CLI 通过 RSA-PKCS 解包密钥
使用 CloudHSM CLI 中的 key unwrap rsa-pkcs 命令通过 RSA 私有密钥和 RSA-PKCS
解包机制来解包有效载荷密钥。
解包的密钥的使用方式与 AWS CloudHSM 生成的密钥相同。为了表明它们不是本地生成的,其 local
属性设置为 false
。
要使用 key unwrap rsa-pkcs 命令,您必须在 AWS CloudHSM 集群中拥有 RSA 公钥包装密钥的 RSA 私钥,并且其 unwrap
属性必须设置为 true
。
用户类型
以下类型的用户均可运行此命令。
-
加密用户(CU)
要求
-
要运行此命令,必须以 CU 身份登录。
语法
aws-cloudhsm >
help key unwrap rsa-pkcs
Usage: key unwrap rsa-pkcs [OPTIONS] --filter [
<FILTER>
...] --key-type-class<KEY_TYPE_CLASS>
--label<LABEL>
<--data-path<DATA_PATH>
|--data<DATA>
> Options: --cluster-id<CLUSTER_ID>
Unique Id to choose which of the clusters in the config file to run the operation against. If not provided, will fall back to the value provided when interactive mode was started, or error --filter [<FILTER>
...] Key reference (e.g. key-reference=0xabc) or space separated list of key attributes in the form of attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE to select a key to unwrap with --data-path<DATA_PATH>
Path to the binary file containing the wrapped key data --data<DATA>
Base64 encoded wrapped key data --attributes [<UNWRAPPED_KEY_ATTRIBUTES>
...] Space separated list of key attributes in the form of KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE for the unwrapped key --key-type-class<KEY_TYPE_CLASS>
Key type and class of wrapped key [possible values: aes, des3, ec-private, generic-secret, rsa-private] --label<LABEL>
Label for the unwrapped key --session Creates a session key that exists only in the current session. The key cannot be recovered after the session ends -h, --help Print help
示例
这些示例展示了如何通过将 unwrap
属性值设置为 true
的 AES 密钥来使用 key unwrap rsa-oaep 命令。
例 示例:从 Base64 编码的包装密钥数据中解包有效载荷密钥
aws-cloudhsm >
key unwrap rsa-pkcs --key-type-class aes --label aes-unwrapped --filter attr.label=rsa-private-key-example --data am0Nc7+YE8FWs+5HvU7sIBcXVb24QA0l65nbNAD+1bK+e18BpSfnaI3P+r8Dp+pLu1ofoUy/vtzRjZoCiDofcz4EqCFnGl4GdcJ1/3W/5WRvMatCa2d7cx02swaeZcjKsermPXYRO1lGlfq6NskwMeeTkV8R7Rx9artFrs1y0DdIgIKVaiFHwnBIUMnlQrR2zRmMkfwU1jxMYmOYyD031F5VbnjSrhfMwkww2la7uf/c3XdFJ2+0Bo94c6og/yfPcpOOobJlITCoXhtMRepSdO4OggYq/6nUDuHCtJ86pPGnNahyr7+sAaSI3a5ECQLUjwaIARUCyoRh7EFK3qPXcg==
{ "error_code": 0, "data": { "key": { "key-reference": "0x00000000001c08ef", "key-info": { "key-owners": [ { "username": "cu1", "key-coverage": "full" } ], "shared-users": [], "cluster-coverage": "full" }, "attributes": { "key-type": "aes", "label": "aes-unwrapped", "id": "0x", "check-value": "0x8d9099", "class": "secret-key", "encrypt": false, "decrypt": false, "token": true, "always-sensitive": false, "derive": false, "destroyable": true, "extractable": true, "local": false, "modifiable": true, "never-extractable": false, "private": true, "sensitive": true, "sign": true, "trusted": false, "unwrap": false, "verify": true, "wrap": false, "wrap-with-trusted": false, "key-length-bytes": 16 } } } }
例 示例:解包通过数据路径提供的有效载荷密钥
aws-cloudhsm >
key unwrap rsa-pkcs --key-type-class aes --label aes-unwrapped --filter attr.label=rsa-private-key-example --data-path payload-key.pem
{ "error_code": 0, "data": { "key": { "key-reference": "0x00000000001c08ef", "key-info": { "key-owners": [ { "username": "cu1", "key-coverage": "full" } ], "shared-users": [], "cluster-coverage": "full" }, "attributes": { "key-type": "aes", "label": "aes-unwrapped", "id": "0x", "check-value": "0x8d9099", "class": "secret-key", "encrypt": false, "decrypt": false, "token": true, "always-sensitive": false, "derive": false, "destroyable": true, "extractable": true, "local": false, "modifiable": true, "never-extractable": false, "private": true, "sensitive": true, "sign": true, "trusted": false, "unwrap": false, "verify": true, "wrap": false, "wrap-with-trusted": false, "key-length-bytes": 16 } } } }
参数
<CLUSTER_ID>
-
要运行此操作的集群的 ID。
必需:如果已配置多个集群。
<FILTER>
-
密钥引用(例如
key-reference=0xabc
)或空格分隔的密钥属性列表,采用attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE
形式,可选择要用于解包的密钥。必需:是
<DATA_PATH>
-
包含包装的密钥数据的二进制文件的路径。
必需:是(除非通过 Base64 编码的数据提供)
<DATA>
-
Base64 编码的包装密钥数据。
必需:是(除非通过数据路径提供)
<ATTRIBUTES>
-
包装密钥的空格分隔的密钥属性列表,采用
KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE
形式。必需:否
<KEY_TYPE_CLASS>
-
包装密钥的密钥类型和类[可能的值:
aes
、des3
、ec-private
、generic-secret
、rsa-private
]。必需:是
<LABEL>
-
解包密钥的标签。
必需:是
<SESSION>
-
创建仅在当前会话中存在的会话密钥。会话结束后,密钥无法恢复。
必需:否