本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
使用 Cloud HSM CLI 中的key generate-asymmetric-pair命令在 AWS CloudHSM 集群中生成对称通用密钥。
用户类型
以下类型的用户均可运行此命令。
-
加密用户 (CUs)
要求
要运行此命令,必须以 CU 身份登录。
语法
aws-cloudhsm >
key help generate-symmetric generic-secret
Generate a generic secret key Usage: key generate-symmetric generic-secret [OPTIONS] --label
<LABEL>
--key-length-bytes<KEY_LENGTH_BYTES>
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 --label<LABEL>
Label for the key --session Creates a session key that exists only in the current session. The key cannot be recovered after the session ends --key-length-bytes<KEY_LENGTH_BYTES>
Key length in bytes --attributes [<KEY_ATTRIBUTES>
...] Space separated list of key attributes to set for the generated generic secret key in the form of KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE --share-crypto-users [<SHARE_CRYPTO_USERS>
...] Space separated list of Crypto User usernames to share the generic secret key with --manage-key-quorum-value<MANAGE_KEY_QUORUM_VALUE>
The quorum value for key management operations --use-key-quorum-value<USE_KEY_QUORUM_VALUE>
The quorum value for key usage operations -h, --help Print help
示例
以下示例显示了如何使用 key generate-symmetric generic-secret 命令创建通用机密密钥。
例 示例:创建通用密钥
aws-cloudhsm >
key generate-symmetric generic-secret \ --label example-generic-secret \ --key-length-bytes 256
{ "error_code": 0, "data": { "key": { "key-reference": "0x00000000002e08fd", "key-info": { "key-owners": [ { "username": "cu1", "key-coverage": "full" } ], "shared-users": [], "key-quorum-values": { "manage-key-quorum-value": 0, "use-key-quorum-value": 0 }, "cluster-coverage": "full" }, "attributes": { "key-type": "generic-secret", "label": "example-generic-secret", "id": "", "class": "secret-key", "encrypt": false, "decrypt": false, "token": true, "always-sensitive": true, "derive": false, "destroyable": true, "extractable": true, "local": true, "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": 256 } } } }
例 示例:使用可选属性创建通用机密密钥
aws-cloudhsm >
key generate-symmetric generic-secret \ --label example-generic-secret \ --key-length-bytes 256 \ --attributes encrypt=true
{ "error_code": 0, "data": { "key": { "key-reference": "0x00000000002e08fd", "key-info": { "key-owners": [ { "username": "cu1", "key-coverage": "full" } ], "shared-users": [], "key-quorum-values": { "manage-key-quorum-value": 0, "use-key-quorum-value": 0 }, "cluster-coverage": "full" }, "attributes": { "key-type": "generic-secret", "label": "example-generic-secret", "id": "", "class": "secret-key", "encrypt": true, "decrypt": false, "token": true, "always-sensitive": true, "derive": false, "destroyable": true, "extractable": true, "local": true, "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": 256 } } } }
例 示例:创建具有法定值的通用密钥
生成带有法定人数控制的密钥时,该密钥必须与等于最大密钥法定值的最小用户数相关联。关联用户包括密钥所有者和与之共享密钥的加密用户。要确定与之共享密钥的最小用户数,请获取密钥使用法定值和密钥管理法定值之间的最大法定值,然后减去 1 以说明密钥所有者(默认情况下与密钥相关联)。要与更多用户共享密钥,请使用使用 Cloud 共享密钥 HSM CLI命令。
aws-cloudhsm >
key generate-symmetric generic-secret \ --label example-generic-secret \ --key-length-bytes 256 \ --attributes encrypt=true --share-crypto-users cu2 cu3 cu4 \ --manage-key-quorum-value 4 \ --use-key-quorum-value 2
{ "error_code": 0, "data": { "key": { "key-reference": "0x00000000002e08fd", "key-info": { "key-owners": [ { "username": "cu1", "key-coverage": "full" } ], "shared-users": [ { "username": "cu2", "key-coverage": "full" }, { "username": "cu3", "key-coverage": "full" }, { "username": "cu4", "key-coverage": "full" }, ], "key-quorum-values": { "manage-key-quorum-value": 4, "use-key-quorum-value": 2 }, "cluster-coverage": "full" }, "attributes": { "key-type": "generic-secret", "label": "example-generic-secret", "id": "", "class": "secret-key", "encrypt": true, "decrypt": false, "token": true, "always-sensitive": true, "derive": false, "destroyable": true, "extractable": true, "local": true, "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": 256 } } } }
参数
<CLUSTER_ID>
-
要运行此操作的集群的 ID。
必需:如果已配置多个集群。
<KEY_ATTRIBUTES>
-
以
KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE
(例如sign=true
)的形式指定要为生成的AES密钥设置的按空格分隔的密钥属性列表。有关支持的密钥属性的列表,请参阅 云的关键属性 HSM CLI。
必需:否
<KEY-LENGTH-BYTES>
-
指定以字节为单位的密钥长度。
有效值:
1 至 800
必需:是
<LABEL>
-
为通用密钥指定用户定义的标签。客户端 SDK 5.11 及更高版本允许的最大大小
label
为 127 个字符。客户端 SDK 5.10 及之前的版本限制为 126 个字符。必需:是
<SESSION>
-
创建仅在当前会话中存在的密钥。会话结束后,密钥无法恢复。
如果您只需要一个短暂的密钥,例如用于加密然后快速解密另一个密钥的包装密钥,请使用此参数。对于会话结束后可能需要解密的加密数据,切勿使用会话密钥。
默认情况下,生成的密钥是永久(令牌)密钥。传入 < SESSION > 可以改变这一点,确保使用此参数生成的密钥是会话(临时)密钥。
必需:否
<SHARE_CRYPTO_USERS>
-
以空格分隔的 Crypto 用户名列表,用于与之共享通用密钥
必需:否
<MANAGE_KEY_QUORUM_VALUE>
-
密钥管理操作的法定值。此值必须小于或等于与该密钥关联的用户数。这包括与之共享密钥的用户和密钥所有者。最大值为 8。
必需:否
<USE_KEY_QUORUM_VALUE>
-
密钥使用操作的法定值。此值必须小于或等于与该密钥关联的用户数。这包括与之共享密钥的用户和密钥所有者。最大值为 8。
必需:否