

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# CloudHSM CLI 命令的引用
<a name="cloudhsm_cli-reference"></a>

CloudHSM CLI 可帮助管理员管理其集群中的用户。 AWS CloudHSM CloudHSM CLI 可以在两种模式下运行：交互模式和单命令模式。要快速开始使用，请参阅 [AWS CloudHSM 命令行界面 (CLI) 入门](cloudhsm_cli-getting-started.md)。

要运行大多数 CloudHSM CLI 命令，必须启动 CloudHSM CLI 并登录 HSM。如果您添加或删除 HSMs，请更新 CloudHSM CLI 的配置文件。否则，您所做的更改可能不会对集群 HSMs 中的所有人生效。

以下主题介绍 CloudHSM CLI 中的命令：


| 命令 | 说明 | 用户类型 | 
| --- | --- | --- | 
| [激活](cloudhsm_cli-cluster-activate.md) | 激活一个 CloudHSM 集群并确认该集群是新集群。必须先完成此操作，然后才能执行任何其他操作。 | 未激活的管理员 | 
| [hsm-info](cloudhsm_cli-cluster-hsm-info.md) | 列出您的集群 HSMs 中的。 | 全部 [1](#cli-ref-1)，包括未经身份验证的用户。不需要登录名。 | 
| [ecdsa](cloudhsm_cli-crypto-sign-ecdsa.md) | 使用 EC 私有密钥和 ECDSA 签名机制生成签名。 | 加密用户 (CU) | 
| [ed25519ph](cloudhsm_cli-crypto-sign-ed25519ph.md) | 使用 Ed25519 私钥和 D HashEd SA 签名机制生成签名。 | CU | 
| [rsa-pkcs](cloudhsm_cli-crypto-sign-rsa-pkcs.md) | 使用 RSA 私有密钥和 RSA-PKCS 签名机制生成签名。 | CU | 
| [rsa-pkcs-pss](cloudhsm_cli-crypto-sign-rsa-pkcs-pss.md) | 使用 RSA 私钥和签名机制生成 RSA-PKCS-PSS签名。 | CU | 
| [ecdsa](cloudhsm_cli-crypto-verify-ecdsa.md) | 确认文件已通过给定的公有密钥在 HSM 中签名。验证签名是否是使用 ECDSA 签名机制生成的。将签名文件与源文件进行比较，并根据给定的 ecdsa 公有密钥和签名机制确定两者是否具有加密相关性。 | CU | 
| [ed25519ph](cloudhsm_cli-crypto-verify-ed25519ph.md) | 使用 E HashEd d25519 公钥验证 DSA 签名。 | CU | 
| [rsa-pkcs](cloudhsm_cli-crypto-verify-rsa-pkcs.md) | 确认文件已通过给定的公有密钥在 HSM 中签名。验证签名是否是使用 RSA-PKCS 签名机制生成的。将签名文件与源文件进行比较，并根据给定的 rsa 公有密钥和签名机制确定两者是否具有加密相关性。 | CU | 
| [rsa-pkcs-pss](cloudhsm_cli-crypto-verify-rsa-pkcs-pss.md) | 确认文件已通过给定的公有密钥在 HSM 中签名。验证签名是否使用签名机制生成。 RSA-PKCS-PSS将签名文件与源文件进行比较，并根据给定的 rsa 公有密钥和签名机制确定两者是否具有加密相关性。 | CU | 
| [key delete](cloudhsm_cli-key-delete.md) | 从您的 AWS CloudHSM 集群中删除密钥。 | CU | 
| [key generate-file](cloudhsm_cli-key-generate-file.md) | 在您的 AWS CloudHSM 集群中生成密钥文件。 | CU | 
| [密钥 generate-asymmetric-pair rsa](cloudhsm_cli-key-generate-asymmetric-pair-rsa.md) | 在您的 AWS CloudHSM 集群中生成非对称 RSA key pair。 | CU | 
| [key generate-asymmetric-pair ec](cloudhsm_cli-key-generate-asymmetric-pair-ec.md) | 在集群中生成非对称椭圆曲线 (EC) 密钥对。 AWS CloudHSM  | CU | 
| [key generate-symmetric aes](cloudhsm_cli-key-generate-symmetric-aes.md) | 在 AWS CloudHSM 集群中生成对称 AES 密钥。 | CU | 
| [key generate-symmetric generic-secret](cloudhsm_cli-key-generate-symmetric-generic-secret.md) | 在您的 AWS CloudHSM 集群中生成对称通用密钥。 | CU | 
| [key import pem](cloudhsm_cli-key-import-pem.md) | 将 PEM 格式密钥导入到 HSM。您可以使用它来导入在 HSM 外生成的公有密钥。 | CU | 
| [key list](cloudhsm_cli-key-list.md) | 查找 AWS CloudHSM 集群中当前用户的所有密钥。 | CU | 
| [key replicate](cloudhsm_cli-key-replicate.md) | 将密钥从源集群复制到克隆的目标集群。 | CU | 
| [key set-attribute](cloudhsm_cli-key-set-attribute.md) | 设置集 AWS CloudHSM 群中密钥的属性。 | CUs 可以运行此命令，管理员可以设置可信属性。 | 
| [key share](cloudhsm_cli-key-share.md) | 与 AWS CloudHSM 集群 CUs 中的其他人共享密钥。 | CU | 
| [key unshare](cloudhsm_cli-key-unshare.md) | 取消与 AWS CloudHSM 集群 CUs 中的其他人共享密钥。 | CU | 
| [aes-gcm](cloudhsm_cli-key-unwrap-aes-gcm.md) | 使用 AES 包装密钥和 AES-GCM 解包机制将有效载荷密钥解包到集群中。 | CU | 
| [aes-no-pad](cloudhsm_cli-key-unwrap-aes-no-pad.md) | 使用 AES 封装密钥和解包机制将有效载荷密钥 AES-NO-PAD解封到集群中。 | CU | 
| [aes-pkcs5-pad](cloudhsm_cli-key-unwrap-aes-pkcs5-pad.md) | 使用 AES 封装密钥和 AES PKCS5--PAD 解包机制解开有效载荷密钥。 | CU | 
| [aes-zero-pad](cloudhsm_cli-key-unwrap-aes-zero-pad.md) | 使用 AES 封装密钥和解包机制将有效载荷密钥 AES-ZERO-PAD解封到集群中。 | CU | 
| [cloudhsm-aes-gcm](cloudhsm_cli-key-unwrap-cloudhsm-aes-gcm.md) | 使用 AES 封装密钥和解包机制将有效载荷密钥 CLOUDHSM-AES-GCM解封到集群中。 | CU | 
| [rsa-aes](cloudhsm_cli-key-unwrap-rsa-aes.md) | 使用 RSA 私有密钥和 RSA-AES 解包机制来解包有效载荷密钥。 | CU | 
| [rsa-oaep](cloudhsm_cli-key-unwrap-rsa-oaep.md) | 使用 RSA 私有密钥和 RSA-OAEP 解包机制来解包有效载荷密钥。 | CU | 
| [rsa-pkcs](cloudhsm_cli-key-unwrap-rsa-pkcs.md) | 使用 RSA 私有密钥和 RSA-PKCS 解包机制来解包有效载荷密钥。 | CU | 
| [aes-gcm](cloudhsm_cli-key-wrap-aes-gcm.md) | 使用 HSM 上的 AES 密钥和 AES-GCM 包装机制来包装有效载荷密钥。 | CU | 
| [aes-no-pad](cloudhsm_cli-key-wrap-aes-no-pad.md) | 使用 HSM 上的 AES 密钥和 AES-NO-PAD包装机制封装有效载荷密钥。 | CU | 
| [aes-pkcs5-pad](cloudhsm_cli-key-wrap-aes-pkcs5-pad.md) | 使用 HSM 上的 AES 密钥和 AES PKCS5--PAD 包装机制封装有效载荷密钥。 | CU | 
| [aes-zero-pad](cloudhsm_cli-key-wrap-aes-zero-pad.md) | 使用 HSM 上的 AES 密钥和 AES-ZERO-PAD包装机制封装有效载荷密钥。 | CU | 
| [cloudhsm-aes-gcm](cloudhsm_cli-key-wrap-cloudhsm-aes-gcm.md) | 使用 HSM 上的 AES 密钥和 CLOUDHSM-AES-GCM包装机制封装有效载荷密钥。 | CUs | 
| [rsa-aes](cloudhsm_cli-key-wrap-rsa-aes.md) | 使用 HSM 上的 RSA 公有密钥和 RSA-AES 包装机制来包装有效载荷密钥。 | CU | 
| [rsa-oaep](cloudhsm_cli-key-wrap-rsa-oaep.md) | 使用 HSM 上的 RSA 公有密钥和 RSA-OAEP 包装机制来包装有效载荷密钥。 | CU | 
| [ 使用 CloudHSM CLI 通过 RSA-PKCS 解包密钥rsa-pkcs  **key wrap rsa-pkcs** 命令使用 HSM 上的 RSA 公有密钥和 `RSA-PKCS` 包装机制来包装有效载荷密钥。   使用 CloudHSM CLI 中的 **key wrap rsa-pkcs** 命令通过硬件安全模块（HSM）上的 RSA 公有密钥和 `RSA-PKCS` 包装机制包装有效载荷密钥。有效载荷密钥的 `extractable` 属性必须设置为 `true`。 只有密钥的所有者（即创建密钥的加密用户（CU））才能包装密钥。共享密钥的用户可以使用该密钥进行加密操作。 要使用该**key wrap rsa-pkcs**命令，您必须先在 AWS CloudHSM 集群中拥有 RSA 密钥。可以使用 [CloudHSM CLI 中的 generate-asymmetric-pair类别](cloudhsm_cli-key-generate-asymmetric-pair.md) 命令并将 `wrap` 属性设置为 `true` 生成 RSA 密钥对。  用户类型  以下类型的用户均可运行此命令。   加密用户 (CUs)     要求    要运行此命令，必须以 CU 身份登录。     语法  

```
aws-cloudhsm > help key wrap rsa-pkcs
Usage: key wrap rsa-pkcs [OPTIONS] --payload-filter [<PAYLOAD_FILTER>...] --wrapping-filter [<WRAPPING_FILTER>...]

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
      --payload-filter [<PAYLOAD_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 payload key
      --wrapping-filter [<WRAPPING_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 wrapping key
      --path <PATH>
          Path to the binary file where the wrapped key data will be saved
      --wrapping-approval <WRAPPING_APPROVALR>
          File path of signed quorum token file to approve operation for wrapping key
      --payload-approval <PAYLOAD_APPROVALR>
          File path of signed quorum token file to approve operation for payload key
  -h, --help
          Print help
```   示例  此示例演示如何通过 RSA 公有密钥使用 **key wrap rsa-pkcs** 命令。 

**Example**  

```
aws-cloudhsm > key wrap rsa-pkcs --payload-filter attr.label=payload-key --wrapping-filter attr.label=rsa-public-key-example
{
  "error_code": 0,
  "data": {
    "payload_key_reference": "0x00000000001c08f1",
    "wrapping_key_reference": "0x00000000007008da",
    "wrapped_key_data": "am0Nc7+YE8FWs+5HvU7sIBcXVb24QA0l65nbNAD+1bK+e18BpSfnaI3P+r8Dp+pLu1ofoUy/vtzRjZoCiDofcz4EqCFnGl4GdcJ1/3W/5WRvMatCa2d7cx02swaeZcjKsermPXYRO1lGlfq6NskwMeeTkV8R7Rx9artFrs1y0DdIgIKVaiFHwnBIUMnlQrR2zRmMkfwU1jxMYmOYyD031F5VbnjSrhfMwkww2la7uf/c3XdFJ2+0Bo94c6og/yfPcpOOobJlITCoXhtMRepSdO4OggYq/6nUDuHCtJ86pPGnNahyr7+sAaSI3a5ECQLUjwaIARUCyoRh7EFK3qPXcg=="
  }
```   参数   

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。 

***<PAYLOAD\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择有效载荷密钥。  
是否必需：是 

***<PATH>***  
保存包装密钥数据的二进制文件的路径。  
必需：否 

***<WRAPPING\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择包装密钥。  
是否必需：是 

***<WRAPPING\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准包装密钥的操作。仅当包装密钥的密钥管理服务仲裁值大于 1 时才需要。 

***<PAYLOAD\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准有效载荷密钥的操作。仅当有效载荷密钥的密钥管理服务仲裁值大于 1 时才需要。    相关主题    [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)   [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)    ](cloudhsm_cli-key-wrap-rsa-pkcs.md) | 使用 HSM 上的 RSA 公有密钥和 RSA-PKCS 包装机制来包装有效载荷密钥。 | CU | 
| [login](cloudhsm_cli-login.md) | 登录您的集 AWS CloudHSM 群。 | 管理员、加密用户 (CU) 和应用程序用户 (AU) | 
| [logout](cloudhsm_cli-logout.md) | 注销您的 AWS CloudHSM 集群。 | 管理员、加密用户 (CU) 和应用程序用户 (AU, appliance user) | 
| [quorum token-sign delete](cloudhsm_cli-qm-token-del.md) | 删除仲裁授权服务的一个或多个令牌。 | Admin | 
| [quorum token-sign generate](cloudhsm_cli-qm-token-gen.md) | 为仲裁授权服务生成令牌。 | Admin | 
| [quorum token-sign list](cloudhsm_cli-qm-token-list.md) | 列出您的 CloudHSM 集群中存在的所有令牌签名仲裁令牌。 | 全部 [1](#cli-ref-1)，包括未经身份验证的用户。不需要登录名。 | 
| [法定代币符号 list-quorum-values](cloudhsm_cli-qm-token-list-qm.md) | 列出您的 CloudHSM 集群中设置的仲裁值。 | 全部 [1](#cli-ref-1)，包括未经身份验证的用户。不需要登录名。 | 
| [法定代币符号 set-quorum-value](cloudhsm_cli-qm-token-set-qm.md) | 为仲裁授权服务设置新的仲裁值。 | Admin | 
| [user change-mfa](cloudhsm_cli-user-change-mfa.md) | 更改用户的多重身份验证 (MFA, multi-factor authentication) 策略。 | 管理员，CU | 
| [user change-password](cloudhsm_cli-user-change-password.md) | 在上更改用户的密码 HSMs。所有用户都可更改自己的密码。管理员可以更改任何人的密码。 | 管理员，CU | 
| [user create](cloudhsm_cli-user-create.md) | 在您的 AWS CloudHSM 集群中创建用户。 | Admin | 
| [user delete](cloudhsm_cli-user-delete.md) | 删除集 AWS CloudHSM 群中的用户。 | Admin | 
| [user list](cloudhsm_cli-user-list.md) | 列出 AWS CloudHSM 集群中的用户。 | 全部 [1](#cli-ref-1)，包括未经身份验证的用户。不需要登录名。 | 
| [user change-quorum token-sign register](cloudhsm_cli-user-chqm-token-reg.md) | 为用户注册仲裁令牌签名仲裁策略。 | Admin | 

**Annotations**
+ [1] 所有用户包括所有列出的角色和未登录的用户。

# CloudHSM CLI 中的 cluster 类别
<a name="cloudhsm_cli-cluster"></a>

在 CloudHSM CLI 中，**cluster** 是一组命令的父类别，当这些命令与父类别结合使用时，会创建特定于集群的命令。当前，cluster 类别由以下命令组成：

**Topics**
+ [激活](cloudhsm_cli-cluster-activate.md)
+ [hsm-info](cloudhsm_cli-cluster-hsm-info.md)
+ [mtls](cloudhsm_cli-cluster-mtls.md)

# 使用 CloudHSM CLI 激活集群
<a name="cloudhsm_cli-cluster-activate"></a>

使用 CloudHSM CLI 中的 **cluster activate** 命令在 AWS CloudHSM中[激活新集群](activate-cluster.md)。使用该集群执行加密操作之前，必须运行该命令。

## 用户类型
<a name="cluster-activate-userType"></a>

以下类型的用户均可运行此命令。
+ 未激活的管理员

## 语法
<a name="chsm-cli-cluster-activate-syntax"></a>

此命令没有输出参数。

```
aws-cloudhsm > help cluster activate
Activate a cluster

This command will set the initial Admin password. This process will cause your CloudHSM cluster to
move into the ACTIVE state.

USAGE:
    cloudhsm-cli cluster activate [OPTIONS] [--password <PASSWORD>]

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

      --password <PASSWORD>
          Optional: Plaintext activation password If you do not include this argument you will be prompted for it

  -h, --help
          Print help (see a summary with '-h')
```

## 示例
<a name="chsm-cli-cluster-activate-examples"></a>

此命令通过为您的管理员用户设置初始密码来激活您的集群。

```
aws-cloudhsm > cluster activate
Enter password:
Confirm password:
{
  "error_code": 0,
  "data": "Cluster activation successful"
}
```

## 相关主题
<a name="chsm-cluster-activate-seealso"></a>
+ [user create](cloudhsm_cli-user-create.md)
+ [user delete](cloudhsm_cli-user-delete.md)
+ [user change-password](cloudhsm_cli-user-change-password.md)

# HSMs 使用 CloudHSM CLI 列出
<a name="cloudhsm_cli-cluster-hsm-info"></a>

使用 CloudHSM CLI 中的**cluster hsm-info**命令列出集群中的硬件安全HSMs模块 () AWS CloudHSM 。您不必登录 CloudHSM CLI 即可运行此命令。

**注意**  
如果添加或删除 HSMs，请更新 AWS CloudHSM 客户端和命令行工具使用的配置文件。否则，您所做的更改可能不会对集群 HSMs 中的所有人生效。

## 用户类型
<a name="chsm-cluster-hsm-info-userType"></a>

以下类型的用户均可运行此命令。
+ 所有用户。您不必登录即可运行此命令。

## 语法
<a name="chsm-cluster-hsm-info-syntax"></a>

```
aws-cloudhsm > help cluster hsm-info
List info about each HSM in the cluster

Usage: cloudhsm-cli cluster hsm-info [OPTIONS]

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
  -h, --help                     Print help
```

## 示例
<a name="chsm-cluster-hsm-info-examples"></a>

此命令列出了您的 AWS CloudHSM 集群中 HSMs 存在的内容。

```
aws-cloudhsm > cluster hsm-info
{
  "error_code": 0,
  "data": {
    "hsms": [
      {
        "vendor": "Marvell Semiconductors, Inc.",
        "model": "NITROX-III CNN35XX-NFBE",
        "serial-number": "5.3G1941-ICM000590",
        "hardware-version-major": "5",
        "hardware-version-minor": "3",
        "firmware-version-major": "2",
        "firmware-version-minor": "6",
        "firmware-build-number": "16",
        "firmware-id": "CNN35XX-NFBE-FW-2.06-16"
        "fips-state": "2 [FIPS mode with single factor authentication]"
      },
      {
        "vendor": "Marvell Semiconductors, Inc.",
        "model": "NITROX-III CNN35XX-NFBE",
        "serial-number": "5.3G1941-ICM000625",
        "hardware-version-major": "5",
        "hardware-version-minor": "3",
        "firmware-version-major": "2",
        "firmware-version-minor": "6",
        "firmware-build-number": "16",
        "firmware-id": "CNN35XX-NFBE-FW-2.06-16"
        "fips-state": "2 [FIPS mode with single factor authentication]"
      },
      {
        "vendor": "Marvell Semiconductors, Inc.",
        "model": "NITROX-III CNN35XX-NFBE",
        "serial-number": "5.3G1941-ICM000663",
        "hardware-version-major": "5",
        "hardware-version-minor": "3",
        "firmware-version-major": "2",
        "firmware-version-minor": "6",
        "firmware-build-number": "16",
        "firmware-id": "CNN35XX-NFBE-FW-2.06-16"
        "fips-state": "2 [FIPS mode with single factor authentication]"
      }
    ]
  }
}
```

输出具有以下属性：
+ **供应商**：HSM 的供应商名称。
+ **模型**：HSM 的型号。
+ **序列号** ：设备的序列号。情况可能因替换而变化。
+ **H ardware-version-major**：主要硬件版本。
+ **H ardware-version-minor**：次要硬件版本。
+ **F irmware-version-major**：主要固件版本。
+ **F irmware-version-minor**：次要固件版本。
+ **F irmware-build-number**：固件版本号。
+ **Firmware-id**：固件 ID，包括主要版本、次要版本和生成版本。
+ **FIPS 状态**：集群及其中的 FIPS 模式。 HSMs 如果处于 FIPS 模式，则输出为“2 [FIPS mode with single factor authentication]”。如果处于非 FIPS 模式，则输出为“0 [non-FIPS mode with single factor authentication]”。

## 相关主题
<a name="chsm-cluster-hsm-info-seealso"></a>
+ [使用 CloudHSM CLI 激活集群](cloudhsm_cli-cluster-activate.md)

# CloudHSM CLI 中的 cluster mtls 类别
<a name="cloudhsm_cli-cluster-mtls"></a>

在 CloudHSM **cluster mtls** CLI 中，是一组命令的父类别，当这些命令与父类别结合使用时，将创建特定于集群的命令 AWS CloudHSM 。目前，此类别由以下命令组成：

**Topics**
+ [deregister-trust-anchor](cloudhsm_cli-cluster-mtls-deregister-trust-anchor.md)
+ [get-enforcement](cloudhsm_cli-cluster-mtls-get-enforcement.md)
+ [list-trust-anchors](cloudhsm_cli-cluster-mtls-list-trust-anchors.md)
+ [register-trust-anchor](cloudhsm_cli-cluster-mtls-register-trust-anchor.md)
+ [set-enforcement](cloudhsm_cli-cluster-mtls-set-enforcement.md)

# 使用 CloudHSM CLI 取消注册信任锚
<a name="cloudhsm_cli-cluster-mtls-deregister-trust-anchor"></a>

使用 CloudHSM CLI 中的 **cluster mtls deregister-trust-anchor** 命令取消注册客户端和 AWS CloudHSM之间双向 TLS 的信任锚。

## 用户类型
<a name="cluster-mtls-deregister-trust-anchor-userType"></a>

以下用户均可运行此命令。
+ Admin

## 要求
<a name="cluster-mtls-deregister-trust-anchor-requirements"></a>
+ 要运行此命令，您必须以管理员用户身份登录。

## 语法
<a name="cluster-mtls-deregister-trust-anchor-syntax"></a>

```
aws-cloudhsm > help cluster mtls deregister-trust-anchor
            
Deregister a trust anchor for mtls

Usage: cluster mtls deregister-trust-anchor [OPTIONS] --certificate-reference [<CERTIFICATE_REFERENCE>...]

Options:
      --certificate-reference <CERTIFICATE_REFERENCE>  A hexadecimal or decimal certificate reference
      --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
      --approval <APPROVAL>  Filepath of signed quorum token file to approve operation
  -h, --help                     Print help
```

## 示例
<a name="cluster-mtls-deregister-trust-anchor-examples"></a>

**Example**  
在以下示例中，此命令将从 HSM 中删除信任锚。  

```
aws-cloudhsm > cluster mtls deregister-trust-anchor --certificate-reference 0x01
                
{
  "error_code": 0,
  "data": {
    "message": "Trust anchor with reference 0x01 deregistered successfully"
  }
}
```
然后，您可以运行 **list-trust-anchors** 命令来确认信任锚已从 AWS CloudHSM中取消注册：  

```
aws-cloudhsm > cluster mtls list-trust-anchors
                
{
  "error_code": 0,
  "data": {
    "trust_anchors": []
  }
}
```

## 参数
<a name="cluster-mtls-deregister-trust-anchor-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

** *<CERTIFICATE\$1REFERENCE>* **  
十六进制或十进制证书引用。  
 **是否必需**：是  
在集群中取消注册信任锚后，使用该信任锚签名的客户端证书的所有现有 mTLS 连接都将被断开。

** *<APPROVAL>* **  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当仲裁集群服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cluster-mtls-deregister-trust-anchor-seealso"></a>
+  [集群 mtls reregister-trust-anchor](cloudhsm_cli-cluster-mtls-register-trust-anchor.md) 
+  [集群 mtls list-trust-anchors](cloudhsm_cli-cluster-mtls-list-trust-anchors.md) 
+  [设置 mTLS（推荐）](getting-started-setup-mtls.md) 

# 使用 CloudHSM CLI 获取 mTLS 强制执行级别
<a name="cloudhsm_cli-cluster-mtls-get-enforcement"></a>

使用 CloudHSM CLI 中的 **cluster mtls get-enforcement** 命令来获取客户端和 AWS CloudHSM之间双向 TLS 使用的执行级别。

## 用户类型
<a name="cluster-mtls-get-enforcement-userType"></a>

以下用户均可运行此命令。
+ Admin
+ 加密用户 (CUs)

## 要求
<a name="cluster-mtls-get-enforcement-requirements"></a>
+ 要运行此命令，您必须以管理员用户或加密用户（CUs）的身份登录。

## 语法
<a name="cluster-mtls-get-enforcement-syntax"></a>

```
aws-cloudhsm > help cluster mtls get-enforcement
            
Get the status of mtls enforcement in the cluster

Usage: cluster mtls get-enforcement [OPTIONS]

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
  -h, --help                     Print help
```

## 示例
<a name="cluster-mtls-get-enforcement-examples"></a>

**Example**  
在以下示例中，此命令列出了 AWS CloudHSM的 mtls 强制执行级别。  

```
aws-cloudhsm > cluster mtls get-enforcement
                
{
  "error_code": 0,
  "data": {
    "mtls-enforcement-level": "none"
  }
}
```

## 参数
<a name="cluster-mtls-get-enforcement-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

## 相关主题
<a name="cluster-mtls-get-enforcement-seealso"></a>
+  [cluster mtls set-enforcement](cloudhsm_cli-cluster-mtls-set-enforcement.md) 
+  [设置 mTLS（推荐）](getting-started-setup-mtls.md) 

# 使用 CloudHSM CLI 列出信任锚
<a name="cloudhsm_cli-cluster-mtls-list-trust-anchors"></a>

使用 CloudHSM CLI 中的 **cluster mtls list-trust-anchors** 命令列出可用于客户端与 AWS CloudHSM之间的双向 TLS 的所有信任锚。

## 用户类型
<a name="cluster-mtls-list-trust-anchors-userType"></a>

以下用户均可运行此命令。
+ 所有用户。您不必登录即可运行此命令。

## 语法
<a name="cluster-mtls-list-trust-anchors-syntax"></a>

```
aws-cloudhsm > help cluster mtls list-trust-anchors
            
List all trust anchors for mtls

Usage: cluster mtls list-trust-anchors [OPTIONS]

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
  -h, --help                     Print help
```

## 示例
<a name="cluster-mtls-list-trust-anchors-examples"></a>

**Example**  
在以下示例中，此命令列出了 AWS CloudHSM中所有已注册的信任锚。  

```
aws-cloudhsm > cluster mtls list-trust-anchors
                
{
  "error_code": 0,
  "data": {
    "trust_anchors": [
      {
        "certificate-reference": "0x01",
        "certificate": "<PEM Encoded Certificate 1>",
        "cluster-coverage": "full"
      },
      {
        "certificate-reference": "0x02",
        "certificate": "<PEM Encoded Certificate 2>",
        "cluster-coverage": "full"
      }
    ]
  }
}
```

## 参数
<a name="cluster-mtls-list-trust-anchors-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

## 相关主题
<a name="cluster-mtls-register-trust-anchor-seealso"></a>
+  [集群 mtls reregister-trust-anchor](cloudhsm_cli-cluster-mtls-register-trust-anchor.md) 
+  [集群 mtls deregister-trust-anchor](cloudhsm_cli-cluster-mtls-deregister-trust-anchor.md) 
+  [设置 mTLS（推荐）](getting-started-setup-mtls.md) 

# 使用 CloudHSM CLI 注册信任锚
<a name="cloudhsm_cli-cluster-mtls-register-trust-anchor"></a>

使用 CloudHSM CLI 中的 **cluster mtls register-trust-anchor** 命令注册客户端和 AWS CloudHSM之间双向 TLS 的信任锚。

## 用户类型
<a name="cluster-mtls-register-trust-anchor-userType"></a>

以下用户均可运行此命令。
+ Admin

## 要求
<a name="cluster-mtls-register-trust-anchor-requirements"></a>

 AWS CloudHSM 接受具有以下密钥类型的信任锚：


****  

| 密钥类型 | 说明 | 
| --- | --- | 
| EC |  secp256r1（P-256）、secp384r1（P-384）和 secp521r1（P-521）曲线。 | 
| RSA |  2048 位、3072 位和 4096 位 RSA 密钥。 | 

## 语法
<a name="cluster-mtls-register-trust-anchor-syntax"></a>

```
aws-cloudhsm > help cluster mtls register-trust-anchor
            
Register a trust anchor for mtls

Usage: cluster mtls register-trust-anchor [OPTIONS] --path [<PATH>...]

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
      --path <PATH>  Filepath of the trust anchor to register
      --approval <APPROVAL>  Filepath of signed quorum token file to approve operation
  -h, --help                     Print help
```

## 示例
<a name="cluster-mtls-register-trust-anchor-examples"></a>

**Example**  
在以下示例中，此命令将信任锚注册到 HSM 上。最多可注册两个（2）个信任锚。  

```
aws-cloudhsm > cluster mtls register-trust-anchor --path /home/rootCA
                
{
  "error_code": 0,
  "data": {
    "trust_anchor": {
      "certificate-reference": "0x01",
      "certificate": "<PEM Encoded Certificate>",
      "cluster-coverage": "full"
    }
  }
}
```
然后，您可以运行 **list-trust-anchors** 命令来确认信任锚已注册到 AWS CloudHSM上：  

```
aws-cloudhsm > cluster mtls list-trust-anchors
                
{
  "error_code": 0,
  "data": {
    "trust_anchors": [
      {
        "certificate-reference": "0x01",
        "certificate": "<PEM Encoded Certificate>",
        "cluster-coverage": "full"
      }
    ]
  }
}
```

## 参数
<a name="cluster-mtls-register-trust-anchor-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

** *<PATH>* **  
要注册的信任锚的文件路径。  
 **是否必需**：是  
AWS CloudHSM 支持将中间证书注册为信任锚点。在这种情况下，需要将整个 PEM 编码的证书链文件注册到 HSM 上，并以分层顺序排列证书。  
 AWS CloudHSM 支持 6980 字节的证书链。

** *<APPROVAL>* **  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当仲裁集群服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cluster-mtls-register-trust-anchor-seealso"></a>
+  [集群 mtls deregister-trust-anchor](cloudhsm_cli-cluster-mtls-deregister-trust-anchor.md) 
+  [集群 mtls list-trust-anchors](cloudhsm_cli-cluster-mtls-list-trust-anchors.md) 
+  [设置 mTLS（推荐）](getting-started-setup-mtls.md) 

# 使用 CloudHSM CLI 设置 mTLS 的强制执行级别
<a name="cloudhsm_cli-cluster-mtls-set-enforcement"></a>

使用 CloudHSM CLI 中的 **cluster mtls set-enforcement** 命令来设置客户端和 AWS CloudHSM之间双向 TLS 使用的强制执行级别。

## 用户类型
<a name="cluster-mtls-set-enforcement-userType"></a>

以下用户均可运行此命令。
+ 用户名为 admin 的管理员

## 要求
<a name="cluster-mtls-set-enforcement-requirements"></a>

要运行此命令：
+ 至少有一个信任锚已成功注册到 AWS CloudHSM上。
+ 使用正确的私有密钥和客户端证书配置 CloudHSM CLI，然后在双向 TLS 连接下启动 CloudHSM CLI。
+ 您必须以用户名为“admin”的默认管理员身份登录。任何其他管理员用户都将无法运行此命令。

## 语法
<a name="cluster-mtls-set-enforcement-syntax"></a>

```
aws-cloudhsm > help cluster mtls set-enforcement
            
Set mtls enforcement policy in the cluster

Usage: cluster mtls set-enforcement [OPTIONS] --level [<LEVEL>...]

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
      --level <LEVEL>  Level to be set for mtls in the cluster [possible values: none, cluster]
      --approval <APPROVAL>  Filepath of signed quorum token file to approve operation
  -h, --help                     Print help
```

## 示例
<a name="cluster-mtls-set-enforcement-examples"></a>

**Example**  
在以下示例中，此命令将的 mtls 强制级别设置 AWS CloudHSM 为集群。set-enforcement 命令只能在双向 TLS 连接中执行，并以用户名为 admin 的管理员用户身份登录，请参阅 [set the mTLS enforcement for AWS CloudHSM](getting-started-setup-mtls.md#getting-start-setup-mtls-enforcement)。  

```
aws-cloudhsm > cluster mtls set-enforcement --level cluster
                
{
  "error_code": 0,
  "data": {
    "message": "Mtls enforcement level set to Cluster successfully"
  }
}
```
然后，您可以运行 **get-enforcement** 命令来确认强制执行级别已设置为集群：  

```
aws-cloudhsm > cluster mtls get-enforcement
                
{
  "error_code": 0,
  "data": {
    "mtls-enforcement-level": "cluster"
  }
}
```

## 参数
<a name="cluster-mtls-set-enforcement-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

** *<LEVEL>* **  
要为集群中的 mtls 设置的级别。  
 **有效值**   
+  **集群**：强制在客户端和集群 AWS CloudHSM 中使用双向 TLS。
+  **none**：不要强制在客户端和集群 AWS CloudHSM 中使用双向 TLS。
 **是否必需**：是  
在集群中强制执行 mTLS 使用后，所有现有非 mTLS 连接都将被丢弃，并且您只能使用 mTLS 证书连接到集群。

** *<APPROVAL>* **  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当仲裁集群服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cluster-mtls-set-enforcement-seealso"></a>
+  [集群 mtls 获取强制执行](cloudhsm_cli-cluster-mtls-get-enforcement.md) 
+  [设置 mTLS（推荐）](getting-started-setup-mtls.md) 

# CloudHSM CLI 中的 crypto 类别
<a name="cloudhsm_cli-crypto"></a>

在 CloudHSM CLI 中，**crypto** 是一组命令的父类别，当这些命令与父类别结合使用时，将创建特定于加密操作的命令。目前，此类别由以下命令组成：
+ [注](cloudhsm_cli-crypto-sign.md)
  + [ecdsa](cloudhsm_cli-crypto-sign-ecdsa.md)
  + [ed25519ph](cloudhsm_cli-crypto-sign-ed25519ph.md)
  + [rsa-pkcs](cloudhsm_cli-crypto-sign-rsa-pkcs.md)
  + [rsa-pkcs-pss](cloudhsm_cli-crypto-sign-rsa-pkcs-pss.md)
+ [确认](cloudhsm_cli-crypto-verify.md)
  + [ecdsa](cloudhsm_cli-crypto-verify-ecdsa.md)
  + [ed25519ph](cloudhsm_cli-crypto-verify-ed25519ph.md)
  + [rsa-pkcs](cloudhsm_cli-crypto-verify-rsa-pkcs.md)
  + [rsa-pkcs-pss](cloudhsm_cli-crypto-verify-rsa-pkcs-pss.md)

# CloudHSM CLI 中的 crypto sign 类别
<a name="cloudhsm_cli-crypto-sign"></a>

在 CloudHSM CLI 中，**crypto sign** 是一组命令的父类别，当这些命令与父类别结合使用时，会使用 AWS CloudHSM 集群中选定的私有密钥生成签名。**crypto sign** 具有以下子命令：
+ [在 CloudHSM CLI 中使用 ECDSA 机制生成签名](cloudhsm_cli-crypto-sign-ecdsa.md)
+ [在 CloudHSM CLI 中使用 HashEd DSA 机制生成签名](cloudhsm_cli-crypto-sign-ed25519ph.md)
+ [在 CloudHSM CLI 中使用 RSA-PKCS 机制生成签名](cloudhsm_cli-crypto-sign-rsa-pkcs.md)
+ [使用 CloudHSM CL RSA-PKCS-PSS I 中的机制生成签名](cloudhsm_cli-crypto-sign-rsa-pkcs-pss.md)

要使用 **crypto sign**，您必须拥有 HSM 中的私有密钥。您可以使用以下命令生成私有密钥：
+ [key generate-asymmetric-pair ec](cloudhsm_cli-key-generate-asymmetric-pair-ec.md)
+ [密钥 generate-asymmetric-pair rsa](cloudhsm_cli-key-generate-asymmetric-pair-rsa.md)

# 在 CloudHSM CLI 中使用 ECDSA 机制生成签名
<a name="cloudhsm_cli-crypto-sign-ecdsa"></a>

使用 CloudHSM CLI 中的 **crypto sign ecdsa** 命令通过 EC 私有密钥和 ECDSA 签名机制生成签名。

要使用该**crypto sign ecdsa**命令，您的 AWS CloudHSM 集群中必须首先有一个 EC 私钥。您可以使用 `sign` 属性设置为 `true` 的 [使用 CloudHSM CLI 生成非对称 EC 密钥对](cloudhsm_cli-key-generate-asymmetric-pair-ec.md) 命令生成 EC 私有密钥。

生成的 ECDSA 签名采用以下格式生成`r||s`，其中 r 和 s 分量作为原始二进制数据连接并以 base64 编码格式返回。

**注意**  
可以使用[CloudHSM CLI 中的 crypto verify 类别](cloudhsm_cli-crypto-verify.md)子命令验证签名。 AWS CloudHSM 

## 用户类型
<a name="cloudhsm_cli-crypto-sign-ecdsa-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-crypto-sign-ecdsa-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-crypto-sign-ecdsa-syntax"></a>

```
aws-cloudhsm > help crypto sign ecdsa
Sign with the ECDSA mechanism

Usage: crypto sign ecdsa --key-filter [<KEY_FILTER>>...] --hash-function <HASH_FUNCTION> <--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
      --key-filter [<KEY_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 matching key
      --hash-function <HASH_FUNCTION>
          [possible values: sha1, sha224, sha256, sha384, sha512]
      --data-path <DATA_PATH>
          The path to the file containing the data to be signed
      --data <DATA>
          Base64 Encoded data to be signed
      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation
      --data-type <DATA_TYPE>
          The type of data passed in, either raw or digest [possible values: raw, digest]
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-crypto-sign-ecdsa-examples"></a>

这些示例说明了如何使用 **crypto sign ecdsa** 通过 ECDSA 签名机制和 `SHA256` 哈希函数生成签名。此命令在 HSM 中使用私有密钥。

**Example 示例：为 base 64 编码的数据生成签名**  

```
aws-cloudhsm > crypto sign ecdsa --key-filter attr.label=ec-private --hash-function sha256 --data YWJjMTIz
{
  "error_code": 0,
  "data": {
    "key-reference": "0x00000000007808dd",
    "signature": "4zki+FzjhP7Z/KqoQvh4ueMAxQQVp7FQguZ2wOS3Q5bzk+Hc5irV5iTkuxQbropPttVFZ8V6FgR2fz+sPegwCw=="
  }
}
```

**Example 示例：为数据文件生成签名**  

```
aws-cloudhsm > crypto sign ecdsa --key-filter attr.label=ec-private --hash-function sha256 --data-path data.txt
{
  "error_code": 0,
  "data": {
    "key-reference": "0x00000000007808dd",
    "signature": "4zki+FzjhP7Z/KqoQvh4ueMAxQQVp7FQguZ2wOS3Q5bzk+Hc5irV5iTkuxQbropPttVFZ8V6FgR2fz+sPegwCw=="
  }
}
```

## 参数
<a name="cloudhsm_cli-crypto-sign-ecdsa-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<DATA>***  
要签名的 Base64 编码数据。  
必需：是（除非通过数据路径提供）

***<DATA\$1PATH>***  
指定要签名的数据的位置。  
必需：是（除非通过数据路径提供）

***<HASH\$1FUNCTION>***  
指定哈希函数。  
有效值：  
+ sha1
+ sha224
+ sha256
+ sha384
+ sha512
是否必需：是

***<KEY\$1FILTER>***  
密钥引用（例如，`key-reference=0xabc`）或空格分隔的密钥属性列表，采用 attr.KEY\$1ATTRIBUTE\$1NAME=KEY\$1ATTRIBUTE\$1VALUE 形式，可选择匹配密钥。  
有关支持的 CloudHSM CLI key 密钥属性列表，请参阅“Key attributes for CloudHSM CLI”。  
是否必需：是

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当私有密钥的密钥使用服务仲裁值大于 1 时才需要。

***<DATA\$1TYPE>***  
 指定是否应将数据参数的值作为签名算法的一部分进行哈希处理。`raw` 用于未经过哈希处理的数据；`digest` 用于已经过哈希处理的摘要。  
有效值：  
+ raw
+ 摘要

## 相关主题
<a name="cloudhsm_cli-crypto-sign-ecdsa-seealso"></a>
+ [CloudHSM CLI 中的 crypto sign 类别](cloudhsm_cli-crypto-sign.md)
+ [CloudHSM CLI 中的 crypto verify 类别](cloudhsm_cli-crypto-verify.md)

# 在 CloudHSM CLI 中使用 HashEd DSA 机制生成签名
<a name="cloudhsm_cli-crypto-sign-ed25519ph"></a>

**重要**  
HashEd仅在非 FIPS 模式下的 hsm2m.medium 实例上支持 DSA 签名操作。

使用 CloudHSM CLI 中的**crypto sign ed25519ph**命令使用 Ed25519 私钥和 DSA 签名机制生成签名。 HashEd有关 HashEd DSA 的更多信息，请参阅 [NIST SP 186-5](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-5.pdf)，第 7.8 节。

要使用该**crypto sign ed25519ph**命令，您的集群中必须首先有一个 Ed25519 私钥。 AWS CloudHSM 您可以使用`curve`参数设置为、`sign`属性设置为的[使用 CloudHSM CLI 生成非对称 EC 密钥对](cloudhsm_cli-key-generate-asymmetric-pair-ec.md)命令生成 Ed25519 私钥。`ed25519` `true`

**注意**  
可以使用[CloudHSM CLI 中的 crypto verify 类别](cloudhsm_cli-crypto-verify.md)子命令验证签名。 AWS CloudHSM 

## 用户类型
<a name="cloudhsm_cli-crypto-sign-ed25519ph-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-crypto-sign-ed25519ph-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。
+ HashEd仅在非 FIPS 模式下的 hsm2m.medium 实例上支持 DSA 签名操作。

## 语法
<a name="cloudhsm_cli-crypto-sign-ed25519ph-syntax"></a>

```
aws-cloudhsm > help crypto sign ed25519ph
Sign with the Ed25519ph mechanism

Usage: crypto sign ed25519ph [OPTIONS] --key-filter [<KEY_FILTER>...] --data-type <DATA_TYPE> --hash-function <HASH_FUNCTION> <--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
      --key-filter [<KEY_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 matching key
      --data-path <DATA_PATH>
          The path to the file containing the data to be signed
      --data <DATA>
          Base64 Encoded data to be signed
      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation
      --data-type <DATA_TYPE>
          The type of data passed in, either raw or digest [possible values: raw, digest]
      --hash-function <HASH_FUNCTION>
          Hash function [possible values: sha512]
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-crypto-sign-ed25519ph-examples"></a>

这些示例说明**crypto sign ed25519ph**如何使用 ed25519ph 签名机制和哈希函数生成签名。`sha512`此命令在 HSM 中使用私有密钥。

**Example 示例：为 base 64 编码的数据生成签名**  

```
aws-cloudhsm > crypto sign ed25519ph \
    --key-filter attr.label=ed25519-private \
    --data-type raw \
    --hash-function sha512 \
    --data YWJj
{
  "error_code": 0,
  "data": {
    "key-reference": "0x0000000000401cdf",
    "signature": "mKcCIvC4Ehqp0w+BPWg/gJ5GK0acf/h2OUmbuU5trkEx+FBCRjwqNVogA9BirfWqoQuMYeY2Biqq0RwqJgg0Bg=="
  }
}
```

**Example 示例：为数据文件生成签名**  

```
aws-cloudhsm > crypto sign ed25519ph \
    --key-filter attr.label=ed25519-private \
    --data-type raw \
    --hash-function sha512 \
    --data-path data.txt
{
  "error_code": 0,
  "data": {
    "key-reference": "0x0000000000401cdf",
    "signature": "mKcCIvC4Ehqp0w+BPWg/gJ5GK0acf/h2OUmbuU5trkEx+FBCRjwqNVogA9BirfWqoQuMYeY2Biqq0RwqJgg0Bg=="
  }
}
```

## 参数
<a name="cloudhsm_cli-crypto-sign-ed25519ph-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<DATA>***  
要签名的 Base64 编码数据。  
必需：是（除非通过数据路径提供）

***<DATA\$1PATH>***  
指定要签名的数据的位置。  
必填项：是（除非通过 data 参数提供）

***<HASH\$1FUNCTION>***  
指定哈希函数。ed25519pH 仅支持。 SHA512  
有效值：  
+ sha512
是否必需：是

***<KEY\$1FILTER>***  
密钥引用（例如，`key-reference=0xabc`）或空格分隔的密钥属性列表，采用 attr.KEY\$1ATTRIBUTE\$1NAME=KEY\$1ATTRIBUTE\$1VALUE 形式，可选择匹配密钥。  
有关支持的 CloudHSM CLI 密钥属性的列表，请参阅。[CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)  
是否必需：是

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当私有密钥的密钥使用服务仲裁值大于 1 时才需要。

***<DATA\$1TYPE>***  
 指定是否应将数据参数的值作为签名算法的一部分进行哈希处理。`raw` 用于未经过哈希处理的数据；`digest` 用于已经过哈希处理的摘要。  
有效值：  
+ raw
+ 摘要
是否必需：是

## 相关主题
<a name="cloudhsm_cli-crypto-sign-ed25519ph-seealso"></a>
+ [CloudHSM CLI 中的 crypto sign 类别](cloudhsm_cli-crypto-sign.md)
+ [CloudHSM CLI 中的 crypto verify 类别](cloudhsm_cli-crypto-verify.md)

# 在 CloudHSM CLI 中使用 RSA-PKCS 机制生成签名
<a name="cloudhsm_cli-crypto-sign-rsa-pkcs"></a>

使用 CloudHSM CLI 中的 **crypto sign rsa-pkcs** 命令通过 RSA 私有密钥和 RSA-PKCS 签名机制生成签名。

要使用该**crypto sign rsa-pkcs**命令，您的 AWS CloudHSM 集群中必须首先有一个 RSA 私钥。您可以使用 `sign` 属性设置为 `true` 的 [使用 CloudHSM CLI 生成非对称 RSA 密钥对](cloudhsm_cli-key-generate-asymmetric-pair-rsa.md) 命令生成 RSA 私有密钥。

**注意**  
可以使用[CloudHSM CLI 中的 crypto verify 类别](cloudhsm_cli-crypto-verify.md)子命令验证签名。 AWS CloudHSM 

## 用户类型
<a name="cloudhsm_cli-crypto-sign-rsa-pkcs-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-crypto-sign-rsa-pkcs-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-crypto-sign-rsa-pkcs-syntax"></a>

```
aws-cloudhsm > help crypto sign rsa-pkcs
Sign with the RSA-PKCS mechanism

Usage: crypto sign rsa-pkcs --key-filter [<KEY_FILTER>>...] --hash-function <HASH_FUNCTION> <--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
      --key-filter [<KEY_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 matching key
      --hash-function <HASH_FUNCTION>
          [possible values: sha1, sha224, sha256, sha384, sha512]
      --data-path <DATA_PATH>
          The path to the file containing the data to be signed
      --data <DATA>
          Base64 Encoded data to be signed
      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation
      --data-type <DATA_TYPE>
          The type of data passed in, either raw or digest [possible values: raw, digest]
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-crypto-sign-rsa-pkcs-examples"></a>

这些示例说明了如何使用 **crypto sign rsa-pkcs** 通过 RSA-PKCS 签名机制和 `SHA256` 哈希函数生成签名。此命令在 HSM 中使用私有密钥。

**Example 示例：为 base 64 编码的数据生成签名**  

```
aws-cloudhsm > crypto sign rsa-pkcs --key-filter attr.label=rsa-private --hash-function sha256 --data YWJjMTIz
{
  "error_code": 0,
  "data": {
    "key-reference": "0x00000000007008db",
    "signature": "XJ7mRyHnDRYrDWTQuuNb+5mhoXx7VTsPMjgOQW4iMN7E42eNHj2Q0oovMmBdHUEH0F4HYG8FBJOBhvGuM8J/z6y41GbowVpUT6WzjnIQs79K9i7i6oR1TYjLnIS3r/zkimuXcS8/ZxyDzru+GO9BUT9FFU/of9cvu4Oyn6a5+IXuCbKNQs19uASuFARUTZ0a0Ny1CB1MulxUpqGTmI91J6evlP7k/2khwDmJ5E8FEar5/Cvbn9t21p3Uj561ngTXrYbIZ2KHpef9jQh/cEIvFLG61sexJjQi8EdTxeDA+I3ITO0qrvvESvA9+Sj7kdG2ceIicFS8/8LwyxiIC31UHQ=="
  }
}
```

**Example 示例：为数据文件生成签名**  

```
aws-cloudhsm > crypto sign rsa-pkcs --key-filter attr.label=rsa-private --hash-function sha256 --data-path data.txt
{
  "error_code": 0,
  "data": {
    "key-reference": "0x00000000007008db",
    "signature": "XJ7mRyHnDRYrDWTQuuNb+5mhoXx7VTsPMjgOQW4iMN7E42eNHj2Q0oovMmBdHUEH0F4HYG8FBJOBhvGuM8J/z6y41GbowVpUT6WzjnIQs79K9i7i6oR1TYjLnIS3r/zkimuXcS8/ZxyDzru+GO9BUT9FFU/of9cvu4Oyn6a5+IXuCbKNQs19uASuFARUTZ0a0Ny1CB1MulxUpqGTmI91J6evlP7k/2khwDmJ5E8FEar5/Cvbn9t21p3Uj561ngTXrYbIZ2KHpef9jQh/cEIvFLG61sexJjQi8EdTxeDA+I3ITO0qrvvESvA9+Sj7kdG2ceIicFS8/8LwyxiIC31UHQ=="
  }
}
```

## 参数
<a name="cloudhsm_cli-crypto-sign-rsa-pkcs-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<DATA>***  
要签名的 Base64 编码数据。  
必需：是（除非通过数据路径提供）

***<DATA\$1PATH>***  
指定要签名的数据的位置。  
必需：是（除非通过数据提供）

***<HASH\$1FUNCTION>***  
指定哈希函数。  
有效值：  
+ sha1
+ sha224
+ sha256
+ sha384
+ sha512
是否必需：是

***<KEY\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择匹配密钥。  
有关支持的 CloudHSM CLI key 密钥属性列表，请参阅“Key attributes for CloudHSM CLI”。  
是否必需：是

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当私有密钥的密钥使用服务仲裁值大于 1 时才需要。

***<DATA\$1TYPE>***  
 指定是否应将数据参数的值作为签名算法的一部分进行哈希处理。`raw` 用于未经过哈希处理的数据；`digest` 用于已经过哈希处理的摘要。  
对于 RSA-PKCS，数据必须按照 [RFC 8017 第 9.2 节](https://www.rfc-editor.org/rfc/rfc8017#section-9.2)的规定以 DER 编码格式传递  
有效值：  
+ raw
+ 摘要

## 相关主题
<a name="cloudhsm_cli-crypto-sign-rsa-pkcs-seealso"></a>
+ [CloudHSM CLI 中的 crypto sign 类别](cloudhsm_cli-crypto-sign.md)
+ [CloudHSM CLI 中的 crypto verify 类别](cloudhsm_cli-crypto-verify.md)

# 使用 CloudHSM CL RSA-PKCS-PSS I 中的机制生成签名
<a name="cloudhsm_cli-crypto-sign-rsa-pkcs-pss"></a>

使用 CloudHSM CLI 中的 **crypto sign rsa-pkcs-pss** 命令通过 RSA 私有密钥和 `RSA-PKCS-PSS` 签名机制生成签名。

要使用该**crypto sign rsa-pkcs-pss**命令，您的 AWS CloudHSM 集群中必须首先有一个 RSA 私钥。您可以使用 `sign` 属性设置为 `true` 的 [使用 CloudHSM CLI 生成非对称 RSA 密钥对](cloudhsm_cli-key-generate-asymmetric-pair-rsa.md) 命令生成 RSA 私有密钥。

**注意**  
可以使用[CloudHSM CLI 中的 crypto verify 类别](cloudhsm_cli-crypto-verify.md)子命令验证签名。 AWS CloudHSM 

## 用户类型
<a name="cloudhsm_cli-crypto-sign-rsa-pkcs-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-crypto-sign-rsa-pkcs-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-crypto-sign-rsa-pkcs-syntax"></a>

```
aws-cloudhsm > help crypto sign rsa-pkcs-pss
Sign with the RSA-PKCS-PSS mechanism

Usage: crypto sign rsa-pkcs-pss [OPTIONS] --key-filter [<KEY_FILTER>...] --hash-function <HASH_FUNCTION> --mgf <MGF> --salt-length <SALT_LENGTH> <--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
      --key-filter [<KEY_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 matching key
      --hash-function <HASH_FUNCTION>  [possible values: sha1, sha224, sha256, sha384, sha512]
      --data-path <DATA_PATH>          The path to the file containing the data to be signed
      --data <DATA>                    Base64 Encoded data to be signed
      --mgf <MGF>                      The mask generation function [possible values: mgf1-sha1, mgf1-sha224, mgf1-sha256, mgf1-sha384, mgf1-sha512]
      --salt-length <SALT_LENGTH>      The salt length
      --approval <APPROVAL>            Filepath of signed quorum token file to approve operation
      --data-type <DATA_TYPE>          The type of data passed in, either raw or digest [possible values: raw, digest]
  -h, --help                           Print help
```

## 示例
<a name="cloudhsm_cli-crypto-sign-rsa-pkcs-examples"></a>

这些示例说明了如何使用 **crypto sign rsa-pkcs-pss** 通过 `RSA-PKCS-PSS` 签名机制和 `SHA256` 哈希函数生成签名。此命令在 HSM 中使用私有密钥。

**Example 示例：为 base 64 编码的数据生成签名**  

```
aws-cloudhsm > crypto sign rsa-pkcs-pss --key-filter attr.label=rsa-private --hash-function sha256 --data YWJjMTIz --salt-length 10 --mgf mgf1-sha256
{
  "error_code": 0,
  "data": {
    "key-reference": "0x00000000007008db",
    "signature": "H/z1rYVMzNAa31K4amE5MTiwGxDdCTgQXCJXRBKVOVm7ZuyI0fGE4sT/BUN+977mQEV2TqtWpTsiF2IpwGM1VfSBRt7h/g4o6YERm1tTQLl7q+AJ7uGGK37zCsWQrAo7Vy8NzPShxekePo/ZegrB1aHWN1fE8H3IPUKqLuMDI9o1Jq6kM986ExS7YmeOIclcZkyykTWqHLQVL2C3+A2bHJZBqRcM5XoIpk8HkPypjpN+m4FNUds30GAemoOMl6asSrEJSthaZWV53OBsDOqzA8Rt8JdhXS+GZp3vNLdL1OTBELDPweXVgAu4dBX0FOvpw/gg6sNvuaDK4YOBv2fqKg=="
  }
}
```

**Example 示例：为数据文件生成签名**  

```
aws-cloudhsm > crypto sign rsa-pkcs-pss --key-filter attr.label=rsa-private --hash-function sha256 --data-path data.txt --salt-length 10 --mgf mgf1-sha256
{
  "error_code": 0,
  "data": {
    "key-reference": "0x00000000007008db",
    "signature": "H/z1rYVMzNAa31K4amE5MTiwGxDdCTgQXCJXRBKVOVm7ZuyI0fGE4sT/BUN+977mQEV2TqtWpTsiF2IpwGM1VfSBRt7h/g4o6YERm1tTQLl7q+AJ7uGGK37zCsWQrAo7Vy8NzPShxekePo/ZegrB1aHWN1fE8H3IPUKqLuMDI9o1Jq6kM986ExS7YmeOIclcZkyykTWqHLQVL2C3+A2bHJZBqRcM5XoIpk8HkPypjpN+m4FNUds30GAemoOMl6asSrEJSthaZWV53OBsDOqzA8Rt8JdhXS+GZp3vNLdL1OTBELDPweXVgAu4dBX0FOvpw/gg6sNvuaDK4YOBv2fqKg=="
  }
}
```

## 参数
<a name="cloudhsm_cli-crypto-sign-rsa-pkcs-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<DATA>***  
要签名的 Base64 编码数据。  
必需：是（除非通过数据路径提供）

***<DATA\$1PATH>***  
指定要签名的数据的位置。  
必需：是（除非通过数据提供）

***<HASH\$1FUNCTION>***  
指定哈希函数。  
有效值：  
+ sha1
+ sha224
+ sha256
+ sha384
+ sha512
是否必需：是

***<KEY\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择匹配密钥。  
有关支持的 CloudHSM CLI key 密钥属性列表，请参阅“Key attributes for CloudHSM CLI”。  
是否必需：是

***<MGF>***  
指定掩码生成函数。  
掩码生成函数哈希函数必须与签名机制哈希函数相匹配。
有效值：  
+ mgf1-sha1
+ mgf1-sha224
+ mgf1-sha256
+ mgf1-sha384
+ mgf1-sha512
是否必需：是

***<SALT\$1LENGTH>***  
指定 salt 长度。  
是否必需：是

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当私有密钥的密钥使用服务仲裁值大于 1 时才需要。

***<DATA\$1TYPE>***  
 指定是否应将数据参数的值作为签名算法的一部分进行哈希处理。`raw` 用于未经过哈希处理的数据；`digest` 用于已经过哈希处理的摘要。  
有效值：  
+ raw
+ 摘要

## 相关主题
<a name="cloudhsm_cli-crypto-sign-rsa-pkcs-seealso"></a>
+ [CloudHSM CLI 中的 crypto sign 类别](cloudhsm_cli-crypto-sign.md)
+ [CloudHSM CLI 中的 crypto verify 类别](cloudhsm_cli-crypto-verify.md)

## 相关主题
<a name="cloudhsm_cli-crypto-sign-seealso"></a>
+ [CloudHSM CLI 中的 crypto verify 类别](cloudhsm_cli-crypto-verify.md)

# CloudHSM CLI 中的 crypto verify 类别
<a name="cloudhsm_cli-crypto-verify"></a>

在 CloudHSM CLI 中，**crypto verify** 是一组命令的父类别，当这些命令与父类别结合使用时，可以确认文件是否已由给定的密钥签名。**crypto verify** 具有以下子命令：
+ [crypto verify ecdsa](cloudhsm_cli-crypto-verify-ecdsa.md)
+ [加密验证 ed25519ph](cloudhsm_cli-crypto-verify-ed25519ph.md)
+ [crypto verify rsa-pkcs](cloudhsm_cli-crypto-verify-rsa-pkcs.md)
+ [加密验证 rsa-pkcs-pss](cloudhsm_cli-crypto-verify-rsa-pkcs-pss.md)

**crypto verify** 命令将签名文件与源文件进行比较，并根据给定的公有密钥和签名机制分析它们是否与加密相关。

**注意**  
可以通过[CloudHSM CLI 中的 crypto sign 类别](cloudhsm_cli-crypto-sign.md)操作登录 AWS CloudHSM 文件。

# 在 CloudHSM CLI 中验证使用 ECDSA 机制签名的签名
<a name="cloudhsm_cli-crypto-verify-ecdsa"></a>

使用 CloudHSM CLI 中的 **crypto verify ecdsa** 命令完成以下操作：
+ 确认文件已通过给定的公有密钥在 HSM 中签名。
+ 验证签名是否是使用 ECDSA 签名机制生成的。
+ 将签名文件与源文件进行比较，并根据给定的 ecdsa 公有密钥和签名机制确定两者是否具有加密相关性。
+  ECDSA 验证函数需要的签名格式为`r||s`，其中 r 和 s 分量作为原始二进制数据连接在一起。

要使用该**crypto verify ecdsa**命令，您的 AWS CloudHSM 集群中必须首先有一个 EC 公钥。您可以使用 `verify` 属性设置为 `true` 的 [使用 CloudHSM CLI 导入 PEM 格式密钥](cloudhsm_cli-key-import-pem.md) 命令导入 EC 公有密钥。

**注意**  
您可以使用 [CloudHSM CLI 中的 crypto sign 类别](cloudhsm_cli-crypto-sign.md) 子命令在 CloudHSM CLI 中生成签名。

## 用户类型
<a name="cloudhsm_cli-crypto-verify-ecdsa-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-crypto-verify-ecdsa-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-crypto-verify-ecdsa-syntax"></a>

```
aws-cloudhsm > help crypto verify ecdsa
Verify with the ECDSA mechanism

Usage: crypto verify ecdsa --key-filter [<KEY_FILTER>...] --hash-function <HASH_FUNCTION> <--data-path <DATA_PATH>|--data <DATA>> <--signature-path <SIGNATURE_PATH>|--signature <SIGNATURE>>

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
      --key-filter [<KEY_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 matching key
      --hash-function <HASH_FUNCTION>
          [possible values: sha1, sha224, sha256, sha384, sha512]
      --data-path <DATA_PATH>
          The path to the file containing the data to be verified
      --data <DATA>
          Base64 encoded data to be verified
      --signature-path <SIGNATURE_PATH>
          The path to where the signature is located
      --signature <SIGNATURE>
          Base64 encoded signature to be verified
      --data-type <DATA_TYPE>
          The type of data passed in, either raw or digest [possible values: raw, digest]
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-crypto-verify-ecdsa-examples"></a>

这些示例展示了如何使用 **crypto verify ecdsa** 来验证使用 ECDSA 签名机制和 `SHA256` 哈希函数生成的签名。此命令在 HSM 中使用公有密钥。

**Example 示例：使用 Base64 编码的数据验证 Base64 编码的签名**  

```
aws-cloudhsm > crypto verify ecdsa --hash-function sha256 --key-filter attr.label=ec-public --data YWJjMTIz --signature 4zki+FzjhP7Z/KqoQvh4ueMAxQQVp7FQguZ2wOS3Q5bzk+Hc5irV5iTkuxQbropPttVFZ8V6FgR2fz+sPegwCw==
{
  "error_code": 0,
  "data": {
    "message": "Signature verified successfully"
  }
}
```

**Example 示例：使用数据文件验证签名文件**  

```
aws-cloudhsm > crypto verify ecdsa --hash-function sha256 --key-filter attr.label=ec-public --data-path data.txt --signature-path signature-file
{
   "error_code": 0,
  "data": {
    "message": "Signature verified successfully"
  }
}
```

**Example 示例：证明为错误的签名关系**  
此命令验证位于 `/home/data` 的数据是否由标签为 `ecdsa-public` 的公有密钥使用 ECDSA 签名机制进行签名，以生成位于 `/home/signature` 的签名。由于给定参数不构成真正的签名关系，所以命令会返回错误消息。  

```
aws-cloudhsm > crypto verify ecdsa --hash-function sha256 --key-filter attr.label=ec-public --data aW52YWxpZA== --signature +ogk7M7S3iTqFg3SndJfd91dZFr5Qo6YixJl8JwcvqqVgsVuO6o+VKvTRjz0/V05kf3JJbBLr87Q+wLWcMAJfA==
{
  "error_code": 1,
  "data": "Signature verification failed"
}
```

## 参数
<a name="cloudhsm_cli-crypto-verify-ecdsa-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<DATA>***  
要签名的 Base64 编码数据。  
必需：是（除非通过数据路径提供）

***<DATA\$1PATH>***  
指定要签名的数据的位置。  
必需：是（除非通过数据路径提供）

***<HASH\$1FUNCTION>***  
指定哈希函数。  
有效值：  
+ sha1
+ sha224
+ sha256
+ sha384
+ sha512
是否必需：是

***<KEY\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择匹配密钥。  
有关支持的 CloudHSM CLI key 密钥属性列表，请参阅“Key attributes for CloudHSM CLI”。  
是否必需：是

***<SIGNATURE>***  
Base64 编码的签名。  
必需：是（除非通过签名路径提供）

***<SIGNATURE\$1PATH>***  
指定签名的位置。  
必需：是（除非通过签名路径提供）

***<DATA\$1TYPE>***  
 指定是否应将数据参数的值作为签名算法的一部分进行哈希处理。`raw` 用于未经过哈希处理的数据；`digest` 用于已经过哈希处理的摘要。  
有效值：  
+ raw
+ 摘要

## 相关主题
<a name="cloudhsm_cli-crypto-verify-ecdsa-seealso"></a>
+ [CloudHSM CLI 中的 crypto sign 类别](cloudhsm_cli-crypto-sign.md)
+ [CloudHSM CLI 中的 crypto verify 类别](cloudhsm_cli-crypto-verify.md)

# 在 CloudHSM CLI 中验证使用 HashEd DSA 机制签名的签名
<a name="cloudhsm_cli-crypto-verify-ed25519ph"></a>

**重要**  
HashEd仅在非 FIPS 模式下的 hsm2m.medium 实例上支持 DSA 签名验证操作。

使用 CloudHSM CLI 中的 **crypto verify ed25519ph** 命令完成以下操作：
+ 使用给定的 Ed25519 公钥验证数据或文件的签名。
+ 确认签名是使用 HashEd DSA 签名机制生成的。有关 HashEd DSA 的更多信息，请参阅 [NIST SP 186-5](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-5.pdf)，第 7.8 节。

要使用该**crypto verify ed25519ph**命令，您的集群中必须首先有一个 Ed25519 公钥。 AWS CloudHSM 您可以使用`curve`参数设置为、属性设置为的[使用 CloudHSM CLI 生成非对称 EC 密钥对](cloudhsm_cli-key-generate-asymmetric-pair-ec.md)命令生成 Ed25519 密钥对`true`，也可以使用`verify`属性设置为的[使用 CloudHSM CLI 导入 PEM 格式密钥](cloudhsm_cli-key-import-pem.md)命令导入 Ed25519 公钥。`ed25519` `verify` `true`

**注意**  
您可以使用 [CloudHSM CLI 中的 crypto sign 类别](cloudhsm_cli-crypto-sign.md) 子命令在 CloudHSM CLI 中生成签名。

## 用户类型
<a name="cloudhsm_cli-crypto-verify-ed25519ph-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-crypto-verify-ed25519ph-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。
+ HashEd仅在非 FIPS 模式下的 hsm2m.medium 实例上支持 DSA 签名验证操作。

## 语法
<a name="cloudhsm_cli-crypto-verify-ed25519ph-syntax"></a>

```
aws-cloudhsm > help crypto verify ed25519ph
Verify with the Ed25519ph mechanism

Usage: crypto verify ed25519ph [OPTIONS] --key-filter [<KEY_FILTER>...] --data-type <DATA_TYPE> --hash-function <HASH_FUNCTION> <--data-path <DATA_PATH>|--data <DATA>> <--signature-path <SIGNATURE_PATH>|--signature <SIGNATURE>>

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
      --key-filter [<KEY_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 matching key
      --data-path <DATA_PATH>
          The path to the file containing the data to be verified
      --data <DATA>
          Base64 encoded data to be verified
      --signature-path <SIGNATURE_PATH>
          The path to where the signature is located
      --signature <SIGNATURE>
          Base64 encoded signature to be verified
      --data-type <DATA_TYPE>
          The type of data passed in, either raw or digest [possible values: raw, digest]
      --hash-function <HASH_FUNCTION>
          Hash function [possible values: sha512]
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-crypto-verify-ed25519ph-examples"></a>

这些示例说明如何使用**crypto verify ed25519ph**来验证使用 ed25519ph 签名机制和哈希函数生成的签名。`sha512`此命令在 HSM 中使用 Ed25519 公钥。

**Example 示例：使用 Base64 编码的数据验证 Base64 编码的签名**  

```
aws-cloudhsm > crypto verify ed25519ph \
    --hash-function sha512 \
    --key-filter attr.label=ed25519-public \
    --data-type raw \
    --data YWJj \
    --signature mKcCIvC4Ehqp0w+BPWg/gJ5GK0acf/h2OUmbuU5trkEx+FBCRjwqNVogA9BirfWqoQuMYeY2Biqq0RwqJgg0Bg==
{
  "error_code": 0,
  "data": {
    "message": "Signature verified successfully"
  }
}
```

**Example 示例：使用数据文件验证签名文件**  

```
aws-cloudhsm > crypto verify ed25519ph \
    --hash-function sha512 \
    --key-filter attr.label=ed25519-public \
    --data-type raw \
    --data-path data.txt \
    --signature-path signature-file
{
  "error_code": 0,
  "data": {
    "message": "Signature verified successfully"
  }
}
```

## 参数
<a name="cloudhsm_cli-crypto-verify-ed25519ph-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<DATA>***  
需要验证的 Base64 编码数据。  
必需：是（除非通过数据路径提供）

***<DATA\$1PATH>***  
指定要验证的数据的位置。  
必填项：是（除非通过数据参数提供）

***<HASH\$1FUNCTION>***  
指定哈希函数。ed25519pH 仅支持。 SHA512  
有效值：  
+ sha512
是否必需：是

***<KEY\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择匹配密钥。  
有关支持的 CloudHSM CLI 密钥属性的列表，请参阅。[CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)  
是否必需：是

***<SIGNATURE>***  
Base64 编码的签名。  
必需：是（除非通过签名路径提供）

***<SIGNATURE\$1PATH>***  
指定签名的位置。  
必填项：是（除非通过签名参数提供）

***<DATA\$1TYPE>***  
 指定是否应将数据参数的值作为验证算法的一部分进行哈希处理。`raw` 用于未经过哈希处理的数据；`digest` 用于已经过哈希处理的摘要。  
有效值：  
+ raw
+ 摘要
是否必需：是

## 相关主题
<a name="cloudhsm_cli-crypto-verify-ed25519ph-seealso"></a>
+ [CloudHSM CLI 中的 crypto sign 类别](cloudhsm_cli-crypto-sign.md)
+ [CloudHSM CLI 中的 crypto verify 类别](cloudhsm_cli-crypto-verify.md)
+ [在 CloudHSM CLI 中使用 HashEd DSA 机制生成签名](cloudhsm_cli-crypto-sign-ed25519ph.md)

# 在 CloudHSM CLI 中验证使用 RSA-PKCS 机制签名的签名
<a name="cloudhsm_cli-crypto-verify-rsa-pkcs"></a>

使用 CloudHSM CLI 中的 **crypto verify rsa-pkcs** 命令完成以下操作：
+ 确认文件已通过给定的公有密钥在 HSM 中签名。
+ 验证签名是否是使用 `RSA-PKCS` 签名机制生成的。
+ 将签名文件与源文件进行比较，并根据给定的 rsa 公有密钥和签名机制确定两者是否具有加密相关性。

要使用该**crypto verify rsa-pkcs**命令，您的 AWS CloudHSM 集群中必须首先有一个 RSA 公钥。

**注意**  
您可以使用带有 [CloudHSM CLI 中的 crypto sign 类别](cloudhsm_cli-crypto-sign.md) 子命令的 CloudHSM CLI 生成签名。

## 用户类型
<a name="cloudhsm_cli-crypto-verify-rsa-pkcs-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-crypto-verify-rsa-pkcs-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-crypto-verify-rsa-pkcs-syntax"></a>

```
aws-cloudhsm > help crypto verify rsa-pkcs
Verify with the RSA-PKCS mechanism

Usage: crypto verify rsa-pkcs --key-filter [<KEY_FILTER>...] --hash-function <HASH_FUNCTION> <--data-path <DATA_PATH>|--data <DATA>> <--signature-path <SIGNATURE_PATH>|--signature <SIGNATURE>>

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
      --key-filter [<KEY_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 matching key
      --hash-function <HASH_FUNCTION>
          [possible values: sha1, sha224, sha256, sha384, sha512]
      --data-path <DATA_PATH>
          The path to the file containing the data to be verified
      --data <DATA>
          Base64 encoded data to be verified
      --signature-path <SIGNATURE_PATH>
          The path to where the signature is located
      --signature <SIGNATURE>
          Base64 encoded signature to be verified
      --data-type <DATA_TYPE>
          The type of data passed in, either raw or digest [possible values: raw, digest]
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-crypto-verify-rsa-pkcs-examples"></a>

这些示例说明了如何使用 **crypto verify rsa-pkcs** 来验证使用 RSA-PKCS 签名机制和 `SHA256` 哈希函数生成的签名。此命令在 HSM 中使用公有密钥。

**Example 示例：使用 Base64 编码的数据验证 Base64 编码的签名**  

```
aws-cloudhsm > crypto verify rsa-pkcs --hash-function sha256 --key-filter attr.label=rsa-public --data YWJjMTIz --signature XJ7mRyHnDRYrDWTQuuNb+5mhoXx7VTsPMjgOQW4iMN7E42eNHj2Q0oovMmBdHUEH0F4HYG8FBJOBhvGuM8J/z6y41GbowVpUT6WzjnIQs79K9i7i6oR1TYjLnIS3r/zkimuXcS8/ZxyDzru+GO9BUT9FFU/of9cvu4Oyn6a5+IXuCbKNQs19uASuFARUTZ0a0Ny1CB1MulxUpqGTmI91J6evlP7k/2khwDmJ5E8FEar5/Cvbn9t21p3Uj561ngTXrYbIZ2KHpef9jQh/cEIvFLG61sexJjQi8EdTxeDA+I3ITO0qrvvESvA9+Sj7kdG2ceIicFS8/8LwyxiIC31UHQ==
{
  "error_code": 0,
  "data": {
    "message": "Signature verified successfully"
  }
}
```

**Example 示例：使用数据文件验证签名文件**  

```
aws-cloudhsm > crypto verify rsa-pkcs --hash-function sha256 --key-filter attr.label=rsa-public --data-path data.txt --signature-path signature-file
{
  "error_code": 0,
  "data": {
    "message": "Signature verified successfully"
  }
}
```

**Example 示例：证明为错误的签名关系**  
此命令验证无效数据是否由标签为 `rsa-public` 的公有密钥使用 RSAPKCS 签名机制进行签名，以生成位于 `/home/signature` 中的签名。由于给定参数不构成真正的签名关系，所以命令会返回错误消息。  

```
aws-cloudhsm > crypto verify rsa-pkcs --hash-function sha256 --key-filter attr.label=rsa-public --data aW52YWxpZA== --signature XJ7mRyHnDRYrDWTQuuNb+5mhoXx7VTsPMjgOQW4iMN7E42eNHj2Q0oovMmBdHUEH0F4HYG8FBJOBhvGuM8J/z6y41GbowVpUT6WzjnIQs79K9i7i6oR1TYjLnIS3r/zkimuXcS8/ZxyDzru+GO9BUT9FFU/of9cvu4Oyn6a5+IXuCbKNQs19uASuFARUTZ0a0Ny1CB1MulxUpqGTmI91J6evlP7k/2khwDmJ5E8FEar5/Cvbn9t21p3Uj561ngTXrYbIZ2KHpef9jQh/cEIvFLG61sexJjQi8EdTxeDA+I3ITO0qrvvESvA9+Sj7kdG2ceIicFS8/8LwyxiIC31UHQ==
{
  "error_code": 1,
  "data": "Signature verification failed"
}
```

## 参数
<a name="cloudhsm_cli-crypto-verify-rsa-pkcs-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<DATA>***  
要签名的 Base64 编码数据。  
必需：是（除非通过数据路径提供）

***<DATA\$1PATH>***  
指定要签名的数据的位置。  
必需：是（除非通过数据路径提供）

***<HASH\$1FUNCTION>***  
指定哈希函数。  
有效值：  
+ sha1
+ sha224
+ sha256
+ sha384
+ sha512
是否必需：是

***<KEY\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择匹配密钥。  
有关支持的 CloudHSM CLI key 密钥属性列表，请参阅“Key attributes for CloudHSM CLI”。  
是否必需：是

***<SIGNATURE>***  
Base64 编码的签名。  
必需：是（除非通过签名路径提供）

***<SIGNATURE\$1PATH>***  
指定签名的位置。  
必需：是（除非通过签名路径提供）

***<DATA\$1TYPE>***  
 指定是否应将数据参数的值作为签名算法的一部分进行哈希处理。`raw` 用于未经过哈希处理的数据；`digest` 用于已经过哈希处理的摘要。  
对于 RSA-PKCS，数据必须按照 [RFC 8017 第 9.2 节](https://www.rfc-editor.org/rfc/rfc8017#section-9.2)的规定以 DER 编码格式传递  
有效值：  
+ raw
+ 摘要

## 相关主题
<a name="cloudhsm_cli-crypto-verify-rsa-pkcs-seealso"></a>
+ [CloudHSM CLI 中的 crypto sign 类别](cloudhsm_cli-crypto-sign.md)
+ [CloudHSM CLI 中的 crypto verify 类别](cloudhsm_cli-crypto-verify.md)

# 在 CloudHSM CLI 中验证使用该 RSA-PKCS-PSS机制签名的签名
<a name="cloudhsm_cli-crypto-verify-rsa-pkcs-pss"></a>

使用 CloudHSM CLI 中的 **crypto sign rsa-pkcs-pss** 命令完成以下操作。
+ 确认文件已通过给定的公有密钥在 HSM 中签名。
+ 验证签名是否是使用 RSA-PKCS-PSS 签名机制生成的。
+ 将签名文件与源文件进行比较，并根据给定的 rsa 公有密钥和签名机制确定两者是否具有加密相关性。

要使用该**crypto verify rsa-pkcs-pss**命令，您的 AWS CloudHSM 集群中必须首先有一个 RSA 公钥。您可以使用 key import pem 命令 ADD UNWRAP LINK HERE) 并将 `verify` 属性设置为 `true` 来导入 RSA 公有密钥。

**注意**  
您可以使用带有 [CloudHSM CLI 中的 crypto sign 类别](cloudhsm_cli-crypto-sign.md) 子命令的 CloudHSM CLI 生成签名。

## 用户类型
<a name="cloudhsm_cli-crypto-verify-rsa-pkcs-pss-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-crypto-verify-rsa-pkcs-pss-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-crypto-verify-rsa-pkcs-pss-syntax"></a>

```
aws-cloudhsm > help crypto verify rsa-pkcs-pss
Verify with the RSA-PKCS-PSS mechanism

Usage: crypto verify rsa-pkcs-pss --key-filter [<KEY_FILTER>...] --hash-function <HASH_FUNCTION> --mgf <MGF> --salt-length >SALT_LENGTH< <--data-path <DATA_PATH>|--data <DATA> <--signature-path <SIGNATURE_PATH>|--signature <SIGNATURE>>

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
      --key-filter [<KEY_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 matching key
      --hash-function <HASH_FUNCTION>
          [possible values: sha1, sha224, sha256, sha384, sha512]
      --data-path <DATA_PATH>
          The path to the file containing the data to be verified
      --data <DATA>
          Base64 encoded data to be verified
      --signature-path <SIGNATURE_PATH>
          The path to where the signature is located
      --signature <SIGNATURE>
          Base64 encoded signature to be verified
      --data-type <DATA_TYPE>
          The type of data passed in, either raw or digest [possible values: raw, digest]
      --mgf <MGF>
          The mask generation function [possible values: mgf1-sha1, mgf1-sha224, mgf1-sha256, mgf1-sha384, mgf1-sha512]
      --salt-length <SALT_LENGTH>
          The salt length
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-crypto-verify-rsa-pkcs-pss-examples"></a>

这些示例说明如何使用**crypto verify rsa-pkcs-pss**来验证使用签名机制和`SHA256`哈希函数生成的 RSA-PKCS-PSS签名。此命令在 HSM 中使用公有密钥。

**Example 示例：使用 Base64 编码的数据验证 Base64 编码的签名**  

```
aws-cloudhsm > crypto verify rsa-pkcs-pss --key-filter attr.label=rsa-public --hash-function sha256 --data YWJjMTIz --salt-length 10 --mgf mgf1-sha256 --signature H/z1rYVMzNAa31K4amE5MTiwGxDdCTgQXCJXRBKVOVm7ZuyI0fGE4sT/BUN+977mQEV2TqtWpTsiF2IpwGM1VfSBRt7h/g4o6YERm1tTQLl7q+AJ7uGGK37zCsWQrAo7Vy8NzPShxekePo/ZegrB1aHWN1fE8H3IPUKqLuMDI9o1Jq6kM986ExS7YmeOIclcZkyykTWqHLQVL2C3+A2bHJZBqRcM5XoIpk8HkPypjpN+m4FNUds30GAemoOMl6asSrEJSthaZWV53OBsDOqzA8Rt8JdhXS+GZp3vNLdL1OTBELDPweXVgAu4dBX0FOvpw/gg6sNvuaDK4YOBv2fqKg==
{
  "error_code": 0,
  "data": {
    "message": "Signature verified successfully"
  }
}
```

**Example 示例：使用数据文件验证签名文件**  

```
aws-cloudhsm > crypto verify rsa-pkcs-pss --key-filter attr.label=rsa-public --hash-function sha256 --data-path data.txt --salt-length 10 --mgf mgf1-sha256 --signature signature-file
{
  "error_code": 0,
  "data": {
    "message": "Signature verified successfully"
  }
}
```

**Example 示例：证明为错误的签名关系**  
此命令验证无效数据是否由标签为 `rsa-public` 的公有密钥使用 RSAPKCSPSS 签名机制进行签名，以生成位于 `/home/signature` 中的签名。由于给定参数不构成真正的签名关系，所以命令会返回错误消息。  

```
aws-cloudhsm > crypto verify rsa-pkcs-pss --key-filter attr.label=rsa-public --hash-function sha256 --data aW52YWxpZA== --salt-length 10 --mgf mgf1-sha256 --signature H/z1rYVMzNAa31K4amE5MTiwGxDdCTgQXCJXRBKVOVm7ZuyI0fGE4sT/BUN+977mQEV2TqtWpTsiF2IpwGM1VfSBRt7h/g4o6YERm1tTQLl7q+AJ7uGGK37zCsWQrAo7Vy8NzPShxekePo/ZegrB1aHWN1fE8H3IPUKqLuMDI9o1Jq6kM986ExS7YmeOIclcZkyykTWqHLQVL2C3+A2bHJZBqRcM5XoIpk8HkPypjpN+m4FNUds30GAemoOMl6asSrEJSthaZWV53OBsDOqzA8Rt8JdhXS+GZp3vNLdL1OTBELDPweXVgAu4dBX0FOvpw/gg6sNvuaDK4YOBv2fqKg==
{
  "error_code": 1,
  "data": "Signature verification failed"
}
```

## 参数
<a name="cloudhsm_cli-crypto-verify-rsa-pkcs-pss-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<DATA>***  
要签名的 Base64 编码数据。  
必需：是（除非通过数据路径提供）

***<DATA\$1PATH>***  
指定要签名的数据的位置。  
必需：是（除非通过数据路径提供）

***<HASH\$1FUNCTION>***  
指定哈希函数。  
有效值：  
+ sha1
+ sha224
+ sha256
+ sha384
+ sha512
是否必需：是

***<KEY\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择匹配密钥。  
有关支持的 CloudHSM CLI key 密钥属性列表，请参阅“Key attributes for CloudHSM CLI”。  
是否必需：是

***<MFG>***  
指定掩码生成函数。  
掩码生成函数哈希函数必须与签名机制哈希函数相匹配。
有效值：  
+ mgf1-sha1
+ mgf1-sha224
+ mgf1-sha256
+ mgf1-sha384
+ mgf1-sha512
是否必需：是

***<SIGNATURE>***  
Base64 编码的签名。  
必需：是（除非通过签名路径提供）

***<SIGNATURE\$1PATH>***  
指定签名的位置。  
必需：是（除非通过签名路径提供）

***<DATA\$1TYPE>***  
 指定是否应将数据参数的值作为签名算法的一部分进行哈希处理。`raw` 用于未经过哈希处理的数据；`digest` 用于已经过哈希处理的摘要。  
有效值：  
+ raw
+ 摘要

## 相关主题
<a name="cloudhsm_cli-crypto-verify-rsa-pkcs-pss-seealso"></a>
+ [CloudHSM CLI 中的 crypto sign 类别](cloudhsm_cli-crypto-sign.md)
+ [CloudHSM CLI 中的 crypto verify 类别](cloudhsm_cli-crypto-verify.md)

# CloudHSM CLI 中的 key 类别
<a name="cloudhsm_cli-key"></a>

在 CloudHSM CLI 中，**key** 是一组命令的父类别，当这些命令与父类别结合使用时，会创建特定于密钥的命令。目前，此类别由以下命令组成：
+ [删除](cloudhsm_cli-key-delete.md)
+ [generate-file](cloudhsm_cli-key-generate-file.md)
+ [密钥 generate-asymmetric-pair](cloudhsm_cli-key-generate-asymmetric-pair.md)
  + [密钥 generate-asymmetric-pair rsa](cloudhsm_cli-key-generate-asymmetric-pair-rsa.md)
  + [key generate-asymmetric-pair ec](cloudhsm_cli-key-generate-asymmetric-pair-ec.md)
+ [key generate-symmetric](cloudhsm_cli-key-generate-symmetric.md)
  + [key generate-symmetric aes](cloudhsm_cli-key-generate-symmetric-aes.md)
  + [key generate-symmetric generic-secret](cloudhsm_cli-key-generate-symmetric-generic-secret.md)
+ [import pem](cloudhsm_cli-key-import-pem.md)
+ [列表](cloudhsm_cli-key-list.md)
+ [复制](cloudhsm_cli-key-replicate.md)
+ [设置 - 属性](cloudhsm_cli-key-set-attribute.md)
+ [共享](cloudhsm_cli-key-share.md)
+ [取消共享](cloudhsm_cli-key-unshare.md)
+ [unwrap](cloudhsm_cli-key-unwrap.md)
+ [wrap](cloudhsm_cli-key-wrap.md)

# 使用 CloudHSM CLI 删除密钥
<a name="cloudhsm_cli-key-delete"></a>

使用 CloudHSM CLI 中的**key delete**命令从集群中删除密钥 AWS CloudHSM 。您一次只能删除一个密钥。删除某密钥对中的一个密钥不会影响该密钥对中的另一个密钥。

只有创建密钥并因此拥有密钥的 CU 才能删除该密钥。共享密钥但不拥有密钥的用户可以在加密操作中使用密钥，但无法将其删除。

## 用户类型
<a name="key-delete-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="key-delete-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="key-delete-syntax"></a>

```
aws-cloudhsm > help key delete
Delete a key in the HSM cluster

Usage: key delete [OPTIONS] --filter [<FILTER>...]

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 matching key for deletion
  -h, --help                     Print help
```

## 示例
<a name="key-delete-examples"></a>

```
aws-cloudhsm > key delete --filter attr.label="ec-test-public-key"
{
  "error_code": 0,
  "data": {
    "message": "Key deleted successfully"
  }
}
```

## 参数
<a name="key-delete-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择要删除的匹配密钥。  
有关支持的 CloudHSM CLI key 密钥属性列表，请参阅 [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)。  
是否必需：是

## 相关主题
<a name="key-delete-seealso"></a>
+ [使用 CloudHSM CLI 列出用户的密钥](cloudhsm_cli-key-list.md)
+ [使用 CloudHSM CLI 导出非对称密钥](cloudhsm_cli-key-generate-file.md)
+ [使用 CloudHSM CLI 取消共享密钥](cloudhsm_cli-key-unshare.md)
+ [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)
+ [使用 CloudHSM CLI 筛选密钥](manage-keys-cloudhsm-cli-filtering.md)

# 使用 CloudHSM CLI 导出非对称密钥
<a name="cloudhsm_cli-key-generate-file"></a>

使用 CloudHSM CLI 中的 **key generate-file** 命令从硬件安全模块（HSM）导出非对称密钥。如果目标是私有密钥，则对私有密钥的引用将以伪 PEM 格式导出。如果目标是公有密钥，则公有密钥字节将以 PEM 格式导出。

虚假的 PEM 文件不包含实际的私钥材料，而是引用 HSM 中的私钥，可用于建立从 Web SSL/TLS 服务器卸载到。 AWS CloudHSM有关更多信息，请参阅 [SSL/TLS 分载](ssl-offload.md)。

## 用户类型
<a name="key-generate-file-user-type"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="key-generate-file-requirements"></a>

要运行此命令，必须以 CU 身份登录。

## 语法
<a name="key-generate-file-syntax"></a>

```
aws-cloudhsm > help key generate-file
Generate a key file from a key in the HSM cluster. This command does not export any private key data from the HSM

Usage: key generate-file --encoding <ENCODING> --path <PATH> --filter [<FILTER>...]

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
      --encoding <ENCODING>
          Encoding format for the key file

          Possible values:
          - reference-pem: PEM formatted key reference (supports private keys)
          - pem:           PEM format (supports public keys)

      --path <PATH>
          Filepath where the key file will be written

      --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 matching key for file generation

  -h, --help
          Print help (see a summary with '-h')
```

## 示例
<a name="key-generate-file-examples"></a>

此示例说明**key generate-file**如何使用在 AWS CloudHSM 集群中生成密钥文件。

**Example**  

```
aws-cloudhsm > key generate-file --encoding reference-pem --path /tmp/ec-private-key.pem --filter attr.label="ec-test-private-key"
{
  "error_code": 0,
  "data": {
    "message": "Successfully generated key file"
  }
}
```

## 参数
<a name="key-generate-file-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择要删除的匹配密钥。  
有关支持的 CloudHSM CLI key 密钥属性列表，请参阅 [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)  
必需：否

***<ENCODING>***  
指定密钥文件的编码格式  
是否必需：是

***<PATH>***  
指定将写入密钥文件的文件路径  
是否必需：是

## 生成 KSP 密钥引用（Windows）
<a name="key-generate-ksp-key-reference"></a>

**注意**  
此功能只在 SDK 版本 5.16.0 及更高版本中提供。

### 先决条件
<a name="key-generate-ksp-key-reference-requirements"></a>
+ 只能在 Windows 平台上生成 KSP 密钥引用。
+ 必须以加密用户（CU）身份登录。

### 文件位置
<a name="key-generate-ksp-key-reference-options"></a>

默认情况下，AWS CloudHSM 将生成的文件存储在以下位置：`C:\Users\Default\AppData\Roaming\Microsoft\Crypto\CaviumKSP\GlobalPartition`

要指定其他位置，请使用 `--path` 参数。

### 语法
<a name="key-generate-ksp-key-reference-syntax"></a>

```
aws-cloudhsm > help key generate-file --encoding ksp-key-reference 
Generate a key file from a key in the HSM cluster. This command does not export any private key data from the HSM

Usage: key generate-file --encoding <ENCODING> --path <PATH> --filter [<FILTER>...]

Options:
      --encoding <ENCODING>
        Encoding format for the key file

        Possible values:
        - reference-pem:     PEM formatted key reference (supports private keys)
        - pem:               PEM format (supports public keys)
        - ksp-key-reference: KSP key reference format

      --cluster-id <CLUSTER_ID>
        Unique Id to choose which of the clusters in the config file to run the operation against. If not provided with multiple clusters configured, will error

      --path <PATH>
        Directory path where the key file will be written

      --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 matching key for file generation

      --all
        Generate ksp key reference for all available key pairs in HSM

  -h, --help
        Print help (see a summary with '-h')
```

### 示例 – 使用私有密钥的属性筛选条件生成 KSP 密钥引用
<a name="key-generate-ksp-key-reference-example1"></a>

以下示例为带有特定标签的私有密钥生成 KSP 密钥引用。

**Example**  

```
aws-cloudhsm > key generate-file --encoding ksp-key-reference --path  --filter attr.label="ec-test-private-key"
{
  "error_code": 0,
  "data": {
    "message": "Successfully generated key file"
  }
}
```

### 示例 – 为所有密钥对生成 KSP 密钥引用
<a name="key-generate-ksp-key-reference-example2"></a>

以下示例为集群中的所有密钥对生成 KSP 密钥引用。

**Example**  

```
aws-cloudhsm > key generate-file --encoding ksp-key-reference --all
{
  "error_code": 0,
  "data": {
    "message": "Successfully generated key file"
  }
}
```

## 相关主题
<a name="key-generate-file-seealso"></a>
+ [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)
+ [使用 CloudHSM CLI 筛选密钥](manage-keys-cloudhsm-cli-filtering.md)
+ [CloudHSM CLI 中的 generate-asymmetric-pair类别](cloudhsm_cli-key-generate-asymmetric-pair.md)
+ [CloudHSM CLI 中的 generate-symmetric 类别](cloudhsm_cli-key-generate-symmetric.md)

# CloudHSM CLI 中的 generate-asymmetric-pair类别
<a name="cloudhsm_cli-key-generate-asymmetric-pair"></a>

在 CloudHSM CLI 中，**key generate-asymmetric-pair** 是一组命令的父类别，当这些命令与父类别结合使用时，会创建一个生成非对称密钥对的命令。目前，此类别由以下命令组成：
+ [密钥 generate-asymmetric-pair ec](cloudhsm_cli-key-generate-asymmetric-pair-ec.md)
+ [密钥 generate-asymmetric-pair rsa](cloudhsm_cli-key-generate-asymmetric-pair-rsa.md)

# 使用 CloudHSM CLI 生成非对称 EC 密钥对
<a name="cloudhsm_cli-key-generate-asymmetric-pair-ec"></a>

使用 CloudHSM CLI 中的**key asymmetric-pair ec**命令在集群中生成非对称椭圆曲线 (EC) 密钥对。 AWS CloudHSM 

## 用户类型
<a name="key-generate-asymmetric-pair-ec-user-type"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="key-generate-asymmetric-pair-ec-requirements"></a>

要运行此命令，必须以 CU 身份登录。

## 语法
<a name="key-generate-asymmetric-pair-ec-syntax"></a>

```
aws-cloudhsm > help key generate-asymmetric-pair ec
Generate an Elliptic-Curve Cryptography (ECC) key pair

Usage: key generate-asymmetric-pair ec [OPTIONS] --public-label <PUBLIC_LABEL> --private-label <PRIVATE_LABEL> --curve <CURVE>

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
      --public-label <PUBLIC_LABEL>
          Label for the public key
      --private-label <PRIVATE_LABEL>
          Label for the private key
      --session
          Creates a session key pair that exists only in the current session. The key cannot be recovered after the session ends
      --curve <CURVE>
          Elliptic curve used to generate the key pair [possible values: prime256v1, secp256r1, secp224r1, secp384r1, secp256k1, secp521r1, ed25519]
      --public-attributes [<PUBLIC_KEY_ATTRIBUTES>...]
          Space separated list of key attributes to set for the generated EC public key in the form of KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE
      --private-attributes [<PRIVATE_KEY_ATTRIBUTES>...]
          Space separated list of key attributes to set for the generated EC private 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 EC private key with
      --manage-private-key-quorum-value <MANAGE_PRIVATE_KEY_QUORUM_VALUE>
          The quorum value for key management operations for the private key
      --use-private-key-quorum-value <USE_PRIVATE_KEY_QUORUM_VALUE>
          The quorum value for key usage operations for the private key
  -h, --help
          Print help
```

## 示例
<a name="key-generate-asymmetric-pair-ec-examples"></a>

这些示例演示如何使用 **key generate-asymmetric-pair ec** 命令创建 EC 密钥对。

**Example 示例：创建 EC 密钥对**  

```
aws-cloudhsm > key generate-asymmetric-pair ec \
    --curve secp224r1 \
    --public-label ec-public-key-example \
    --private-label ec-private-key-example
{
  "error_code": 0,
  "data": {
    "public_key": {
      "key-reference": "0x000000000012000b",
      "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": "ec",
        "label": "ec-public-key-example",
        "id": "",
        "check-value": "0xd7c1a7",
        "class": "public-key",
        "encrypt": false,
        "decrypt": false,
        "token": true,
        "always-sensitive": false,
        "derive": false,
        "destroyable": true,
        "extractable": true,
        "local": true,
        "modifiable": true,
        "never-extractable": false,
        "private": true,
        "sensitive": false,
        "sign": false,
        "trusted": false,
        "unwrap": false,
        "verify": false,
        "wrap": false,
        "wrap-with-trusted": false,
        "key-length-bytes": 57,
        "ec-point": "0x047096513df542250a6b228fd9cb67fd0c903abc93488467681974d6f371083fce1d79da8ad1e9ede745fb9f38ac8622a1b3ebe9270556000c",
        "curve": "secp224r1"
      }
    },
"private_key": {
      "key-reference": "0x000000000012000c",
      "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": "ec",
        "label": "ec-private-key-example",
        "id": "",
        "check-value": "0xd7c1a7",
        "class": "private-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": false,
        "trusted": false,
        "unwrap": false,
        "verify": false,
        "wrap": false,
        "wrap-with-trusted": false,
        "key-length-bytes": 122,
        "ec-point": "0x047096513df542250a6b228fd9cb67fd0c903abc93488467681974d6f371083fce1d79da8ad1e9ede745fb9f38ac8622a1b3ebe9270556000c",
        "curve": "secp224r1"
      }
    }
  }
}
```

**Example 示例：使用可选属性创建 EC 密钥对**  

```
aws-cloudhsm > key generate-asymmetric-pair ec \
    --curve secp224r1 \
    --public-label ec-public-key-example \
    --private-label ec-private-key-example \
    --public-attributes encrypt=true \
    --private-attributes decrypt=true
{
  "error_code": 0,
  "data": {
    "public_key": {
      "key-reference": "0x00000000002806eb",
      "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": "ec",
        "label": "ec-public-key-example",
        "id": "",
        "check-value": "0xedef86",
        "class": "public-key",
        "encrypt": true,
        "decrypt": false,
        "token": true,
        "always-sensitive": false,
        "derive": false,
        "destroyable": true,
        "extractable": true,
        "local": true,
        "modifiable": true,
        "never-extractable": false,
        "private": true,
        "sensitive": false,
        "sign": false,
        "trusted": false,
        "unwrap": false,
        "verify": false,
        "wrap": false,
        "wrap-with-trusted": false,
        "key-length-bytes": 57,
        "ec-point": "0x0487af31882189ec29eddf17a48e8b9cebb075b7b5afc5522fe9c83a029a450cc68592889a1ebf45f32240da5140d58729ffd7b2d44262ddb8",
        "curve": "secp224r1"
      }
    },
    "private_key": {
      "key-reference": "0x0000000000280c82",
      "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": "ec",
        "label": "ec-private-key-example",
        "id": "",
        "check-value": "0xedef86",
        "class": "private-key",
        "encrypt": false,
        "decrypt": true,
        "token": true,
        "always-sensitive": true,
        "derive": false,
        "destroyable": true,
        "extractable": true,
        "local": true,
        "modifiable": true,
        "never-extractable": false,
        "private": true,
        "sensitive": true,
        "sign": false,
        "trusted": false,
        "unwrap": false,
        "verify": false,
        "wrap": false,
        "wrap-with-trusted": false,
        "key-length-bytes": 122,
        "ec-point": "0x0487af31882189ec29eddf17a48e8b9cebb075b7b5afc5522fe9c83a029a450cc68592889a1ebf45f32240da5140d58729ffd7b2d44262ddb8",
        "curve": "secp224r1"
      }
    }
  }
}
```

**Example 示例：使用仲裁值创建 EC 密钥对**  
生成带有仲裁控制的密钥时，该密钥必须与等于最大密钥仲裁值的最小用户数相关联。关联用户包括密钥所有者和与其共享密钥的加密用户。要确定与之共享密钥的最小用户数，请获取密钥使用仲裁值和密钥管理仲裁值之间的最大仲裁值，然后减去 1 以说明密钥所有者（默认情况下与密钥相关联）。要与更多用户共享密钥，请使用 **[使用 CloudHSM CLI 共享密钥](cloudhsm_cli-key-share.md)** 命令。  

```
aws-cloudhsm > key generate-asymmetric-pair ec \
    --curve secp224r1 \
    --public-label ec-public-key-example \
    --private-label ec-private-key-example \
    --public-attributes verify=true \
    --private-attributes sign=true
    --share-crypto-users cu2 cu3 cu4 \
    --manage-private-key-quorum-value 4 \
    --use-private-key-quorum-value 2
{
  "error_code": 0,
  "data": {
    "public_key": {
      "key-reference": "0x00000000002806eb",
      "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": "ec",
        "label": "ec-public-key-example",
        "id": "",
        "check-value": "0xedef86",
        "class": "public-key",
        "encrypt": false,
        "decrypt": false,
        "token": true,
        "always-sensitive": false,
        "derive": false,
        "destroyable": true,
        "extractable": true,
        "local": true,
        "modifiable": true,
        "never-extractable": false,
        "private": true,
        "sensitive": false,
        "sign": false,
        "trusted": false,
        "unwrap": false,
        "verify": true,
        "wrap": false,
        "wrap-with-trusted": false,
        "key-length-bytes": 57,
        "ec-point": "0x0487af31882189ec29eddf17a48e8b9cebb075b7b5afc5522fe9c83a029a450cc68592889a1ebf45f32240da5140d58729ffd7b2d44262ddb8",
        "curve": "secp224r1"
      }
    },
    "private_key": {
      "key-reference": "0x0000000000280c82",
      "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": "ec",
        "label": "ec-private-key-example",
        "id": "",
        "check-value": "0xedef86",
        "class": "private-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": false,
        "wrap": false,
        "wrap-with-trusted": false,
        "key-length-bytes": 122,
        "ec-point": "0x0487af31882189ec29eddf17a48e8b9cebb075b7b5afc5522fe9c83a029a450cc68592889a1ebf45f32240da5140d58729ffd7b2d44262ddb8",
        "curve": "secp224r1"
      }
    }
  }
}
```

## 参数
<a name="key-generate-asymmetric-pair-ec-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<CURVE>***  
指定椭圆曲线的标识符。  
+ prime256v1
+ secp256r1
+ secp224r1
+ secp384r1
+ secp256k1
+ secp521r1
+ ed25519（仅在非 FIPS 模式下的 hsm2m.medium 实例上支持）
是否必需：是

***<PUBLIC\$1KEY\$1ATTRIBUTES>***  
指定一个以空格分隔的密钥属性列表，以 `KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE`（例如 `verify=true`）的形式为生成的 EC 公有密钥进行设置  
有关支持的密钥属性的列表，请参阅 [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)。  
必需：否

***<PUBLIC\$1LABEL>***  
为公有密钥指定用户定义的标签。对于 Client SDK 5.11 及更高版本，`label` 允许的最大大小为 127 个字符。Client SDK 5.10 及更低版本的字符数限制为 126 个。  
是否必需：是

***<PRIVATE\$1KEY\$1ATTRIBUTES>***  
以 `KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE`（例如 `sign=true`）的形式指定要为生成的 EC 私有密钥设置的以空格分隔的密钥属性列表  
有关支持的密钥属性的列表，请参阅 [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)。  
必需：否

***<PRIVATE\$1LABEL>***  
为私有密钥指定用户定义的标签。对于 Client SDK 5.11 及更高版本，`label` 允许的最大大小为 127 个字符。Client SDK 5.10 及更低版本的字符数限制为 126 个。  
是否必需：是

***<SESSION>***  
创建仅在当前会话中存在的密钥。会话结束后，密钥无法恢复。  
如果您只需要一个短暂的密钥，例如用于加密然后快速解密另一个密钥的包装密钥，请使用此参数。对于会话结束后可能需要解密的加密数据，切勿使用会话密钥。  
默认情况下，生成的密钥是永久（令牌）密钥。传入 <SESSION> 会改变这一点，确保使用此参数生成的密钥是会话（临时）密钥。  
必需：否

***<SHARE\$1CRYPTO\$1USERS>***  
指定以空格分隔的加密用户用户名列表，以便与之共享 EC 私有密钥  
必需：否

***<MANAGE\$1PRIVATE\$1KEY\$1QUORUM\$1VALUE>***  
私有密钥的密钥管理操作的仲裁值。此值必须小于或等于与该密钥关联的用户数。这包括与其共享密钥的用户和密钥所有者。最大值为 8。  
必需：否

***<USE\$1PRIVATE\$1KEY\$1QUORUM\$1VALUE>***  
私有密钥的密钥使用操作的仲裁值。此值必须小于或等于与该密钥关联的用户数。这包括与其共享密钥的用户和密钥所有者。最大值为 8。  
必需：否

## 相关主题
<a name="key-generate-asymmetric-pair-ec-seealso"></a>
+ [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)
+ [使用 CloudHSM CLI 筛选密钥](manage-keys-cloudhsm-cli-filtering.md)

# 使用 CloudHSM CLI 生成非对称 RSA 密钥对
<a name="cloudhsm_cli-key-generate-asymmetric-pair-rsa"></a>

使用 CloudHSM CLI 中的**key generate-asymmetric-pair rsa**命令在集群中生成非对称 RSA 密钥对。 AWS CloudHSM 

## 用户类型
<a name="key-generate-asymmetric-pair-rsa-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="key-generate-asymmetric-pair-rsa-requirements"></a>

要运行此命令，必须以 CU 身份登录。

## 语法
<a name="key-generate-asymmetric-pair-rsa-syntax"></a>

```
aws-cloudhsm > help key generate-asymmetric-pair rsa
Generate an RSA key pair

Usage: key generate-asymmetric-pair rsa [OPTIONS] --public-label <PUBLIC_LABEL> --private-label <PRIVATE_LABEL> --modulus-size-bits <MODULUS_SIZE_BITS> --public-exponent <PUBLIC_EXPONENT>

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
      --public-label <PUBLIC_LABEL>
          Label for the public key
      --private-label <PRIVATE_LABEL>
          Label for the private key
      --session
          Creates a session key pair that exists only in the current session. The key cannot be recovered after the session ends
      --modulus-size-bits <MODULUS_SIZE_BITS>
          Modulus size in bits used to generate the RSA key pair
      --public-exponent <PUBLIC_EXPONENT>
          Public exponent used to generate the RSA key pair
      --public-attributes [<PUBLIC_KEY_ATTRIBUTES>...]
          Space separated list of key attributes to set for the generated RSA public key in the form of KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE
      --private-attributes [<PRIVATE_KEY_ATTRIBUTES>...]
          Space separated list of key attributes to set for the generated RSA private 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 RSA key with
      --manage-private-key-quorum-value <MANAGE_PRIVATE_KEY_QUORUM_VALUE>
          The quorum value for key management operations for the private key
      --use-private-key-quorum-value <USE_PRIVATE_KEY_QUORUM_VALUE>
          The quorum value for key usage operations for the private key
  -h, --help
          Print help
```

## 示例
<a name="key-generate-asymmetric-pair-rsa-examples"></a>

这些示例演示如何使用 `key generate-asymmetric-pair rsa` 创建 RSA 密钥对。

**Example 示例：创建 RSA 密钥对**  

```
aws-cloudhsm > key generate-asymmetric-pair rsa \
--public-exponent 65537 \
--modulus-size-bits 2048 \
--public-label rsa-public-key-example \
--private-label rsa-private-key-example
{
  "error_code": 0,
  "data": {
    "public_key": {
      "key-reference": "0x0000000000160010",
      "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": "rsa",
        "label": "rsa-public-key-example",
        "id": "",
        "check-value": "0x498e1f",
        "class": "public-key",
        "encrypt": false,
        "decrypt": false,
        "token": true,
        "always-sensitive": false,
        "derive": false,
        "destroyable": true,
        "extractable": true,
        "local": true,
        "modifiable": true,
        "never-extractable": false,
        "private": true,
        "sensitive": false,
        "sign": false,
        "trusted": false,
        "unwrap": false,
        "verify": false,
        "wrap": false,
        "wrap-with-trusted": false,
        "key-length-bytes": 512,
        "public-exponent": "0x010001",
        "modulus": "0xdfca0669dc8288ed3bad99509bd21c7e6192661407021b3f4cdf4a593d939dd24f4d641af8e4e73b04c847731c6dbdff3385818e08dd6efcbedd6e5b130344968c
e89a065e7d1a46ced96b46b909db2ab6be871ee700fd0a448b6e975bb64cae77c49008749212463e37a577baa57ce3e574cb057e9db131e119badf50c938f26e8a5975c61a8ba7ffe7a1115a
bcebb7d20bd6df1948ae336ae23b52d73b7f3b6acc2543edb6358e08d326d280ce489571f4d34e316a2ea1904d513ca12fa04075fc09ad005c81b7345d7804ff24c45117f0a1020dca7794df037a10aadec8653473b2088711f7b7d8b58431654e14e31af0e00511da641058fb7475ffdbe60f",
        "modulus-size-bits": 2048
      }
    },
"private_key": {
      "key-reference": "0x0000000000160011",
      "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": "rsa",
        "label": "rsa-private-key-example",
        "id": "",
        "check-value": "0x498e1f",
        "class": "private-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": false,
        "trusted": false,
        "unwrap": false,
        "verify": false,
        "wrap": false,
        "wrap-with-trusted": false,
        "key-length-bytes": 1217,
        "public-exponent": "0x010001",
        "modulus": "0xdfca0669dc8288ed3bad99509bd21c7e6192661407021b3f4cdf4a593d939dd24f4d641af8e4e73b04c847731c6dbdff3385818e08dd6efcbedd6e5b130344968ce89a065e7d1a46ced96b46b909db2ab6be871ee700fd0a448b6e975bb64cae77c49008749212463e37a577baa57ce3e574cb057e9db131e119badf50c938f26e8a5975c61a8ba7ffe7a1115abcebb7d20bd6df1948ae336ae23b52d73b7f3b6acc2543edb6358e08d326d280ce489571f4d34e316a2ea1904d513ca12fa04075fc09ad005c81b7345d7804ff24c45117f0a1020dca7794df037a10aadec8653473b2088711f7b7d8b58431654e14e31af0e00511da641058fb7475ffdbe60f",
        "modulus-size-bits": 2048
      }
    }
  }
}
```

**Example 示例：使用可选属性创建 RSA 密钥对**  

```
aws-cloudhsm > key generate-asymmetric-pair rsa \
--public-exponent 65537 \
--modulus-size-bits 2048 \
--public-label rsa-public-key-example \
--private-label rsa-private-key-example \
--public-attributes encrypt=true \
--private-attributes decrypt=true
{
  "error_code": 0,
  "data": {
    "public_key": {
      "key-reference": "0x0000000000280cc8",
      "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": "rsa",
        "label": "rsa-public-key-example",
        "id": "",
        "check-value": "0x01fe6e",
        "class": "public-key",
        "encrypt": true,
        "decrypt": false,
        "token": true,
        "always-sensitive": false,
        "derive": false,
        "destroyable": true,
        "extractable": true,
        "local": true,
        "modifiable": true,
        "never-extractable": false,
        "private": true,
        "sensitive": false,
        "sign": false,
        "trusted": false,
        "unwrap": false,
        "verify": false,
        "wrap": false,
        "wrap-with-trusted": false,
        "key-length-bytes": 512,
        "public-exponent": "0x010001",
        "modulus": "0xb1d27e857a876f4e9fd5de748a763c539b359f937eb4b4260e30d1435485a732c878cdad9c72538e2215351b1d41358c9bf80b599c
73a80fdb457aa7b20cd61e486c326e2cfd5e124a7f6a996437437812b542e3caf85928aa866f0298580f7967ee6aa01440297d7308fdd9b76b70d1b67f12634d
f6e6296d6c116d5744c6d60d14d3bf3cb978fe6b75ac67b7089bafd50d8687213b31abc7dc1bad422780d29c851d5102b56f932551eaf52a9591fd8c43d81ecc
133022653225bd129f8491101725e9ea33e1ded83fb57af35f847e532eb30cd7e726f23910d2671c6364092e834697ec3cef72cc23615a1ba7c5e100156ae0ac
ac3160f0ca9725d38318b7",
        "modulus-size-bits": 2048
      }
    },
    "private_key": {
      "key-reference": "0x0000000000280cc7",
      "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": "rsa",
        "label": "rsa-private-key-example",
        "id": "",
        "check-value": "0x01fe6e",
        "class": "private-key",
        "encrypt": false,
        "decrypt": true,
        "token": true,
        "always-sensitive": true,
        "derive": false,
        "destroyable": true,
        "extractable": true,
        "local": true,
        "modifiable": true,
        "never-extractable": false,
        "private": true,
        "sensitive": true,
        "sign": false,
        "trusted": false,
        "unwrap": false,
        "verify": false,
        "wrap": false,
        "wrap-with-trusted": false,
        "key-length-bytes": 1217,
        "public-exponent": "0x010001",
        "modulus": "0xb1d27e857a876f4e9fd5de748a763c539b359f937eb4b4260e30d1435485a732c878cdad9c72538e2215351b1d41358c9bf80b599c73a80fdb457aa7b20cd61e486c326e2cfd5e124a7f6a996437437812b542e3caf85928aa866f0298580f7967ee6aa01440297d7308fdd9b76b70d1b67f12634df6e6296d6c116d5744c6d60d14d3bf3cb978fe6b75ac67b7089bafd50d8687213b31abc7dc1bad422780d29c851d5102b56f932551eaf52a9591fd8c43d81ecc133022653225bd129f8491101725e9ea33e1ded83fb57af35f847e532eb30cd7e726f23910d2671c6364092e834697ec3cef72cc23615a1ba7c5e100156ae0acac3160f0ca9725d38318b7",
        "modulus-size-bits": 2048
      }
    }
  }
}
```

**Example 示例：使用仲裁值创建 RSA 密钥对**  
生成带有仲裁控制的密钥时，该密钥必须与等于最大密钥仲裁值的最小用户数相关联。关联用户包括密钥所有者和与其共享密钥的加密用户。要确定与之共享密钥的最小用户数，请获取密钥使用仲裁值和密钥管理仲裁值之间的最大仲裁值，然后减去 1 以说明密钥所有者（默认情况下与密钥相关联）。要与更多用户共享密钥，请使用 **[使用 CloudHSM CLI 共享密钥](cloudhsm_cli-key-share.md)** 命令。  

```
aws-cloudhsm > key generate-asymmetric-pair rsa \
--public-exponent 65537 \
--modulus-size-bits 2048 \
--public-label rsa-public-key-example \
--private-label rsa-private-key-example \
--public-attributes verify=true \
--private-attributes sign=true
--share-crypto-users cu2 cu3 cu4 \
--manage-private-key-quorum-value 4 \
--use-private-key-quorum-value 2
{
  "error_code": 0,
  "data": {
    "public_key": {
      "key-reference": "0x0000000000280cc8",
      "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": "rsa",
        "label": "rsa-public-key-example",
        "id": "",
        "check-value": "0x01fe6e",
        "class": "public-key",
        "encrypt": false,
        "decrypt": false,
        "token": true,
        "always-sensitive": false,
        "derive": false,
        "destroyable": true,
        "extractable": true,
        "local": true,
        "modifiable": true,
        "never-extractable": false,
        "private": true,
        "sensitive": false,
        "sign": true,
        "trusted": false,
        "unwrap": false,
        "verify": true,
        "wrap": false,
        "wrap-with-trusted": false,
        "key-length-bytes": 512,
        "public-exponent": "0x010001",
        "modulus": "0xb1d27e857a876f4e9fd5de748a763c539b359f937eb4b4260e30d1435485a732c878cdad9c72538e2215351b1d41358c9bf80b599c
73a80fdb457aa7b20cd61e486c326e2cfd5e124a7f6a996437437812b542e3caf85928aa866f0298580f7967ee6aa01440297d7308fdd9b76b70d1b67f12634d
f6e6296d6c116d5744c6d60d14d3bf3cb978fe6b75ac67b7089bafd50d8687213b31abc7dc1bad422780d29c851d5102b56f932551eaf52a9591fd8c43d81ecc
133022653225bd129f8491101725e9ea33e1ded83fb57af35f847e532eb30cd7e726f23910d2671c6364092e834697ec3cef72cc23615a1ba7c5e100156ae0ac
ac3160f0ca9725d38318b7",
        "modulus-size-bits": 2048
      }
    },
    "private_key": {
      "key-reference": "0x0000000000280cc7",
      "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": "rsa",
        "label": "rsa-private-key-example",
        "id": "",
        "check-value": "0x01fe6e",
        "class": "private-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": false,
        "wrap": false,
        "wrap-with-trusted": false,
        "key-length-bytes": 1217,
        "public-exponent": "0x010001",
        "modulus": "0xb1d27e857a876f4e9fd5de748a763c539b359f937eb4b4260e30d1435485a732c878cdad9c72538e2215351b1d41358c9bf80b599c73a80fdb457aa7b20cd61e486c326e2cfd5e124a7f6a996437437812b542e3caf85928aa866f0298580f7967ee6aa01440297d7308fdd9b76b70d1b67f12634df6e6296d6c116d5744c6d60d14d3bf3cb978fe6b75ac67b7089bafd50d8687213b31abc7dc1bad422780d29c851d5102b56f932551eaf52a9591fd8c43d81ecc133022653225bd129f8491101725e9ea33e1ded83fb57af35f847e532eb30cd7e726f23910d2671c6364092e834697ec3cef72cc23615a1ba7c5e100156ae0acac3160f0ca9725d38318b7",
        "modulus-size-bits": 2048
      }
    }
  }
}
```

## 参数
<a name="key-generate-asymmetric-pair-rsa-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<MODULUS\$1SIZE\$1BITS>***  
 指定模数的长度 (以位为单位)。最小值为 2048。  
是否必需：是

***<PRIVATE\$1KEY\$1ATTRIBUTES>***  
以 `KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE`（例如 `sign=true`）的形式指定要为生成的 RSA 私有密钥设置的以空格分隔的密钥属性列表  
有关支持的密钥属性的列表，请参阅 [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)。  
必需：否

***<PRIVATE\$1LABEL>***  
 为私有密钥指定用户定义的标签。对于 Client SDK 5.11 及更高版本，`label` 允许的最大大小为 127 个字符。Client SDK 5.10 及更低版本的字符数限制为 126 个。  
是否必需：是

***<PUBLIC\$1EXPONENT>***  
指定公有指数。此值必须为大于或等于 65537 的奇数。  
是否必需：是

***<PUBLIC\$1KEY\$1ATTRIBUTES>***  
以 `KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE`（例如 `verify=true`）的形式指定要为生成的 RSA 公有密钥设置的以空格分隔的密钥属性列表。  
有关支持的密钥属性的列表，请参阅 [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)。  
必需：否

***<PUBLIC\$1LABEL>***  
 为公有密钥指定用户定义的标签。对于 Client SDK 5.11 及更高版本，`label` 允许的最大大小为 127 个字符。Client SDK 5.10 及更低版本的字符数限制为 126 个。  
是否必需：是

***<SESSION>***  
创建仅在当前会话中存在的密钥。会话结束后，密钥无法恢复。  
如果您只需要一个短暂的密钥，例如用于加密然后快速解密另一个密钥的包装密钥，请使用此参数。对于会话结束后可能需要解密的加密数据，切勿使用会话密钥。  
默认情况下，生成的密钥是永久（令牌）密钥。传入 <SESSION> 会改变这一点，确保使用此参数生成的密钥是会话（临时）密钥。  
必需：否

***<SHARE\$1CRYPTO\$1USERS>***  
指定以空格分隔的加密用户用户名列表，以便与之共享 RSA 私有密钥  
必需：否

***<MANAGE\$1PRIVATE\$1KEY\$1QUORUM\$1VALUE>***  
私有密钥的密钥管理操作的仲裁值。此值必须小于或等于与该密钥关联的用户数。这包括与其共享密钥的用户和密钥所有者。最大值为 8。  
必需：否

***<USE\$1PRIVATE\$1KEY\$1QUORUM\$1VALUE>***  
私有密钥的密钥使用操作的仲裁值。此值必须小于或等于与该密钥关联的用户数。这包括与其共享密钥的用户和密钥所有者。最大值为 8。  
必需：否

## 相关主题
<a name="key-generate-asymmetric-pair-rsa-seealso"></a>
+ [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)
+ [使用 CloudHSM CLI 筛选密钥](manage-keys-cloudhsm-cli-filtering.md)

# CloudHSM CLI 中的 generate-symmetric 类别
<a name="cloudhsm_cli-key-generate-symmetric"></a>

在 CloudHSM CLI 中，**key generate-symmetric** 是一组命令的父类别，当这些命令与父类别结合使用时，会创建一个生成对称密钥的命令。目前，此类别由以下命令组成：
+ [key generate-symmetric aes](cloudhsm_cli-key-generate-symmetric-aes.md)
+ [key generate-symmetric generic-secret](cloudhsm_cli-key-generate-symmetric-generic-secret.md)

# 使用 CloudHSM CLI 生成对称 AES 密钥
<a name="cloudhsm_cli-key-generate-symmetric-aes"></a>

使用 CloudHSM CLI 中的**key generate-symmetric aes**命令在集群中生成对称 AES 密钥。 AWS CloudHSM 

## 用户类型
<a name="key-generate-symmetric-aes-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="key-generate-symmetric-aes-requirements"></a>

要运行此命令，必须以 CU 身份登录。

## 语法
<a name="key-generate-symmetric-aes-syntax"></a>

```
aws-cloudhsm > help key generate-symmetric aes
Generate an AES key

Usage: key generate-symmetric aes [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 AES 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 AES 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
```

## 示例
<a name="key-generate-symmetric-aes-examples"></a>

以下示例显示了如何使用 **key generate-symmetric aes** 命令创建 AES 密钥。

**Example 示例：创建 AES 密钥**  

```
aws-cloudhsm > key generate-symmetric aes \
--label example-aes \
--key-length-bytes 24
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000002e06bf",
      "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": "aes",
        "label": "example-aes",
        "id": "",
        "check-value": "0x9b94bd",
        "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": 24
      }
    }
  }
}
```

**Example 示例：使用可选属性创建 AES 密钥对**  

```
aws-cloudhsm > key generate-symmetric aes \
--label example-aes \
--key-length-bytes 24 \
--attributes decrypt=true encrypt=true
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000002e06bf",
      "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": "aes",
        "label": "example-aes",
        "id": "",
        "check-value": "0x9b94bd",
        "class": "secret-key",
        "encrypt": true,
        "decrypt": true,
        "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": 24
      }
    }
  }
}
```

**Example 示例：使用仲裁值创建 AES 密钥**  
生成带有仲裁控制的密钥时，该密钥必须与等于最大密钥仲裁值的最小用户数相关联。关联用户包括密钥所有者和与其共享密钥的加密用户。要确定与之共享密钥的最小用户数，请获取密钥使用仲裁值和密钥管理仲裁值之间的最大仲裁值，然后减去 1 以说明密钥所有者（默认情况下与密钥相关联）。要与更多用户共享密钥，请使用 **[使用 CloudHSM CLI 共享密钥](cloudhsm_cli-key-share.md)** 命令。  

```
aws-cloudhsm > key generate-symmetric aes \
--label example-aes \
--key-length-bytes 24 \
--attributes decrypt=true 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": "0x00000000002e06bf",
      "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": "aes",
        "label": "example-aes",
        "id": "",
        "check-value": "0x9b94bd",
        "class": "secret-key",
        "encrypt": true,
        "decrypt": true,
        "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": 24
      }
    }
  }
}
```

## 参数
<a name="key-generate-symmetric-aes-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<KEY\$1ATTRIBUTES>***  
以 `KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE`（例如 `sign=true`）的形式指定要为生成的 AES 密钥设置的按空格分隔的密钥属性列表。  
有关支持的密钥属性的列表，请参阅 [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)。  
必需：否

***<KEY-LENGTH-BYTES>***  
指定以字节为单位的密钥长度。  

有效值：
+ 16、24 和 32
是否必需：是

***<LABEL>***  
为 AES 密钥指定用户定义的标签。对于 Client SDK 5.11 及更高版本，`label` 允许的最大大小为 127 个字符。Client SDK 5.10 及更低版本的字符数限制为 126 个。  
是否必需：是

***<SESSION>***  
创建仅在当前会话中存在的密钥。会话结束后，密钥无法恢复。  
如果您只需要一个短暂的密钥，例如用于加密然后快速解密另一个密钥的包装密钥，请使用此参数。对于会话结束后可能需要解密的加密数据，切勿使用会话密钥。  
默认情况下，生成的密钥是永久（令牌）密钥。传入 <SESSION> 会改变这一点，确保使用此参数生成的密钥是会话（临时）密钥。  
必需：否

***<SHARE\$1CRYPTO\$1USERS>***  
指定以空格分隔的加密用户用户名列表，以便与之共享 AES 密钥  
必需：否

***<MANAGE\$1KEY\$1QUORUM\$1VALUE>***  
密钥管理操作的仲裁值。此值必须小于或等于与该密钥关联的用户数。这包括与其共享密钥的用户和密钥所有者。最大值为 8。  
必需：否

***<USE\$1KEY\$1QUORUM\$1VALUE>***  
密钥使用操作的仲裁值。此值必须小于或等于与该密钥关联的用户数。这包括与其共享密钥的用户和密钥所有者。最大值为 8。  
必需：否

## 相关主题
<a name="key-generate-symmetric-aes-seealso"></a>
+ [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)
+ [使用 CloudHSM CLI 筛选密钥](manage-keys-cloudhsm-cli-filtering.md)

# 使用 CloudHSM CLI 生成对称通用机密密钥
<a name="cloudhsm_cli-key-generate-symmetric-generic-secret"></a>

使用 CloudHSM CLI 中的**key generate-symmetric generic-secret**命令在集群中生成对称通用密钥。 AWS CloudHSM 

## 用户类型
<a name="key-generate-symmetric-generic-secret-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="key-generate-symmetric-generic-secret-requirements"></a>

要运行此命令，必须以 CU 身份登录。

## 语法
<a name="key-generate-symmetric-generic-secret-syntax"></a>

```
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
```

## 示例
<a name="key-generate-symmetric-generic-secret-examples"></a>

以下示例显示了如何使用 **key generate-symmetric generic-secret** 命令创建通用机密密钥。

**Example 示例：创建通用密钥**  

```
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
      }
    }
  }
}
```

**Example 示例：使用可选属性创建通用机密密钥**  

```
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
      }
    }
  }
}
```

**Example 示例：使用仲裁值创建通用密钥**  
生成带有仲裁控制的密钥时，该密钥必须与等于最大密钥仲裁值的最小用户数相关联。关联用户包括密钥所有者和与其共享密钥的加密用户。要确定与之共享密钥的最小用户数，请获取密钥使用仲裁值和密钥管理仲裁值之间的最大仲裁值，然后减去 1 以说明密钥所有者（默认情况下与密钥相关联）。要与更多用户共享密钥，请使用 **[使用 CloudHSM CLI 共享密钥](cloudhsm_cli-key-share.md)** 命令。  

```
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
      }
    }
  }
}
```

## 参数
<a name="key-generate-symmetric-generic-secret-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<KEY\$1ATTRIBUTES>***  
以 `KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE`（例如 `sign=true`）的形式指定要为生成的 AES 密钥设置的按空格分隔的密钥属性列表。  
有关支持的密钥属性的列表，请参阅 [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)。  
必需：否

***<KEY-LENGTH-BYTES>***  
指定以字节为单位的密钥长度。  

有效值：
+ 1 至 800
是否必需：是

***<LABEL>***  
为通用密钥指定用户定义的标签。对于 Client SDK 5.11 及更高版本，`label` 允许的最大大小为 127 个字符。Client SDK 5.10 及更低版本的字符数限制为 126 个。  
是否必需：是

***<SESSION>***  
创建仅在当前会话中存在的密钥。会话结束后，密钥无法恢复。  
如果您只需要一个短暂的密钥，例如用于加密然后快速解密另一个密钥的包装密钥，请使用此参数。对于会话结束后可能需要解密的加密数据，切勿使用会话密钥。  
默认情况下，生成的密钥是永久（令牌）密钥。传入 <SESSION> 会改变这一点，确保使用此参数生成的密钥是会话（临时）密钥。  
必需：否

***<SHARE\$1CRYPTO\$1USERS>***  
以空格分隔的加密用户用户名列表，以便与之共享通用密钥  
必需：否

***<MANAGE\$1KEY\$1QUORUM\$1VALUE>***  
密钥管理操作的仲裁值。此值必须小于或等于与该密钥关联的用户数。这包括与其共享密钥的用户和密钥所有者。最大值为 8。  
必需：否

***<USE\$1KEY\$1QUORUM\$1VALUE>***  
密钥使用操作的仲裁值。此值必须小于或等于与该密钥关联的用户数。这包括与其共享密钥的用户和密钥所有者。最大值为 8。  
必需：否

## 相关主题
<a name="key-generate-symmetric-generic-secret-seealso"></a>
+ [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)
+ [使用 CloudHSM CLI 筛选密钥](manage-keys-cloudhsm-cli-filtering.md)

# 使用 CloudHSM CLI 导入 PEM 格式密钥
<a name="cloudhsm_cli-key-import-pem"></a>

使用中的**key import pem**命令 AWS CloudHSM 将 PEM 格式的密钥导入硬件安全模块 (HSM)。您可以使用它来导入在 HSM 外生成的公有密钥。

**注意**  
使用 [使用 CloudHSM CLI 导出非对称密钥](cloudhsm_cli-key-generate-file.md) 命令从公有密钥创建标准 PEM 文件或使用私有密钥创建引用 PEM 文件。

## 用户类型
<a name="cloudhsm_cli-key-import-pem-user-type"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-import-pem-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-import-pem-syntax"></a>

```
aws-cloudhsm > help key import pem
Import key from a PEM file

Usage: key import pem [OPTIONS] --path <PATH> --label <LABEL> --key-type-class <KEY_TYPE_CLASS>
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
      --path <PATH>
          Path where the key is located in PEM format
      --label <LABEL>
          Label for the imported key
      --key-type-class <KEY_TYPE_CLASS>
          Key type and class of the imported key [possible values: ec-public, rsa-public]
      --attributes [<IMPORT_KEY_ATTRIBUTES>...]
          Space separated list of key attributes in the form of KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE for the imported key
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-import-pem-examples"></a>

以下示例演示了如何使用 **key import pem** 命令从 PEM 格式的文件中导入 RSA 公有密钥。

**Example 示例：导入 RSA 公有密钥**  

```
aws-cloudhsm > key import pem --path /home/example --label example-imported-key --key-type-class rsa-public
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000001e08e3",
      "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": "rsa",
        "label": "example-imported-key",
        "id": "0x",
        "check-value": "0x99fe93",
        "class": "public-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": false,
        "sign": false,
        "trusted": false,
        "unwrap": false,
        "verify": false,
        "wrap": false,
        "wrap-with-trusted": false,
        "key-length-bytes": 512,
        "public-exponent": "0x010001",
        "modulus": "0x8e9c172c37aa22ed1ce25f7c3a7c936dadc532201400128b044ebb4b96│··3e4930ab910df5a2896eaeb8853cfea0e341227654a8337a7864cc8a87d136f006cfba9e68d0b329│··746c1ad60941668b18699fc8169ff1ec363d0d18292845b2454d6a0b8c5d111b79c047619d460cdf│··be59debbacb66b7abeaf3f3d35dd2b9cfa6b6b7b1258b6866cb4085ac749e9d8552b3a4509e1b86c│··828cc794e22767b4f6b5bc6ff5c96f4b7e60eab305d669cfa2197e85379cb35c659bb58fcd246d48│··d9f6a7f36063b42da025459275aa8e3abedad775387086bd6c198ded868403f4b87ffda5a2d455ac│··aa6cbd00003c31d8d2f51d10cd272b31cf0c4037791f48ad51fb35",
        "modulus-size-bits": 2048
      }
    },
    "message": "Successfully imported key"
  }
}
```

**Example 示例：导入具有可选属性的 RSA 公有密钥**  

```
aws-cloudhsm > key import pem --path /home/example --label example-imported-key-with-attributes --key-type-class rsa-public --attributes verify=true
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000001e08e3",
      "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": "rsa",
        "label": "example-imported-key-with-attributes",
        "id": "0x",
        "check-value": "0x99fe93",
        "class": "public-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": false,
        "sign": false,
        "trusted": false,
        "unwrap": false,
        "verify": true,
        "wrap": false,
        "wrap-with-trusted": false,
        "key-length-bytes": 512,
        "public-exponent": "0x010001",
        "modulus": "0x8e9c172c37aa22ed1ce25f7c3a7c936dadc532201400128b044ebb4b96│··3e4930ab910df5a2896eaeb8853cfea0e341227654a8337a7864cc8a87d136f006cfba9e68d0b329│··746c1ad60941668b18699fc8169ff1ec363d0d18292845b2454d6a0b8c5d111b79c047619d460cdf│··be59debbacb66b7abeaf3f3d35dd2b9cfa6b6b7b1258b6866cb4085ac749e9d8552b3a4509e1b86c│··828cc794e22767b4f6b5bc6ff5c96f4b7e60eab305d669cfa2197e85379cb35c659bb58fcd246d48│··d9f6a7f36063b42da025459275aa8e3abedad775387086bd6c198ded868403f4b87ffda5a2d455ac│··aa6cbd00003c31d8d2f51d10cd272b31cf0c4037791f48ad51fb35",
        "modulus-size-bits": 2048
      }
    },
    "message": "Successfully imported key"
  }
}
```

## 参数
<a name="cloudhsm_cli-key-import-pem-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<PATH>***  
指定密钥文件所在的文件路径。  
是否必需：是

***<LABEL>***  
为导入的密钥指定用户定义的标签。`label` 的最大大小为 126 个字符。  
是否必需：是

***<KEY\$1TYPE\$1CLASS>***  
包装密钥的密钥类型和类。  
可能的值：  
+ ec-public
+ rsa-public
是否必需：是

***<IMPORT\$1KEY\$1ATTRIBUTES>***  
以 `KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式指定要为导入的密钥设置的密钥属性列表（例如 `sign=true`），用空格分隔。有关支持的密钥属性的列表，请参阅 [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)。  
必需：否

## 相关主题
<a name="cloudhsm_cli-key-import-pem-seealso"></a>
+ [CloudHSM CLI 中的 crypto sign 类别](cloudhsm_cli-crypto-sign.md)
+ [CloudHSM CLI 中的 crypto verify 类别](cloudhsm_cli-crypto-verify.md)

# 使用 CloudHSM CLI 列出用户的密钥
<a name="cloudhsm_cli-key-list"></a>

使用 CloudHSM CLI 中的**key list**命令查找集群中当前 AWS CloudHSM 用户的所有密钥。输出包含用户拥有和共享的密钥，以及 CloudHSM 集群中的所有公有密钥。

## 用户类型
<a name="chsm-cli-key-list-user-type"></a>

以下类型的用户均可运行此命令。
+ 管理员 () COs
+ 加密用户 (CUs)

## 语法
<a name="chsm-cli-key-list-syntax"></a>

```
aws-cloudhsm > help key list
List the keys the current user owns, shares, and all public keys in the HSM cluster

Usage: key list [OPTIONS]

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 matching key(s) to list
      --max-items <MAX_ITEMS>
          The total number of items to return in the command's output. If the total number of items available is more than the value specified, a next-token is provided in the command's output. To resume pagination, provide the next-token value in the starting-token argument of a subsequent command [default: 10]
      --starting-token <STARTING_TOKEN>
          A token to specify where to start paginating. This is the next-token from a previously truncated response
  -v, --verbose
          If included, prints all attributes and key information for each matched key. By default each matched key only displays its key-reference and label attribute. This flag when used by Admins has no effect
  -h, --help
          Print help
```

## 示例
<a name="chsm-cli-key-list-examples"></a>

以下示例显示运行 **key list** 命令的不同方式。以下示例显示了作为加密用户的输出。

**Example 示例：Find all keys – default**  
此命令列出了 AWS CloudHSM 集群中已登录用户的密钥。  
默认情况下，仅显示当前登录用户的 10 个按键，并且输出中仅显示 `key-reference` 和 `label`。使用适当的分页选项将更多或更少的密钥显示为输出。

```
aws-cloudhsm > key list
{
  "error_code": 0,
  "data": {
    "matched_keys": [
      {
        "key-reference": "0x00000000000003d5",
        "attributes": {
          "label": "test_label_1"
        }
      },
      {
        "key-reference": "0x0000000000000626",
        "attributes": {
          "label": "test_label_2"
        }
      },.
      ...8 keys later...
    ],
    "total_key_count": 56,
    "returned_key_count": 10,
    "next_token": "10"
  }
}
```

**Example 示例：Find all keys – verbose**  
输出包括用户拥有和共享的密钥，以及中的所有公钥 HSMs。  
注意：默认情况下，仅显示当前登录用户的 10 个密钥。使用适当的分页选项将更多或更少的密钥显示为输出。

```
aws-cloudhsm > key list --verbose
{
  "error_code": 0,
  "data": {
    "matched_keys": [
      {
        "key-reference": "0x000000000012000c",
        "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": "ec",
          "label": "ec-test-private-key",
          "id": "",
          "check-value": "0x2a737d",
          "class": "private-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": false,
          "trusted": false,
          "unwrap": false,
          "verify": false,
          "wrap": false,
          "wrap-with-trusted": false,
          "key-length-bytes": 122,
          "ec-point": "0x0442d53274a6c0ec1a23c165dcb9ccdd72c64e98ae1a9594bb5284e752c746280667e11f1e983493c1c605e0a8071ede47ca280f94c6b2aa33",
          "curve": "secp224r1"
        }
      },
      {
        "key-reference": "0x000000000012000d",
        "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": "ec",
          "label": "ec-test-public-key",
          "id": "",
          "check-value": "0x2a737d",
          "class": "public-key",
          "encrypt": false,
          "decrypt": false,
          "token": true,
          "always-sensitive": false,
          "derive": false,
          "destroyable": true,
          "extractable": true,
          "local": true,
          "modifiable": true,
          "never-extractable": false,
          "private": true,
          "sensitive": false,
          "sign": false,
          "trusted": false,
          "unwrap": false,
          "verify": false,
          "wrap": false,
          "wrap-with-trusted": false,
          "key-length-bytes": 57,
          "ec-point": "0x0442d53274a6c0ec1a23c165dcb9ccdd72c64e98ae1a9594bb5284e752c746280667e11f1e983493c1c605e0a8071ede47ca280f94c6b2aa33",
          "curve": "secp224r1"
        }
      }
    ],
      ...8 keys later...
    "total_key_count": 1580,
    "returned_key_count": 10
  }
}
```

**Example 示例：Paginated return**  
以下示例显示密钥的分页子集，其中仅显示两个密钥。然后，该示例提供了一个后续调用以显示接下来的两个密钥。  

```
aws-cloudhsm > key list --verbose --max-items 2
{
  "error_code": 0,
  "data": {
    "matched_keys": [
      {
        "key-reference": "0x0000000000000030",
        "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": "aes",
          "label": "98a6688d1d964ed7b45b9cec5c4b1909",
          "id": "",
          "check-value": "0xb28a46",
          "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": 32
        }
      },
      {
        "key-reference": "0x0000000000000042",
        "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": "aes",
          "label": "4ad6cdcbc02044e09fa954143efde233",
          "id": "",
          "check-value": "0xc98104",
          "class": "secret-key",
          "encrypt": true,
          "decrypt": true,
          "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": true,
          "verify": true,
          "wrap": true,
          "wrap-with-trusted": false,
          "key-length-bytes": 16
        }
      }
    ],
    "total_key_count": 1580,
    "returned_key_count": 2,
    "next_token": "2"
  }
}
```
要显示接下来的 2 个密钥，可以进行后续调用：  

```
aws-cloudhsm > key list --verbose --max-items 2 --starting-token 2
{
  "error_code": 0,
  "data": {
    "matched_keys": [
      {
        "key-reference": "0x0000000000000081",
        "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": "aes",
          "label": "6793b8439d044046982e5b895791e47f",
          "id": "",
          "check-value": "0x3f986f",
          "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": 32
        }
      },
      {
        "key-reference": "0x0000000000000089",
        "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": "aes",
          "label": "56b30fa05c6741faab8f606d3b7fe105",
          "id": "",
          "check-value": "0xe9201a",
          "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": 32
        }
      }
    ],
    "total_key_count": 1580,
    "returned_key_count": 2,
    "next_token": "4"
  }
}
```
有关演示 CloudHSM CLI 中密钥过滤机制的工作原理的更多示例，请参阅 [使用 CloudHSM CLI 筛选密钥](manage-keys-cloudhsm-cli-filtering.md)。

## 参数
<a name="key-list-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择要列出的匹配密钥。  
有关支持的 CloudHSM CLI key 密钥属性列表，请参阅 [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)  
必需：否

***<MAX\$1ITEMS>***  
命令的输出中要返回的项目总数。如果可用的总项目数超过指定的值，则会在命令的输出中提供 next-token。要恢复分页，请在后续命令的 starting-token 参数中提供 next-token 值。  
必需：否

***<STARTING\$1TOKEN>***  
指定从何处开始分页的令牌。这是先前截断的响应中的 next-token。  
必需：否

***<VERBOSE>***  
如果包含，则打印每个匹配密钥的所有属性和密钥信息。默认情况下，每个匹配的密钥仅显示其键引用和标签属性。当管理员使用时，此标志无效。  
必需：否

## 相关主题
<a name="chsm-key-list-seealso"></a>
+ [使用 CloudHSM CLI 删除密钥](cloudhsm_cli-key-delete.md)
+ [使用 CloudHSM CLI 导出非对称密钥](cloudhsm_cli-key-generate-file.md)
+ [使用 CloudHSM CLI 取消共享密钥](cloudhsm_cli-key-unshare.md)
+ [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)
+ [使用 CloudHSM CLI 筛选密钥](manage-keys-cloudhsm-cli-filtering.md)

# 使用 CloudHSM CLI 复制密钥
<a name="cloudhsm_cli-key-replicate"></a>

使用 CloudHSM CLI 中的**key replicate**命令将密钥从 AWS CloudHSM 源集群复制到目标集群。 AWS CloudHSM 

## 用户类型
<a name="chsm-cli-key-replicate-user-type"></a>

以下类型的用户均可运行此命令。
+ 管理员 () COs
+ 加密用户 (CUs)
**注意**  
加密用户必须拥有密钥才能使用此命令。

## 要求
<a name="cloudhsm_cli-key-replicate-requirements"></a>
+ 源集群和目标集群必须是克隆。这意味着其中一个是从另一个的备份创建的，或者它们都是从公共备份创建的。请参阅[使用备份创建集群](create-cluster-from-backup.md)了解更多信息。
+ 密钥的所有者必须存在于目标集群上。此外，如果密钥与任何用户共享，则这些用户也必须存在于目标集群上。
+ 要运行此命令，您必须以加密用户或管理员身份登录源集群和目标集群。
  +  在单命令模式下，该命令将使用 CLOUDHSM\$1PIN 和 CLOUDHSM\$1ROLE 环境变量在源集群上进行身份验证。请参阅[单命令模式](cloudhsm_cli-modes.md#cloudhsm_cli-mode-single-command)了解更多信息。要为目标集群提供凭证，您需要设置两个额外的环境变量：DESTINATION\$1CLOUDHSM\$1PIN 和 DESTINATION\$1CLOUDHSM\$1ROLE：

    ```
    $ export DESTINATION_CLOUDHSM_ROLE=<role>
    ```

    ```
    $ export DESTINATION_CLOUDHSM_PIN=<username:password>
    ```
  +  在交互模式下，用户需要明确登录源集群和目标集群。

## 语法
<a name="chsm-cli-key-replicate-syntax"></a>

```
aws-cloudhsm > help key replicate
Replicate a key from a source to a destination cluster

Usage: key replicate --filter [<FILTER>...] --source-cluster-id <SOURCE_CLUSTER_ID> --destination-cluster-id <DESTINATION_CLUSTER_ID>

Options:
      --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 matching key on the source cluster
      --source-cluster-id <SOURCE_CLUSTER_ID>
          Source cluster ID
      --destination-cluster-id <DESTINATION_CLUSTER_ID>
          Destination cluster ID
  -h, --help
          Print help
```

## 示例
<a name="chsm-cli-key-replicate-examples"></a>

**Example 示例：复制密钥**  
此命令将密钥从源集群复制到克隆的目标集群。以下示例演示了在两个集群上以加密用户身份登录时的输出。  

```
crypto-user-1@cluster-1234abcdefg > key replicate \
      --filter attr.label=example-key \
      --source-cluster-id cluster-1234abcdefg \
      --destination-cluster-id cluster-2345bcdefgh
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x0000000000300006",
      "key-info": {
        "key-owners": [
          {
            "username": "crypto-user-1",
            "key-coverage": "full"
          }
        ],
        "shared-users": [],
        "key-quorum-values": {
          "manage-key-quorum-value": 0,
          "use-key-quorum-value": 0
        },
        "cluster-coverage": "full"
      },
      "attributes": {
        "key-type": "aes",
        "label": "example-key",
        "id": "0x",
        "check-value": "0x5e118e",
        "class": "secret-key",
        "encrypt": false,
        "decrypt": false,
        "token": true,
        "always-sensitive": true,
        "derive": false,
        "destroyable": true,
        "extractable": true,
        "local": true,
        "modifiable": true,
        "never-extractable": true,
        "private": true,
        "sensitive": true,
        "sign": true,
        "trusted": false,
        "unwrap": false,
        "verify": true,
        "wrap": false,
        "wrap-with-trusted": false,
        "key-length-bytes": 16
      }
    },
    "message": "Successfully replicated key"
  }
}
```

## 参数
<a name="key-replicate-arguments"></a>

***<FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择源集群上的匹配密钥。  
有关支持的 CloudHSM CLI key 密钥属性列表，请参阅 [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)  
是否必需：是

***<SOURCE\$1CLUSTER\$1ID>***  
源集群 ID。  
是否必需：是

***<DESTINATION\$1CLUSTER\$1ID>***  
目标集群 ID。  
是否必需：是

## 相关主题
<a name="chsm-key-replicate-seealso"></a>
+ [使用 CloudHSM CLI 连接到多个集群](cloudhsm_cli-configs-multi-cluster.md)

# 使用 CloudHSM CLI 设置密钥的属性
<a name="cloudhsm_cli-key-set-attribute"></a>

使用 CloudHSM CLI 中的**key set-attribute**命令来设置集群中密钥 AWS CloudHSM 的属性。只有创建密钥、并因此拥有密钥的 CU 才能更改密钥属性。

有关可在 CloudHSM CLI 中使用的密钥属性列表，请参阅 [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)。

## 用户类型
<a name="chsm-cli-key-set-attribute-user-type"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs) 可以运行此命令。
+ 管理员可以设置信任属性。

## 要求
<a name="chsm-cli-key-set-attribute-requirements"></a>

要运行此命令，必须以 CU 身份登录。若要设置信任属性，您必须以管理员身份登录。

## 语法
<a name="chsm-cli-key-set-attribute-syntax"></a>

```
aws-cloudhsm > help key set-attribute
Set an attribute for a key in the HSM cluster

Usage: cloudhsm-cli key set-attribute [OPTIONS] --filter [<FILTER>...] --name <KEY_ATTRIBUTE> --value <KEY_ATTRIBUTE_VALUE>

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 matching key to modify
      --name <KEY_ATTRIBUTE>            Name of attribute to be set
      --value <KEY_ATTRIBUTE_VALUE>...  Attribute value to be set
      --approval <APPROVAL>            Filepath of signed quorum token file to approve operation
  -h, --help                            Print help
```

## 示例：设置密钥属性
<a name="chsm-cli-key-set-attribute-examples"></a>

以下示例将介绍了如何使用 **key set-attribute** 命令设置标签。

**Example**  

1. 使用带有 `my_key` 标签的密钥，如下所示：

   ```
   aws-cloudhsm > key set-attribute --filter attr.label=my_key --name encrypt --value false
   {
     "error_code": 0,
     "data": {
       "message": "Attribute set successfully"
     }
   }
   ```

1. 使用 **key list** 命令确认 `encrypt` 属性已更改：

   ```
   aws-cloudhsm > key list --filter attr.label=my_key --verbose
   {
     "error_code": 0,
     "data": {
       "matched_keys": [
         {
           "key-reference": "0x00000000006400ec",
           "key-info": {
             "key-owners": [
               {
                 "username": "bob",
                 "key-coverage": "full"
               }
             ],
             "shared-users": [],
           "key-quorum-values": {
             "manage-key-quorum-value": 0,
             "use-key-quorum-value": 0
           },
             "cluster-coverage": "full"
           },
           "attributes": {
             "key-type": "aes",
             "label": "my_key",
             "id": "",
             "check-value": "0x6bd9f7",
             "class": "secret-key",
             "encrypt": false,
             "decrypt": true,
             "token": true,
             "always-sensitive": true,
             "derive": true,
             "destroyable": true,
             "extractable": true,
             "local": true,
             "modifiable": true,
             "never-extractable": false,
             "private": true,
             "sensitive": true,
             "sign": true,
             "trusted": true,
             "unwrap": true,
             "verify": true,
             "wrap": true,
             "wrap-with-trusted": false,
             "key-length-bytes": 32
           }
         }
       ],
       "total_key_count": 1,
       "returned_key_count": 1
     }
   }
   ```

## 参数
<a name="chsm-cli-key-set-attribute-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<KEY\$1ATTRIBUTE>***  
指定了键属性名称。  
是否必需：是

***<FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择要删除的匹配密钥。  
有关支持的 CloudHSM CLI key 密钥属性列表，请参阅 [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)  
必需：否

***<KEY\$1ATTRIBUTE\$1VALUE>***  
指定密钥属性值。  
是否必需：是

***<KEY\$1REFERENCE>***  
密钥的十六进制或十进制表现形式（例如密钥处理程序）。  
必需：否

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="chsm-cli-key-set-attribute-see-also"></a>
+ [使用 CloudHSM CLI 筛选密钥](manage-keys-cloudhsm-cli-filtering.md)
+ [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)

# 使用 CloudHSM CLI 共享密钥
<a name="cloudhsm_cli-key-share"></a>

使用 CloudHSM CLI 中的**key share**命令 CUs 与集群中的其他 AWS CloudHSM 人共享密钥。

只有创建密钥、并因此拥有密钥的 CU 才能共享密钥。共享密钥的用户可以在加密操作中使用该密钥，但不能删除、导出、共享或取消共享该密钥。此外，这些用户无法更改[密钥属性](cloudhsm_cli-key-attributes.md)。

## 用户类型
<a name="chsm-cli-key-share-user-type"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="chsm-cli-key-share-requirements"></a>

要运行此命令，必须以 CU 身份登录。

## 语法
<a name="chsm-cli-key-share-syntax"></a>

```
aws-cloudhsm > help key share
Share a key in the HSM cluster with another user

Usage: key share --filter [<FILTER>...] --username <USERNAME> --role <ROLE>

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 matching key for sharing

      --username <USERNAME>
          A username with which the key will be shared

      --role <ROLE>
          Role the user has in the cluster

          Possible values:
          - crypto-user: A CryptoUser has the ability to manage and use keys
          - admin:       An Admin has the ability to manage user accounts

      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation

  -h, --help
          Print help (see a summary with '-h')
```

## 示例：与另一个 CU 共享密钥
<a name="chsm-cli-key-share-examples"></a>

以下示例演示了如何使用 **key share** 命令与 CU `alice` 共享密钥。

**Example**  

1. 运行 **key share** 命令与 `alice` 共享密钥。

   ```
   aws-cloudhsm > key share --filter attr.label="rsa_key_to_share" attr.class=private-key --username alice --role crypto-user
   {
     "error_code": 0,
     "data": {
       "message": "Key shared successfully"
     }
   }
   ```

1. 运行 **key list** 命令。

   ```
   aws-cloudhsm > key list --filter attr.label="rsa_key_to_share" attr.class=private-key --verbose
   {
     "error_code": 0,
     "data": {
       "matched_keys": [
         {
           "key-reference": "0x00000000001c0686",
           "key-info": {
             "key-owners": [
               {
                 "username": "cu3",
                 "key-coverage": "full"
               }
             ],
             "shared-users": [
               {
                 "username": "cu2",
                 "key-coverage": "full"
               },
               {
                 "username": "cu1",
                 "key-coverage": "full"
               },
               {
                 "username": "cu4",
                 "key-coverage": "full"
               },
               {
                 "username": "cu5",
                 "key-coverage": "full"
               },
               {
                 "username": "cu6",
                 "key-coverage": "full"
               },
               {
                 "username": "cu7",
                 "key-coverage": "full"
               },
               {
                 "username": "alice",
                 "key-coverage": "full"
               }
             ],
             "key-quorum-values": {
               "manage-key-quorum-value": 0,
               "use-key-quorum-value": 0
             },
             "cluster-coverage": "full"
           },
           "attributes": {
             "key-type": "rsa",
             "label": "rsa_key_to_share",
             "id": "",
             "check-value": "0xae8ff0",
             "class": "private-key",
             "encrypt": false,
             "decrypt": true,
             "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": true,
             "verify": false,
             "wrap": false,
             "wrap-with-trusted": false,
             "key-length-bytes": 1219,
             "public-exponent": "0x010001",
             "modulus": "0xa8855cba933cec0c21a4df0450ec31675c024f3e65b2b215a53d2bda6dcd191f75729150b59b4d86df58254c8f518f7d000cc04d8e958e7502c7c33098e28da4d94378ef34fb57d1cc7e042d9119bd79be0df728421a980a397095157da24cf3cc2b6dab12225d33fdca11f0c6ed1a5127f12488cda9a556814b39b06cd8373ff5d371db2212887853621b8510faa7b0779fbdec447e1f1d19f343acb02b22526487a31f6c704f8f003cb4f7013136f90cc17c2c20e414dc1fc7bcfb392d59c767900319679fc3307388633485657ce2e1a3deab0f985b0747ef4ed339de78147d1985d14fdd8634219321e49e3f5715e79c298f18658504bab04086bfbdcd3b",
             "modulus-size-bits": 2048
           }
         }
       ],
       "total_key_count": 1,
       "returned_key_count": 1
     }
   }
   ```

1. 在上面的列表中，verify `alice` 在 `shared-users` 列表中

## 参数
<a name="chsm-cli-key-share-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择要删除的匹配密钥。  
有关支持的密钥属性的列表，请参阅 [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)。  
是否必需：是

***<USERNAME>***  
为用户指定友好名称。最大长度为 31 个字符。唯一允许的特殊字符是下划线 ( \$1 )。此命令中的用户名不区分大小写，用户名始终以小写形式显示。  
是否必需：是

***<ROLE>***  
指定分配给该用户的角色。此参数为必需参数。要获取用户的角色，请使用 user list 命令。有关 HSM 上的用户类型的详细信息，请参阅 [CloudHSM CLI 的 HSM 用户类型](understanding-users.md)。  
是否必需：是

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="chsm-cli-key-share-see-also"></a>
+ [使用 CloudHSM CLI 筛选密钥](manage-keys-cloudhsm-cli-filtering.md)
+ [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)

# 使用 CloudHSM CLI 取消共享密钥
<a name="cloudhsm_cli-key-unshare"></a>

使用 CloudHSM CLI 中的**key unshare**命令取消 CUs与集群中的其他人共享密钥。 AWS CloudHSM 

只有创建密钥并因此拥有该密钥的 CU 才能取消共享该密钥。共享密钥的用户可以在加密操作中使用该密钥，但不能删除、导出、共享或取消共享该密钥。此外，这些用户无法更改[密钥属性](cloudhsm_cli-key-attributes.md)。

## 用户类型
<a name="chsm-cli-key-unshare-user-type"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="chsm-cli-key-unshare-requirements"></a>

要运行此命令，必须以 CU 身份登录。

## 语法
<a name="chsm-cli-key-unshare-syntax"></a>

```
aws-cloudhsm > help key unshare
Unshare a key in the HSM cluster with another user

Usage: key unshare --filter [<FILTER>...] --username <USERNAME> --role <ROLE>

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 matching key for unsharing

      --username <USERNAME>
          A username with which the key will be unshared

      --role <ROLE>
          Role the user has in the cluster

          Possible values:
          - crypto-user: A CryptoUser has the ability to manage and use keys
          - admin:       An Admin has the ability to manage user accounts

      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation

  -h, --help
          Print help (see a summary with '-h')
```

## 示例：取消与其他 CU 共享密钥
<a name="chsm-cli-key-share-examples"></a>

以下示例演示了如何使用 **key unshare** 命令取消与 CU `alice` 共享密钥。

**Example**  

1. 运行 **key list** 命令并按要取消与 `alice` 共享的特定密钥筛选。

   ```
   aws-cloudhsm > key list --filter attr.label="rsa_key_to_share" attr.class=private-key --verbose
   {
     "error_code": 0,
     "data": {
       "matched_keys": [
         {
           "key-reference": "0x00000000001c0686",
           "key-info": {
             "key-owners": [
               {
                 "username": "cu3",
                 "key-coverage": "full"
               }
             ],
             "shared-users": [
               {
                 "username": "cu2",
                 "key-coverage": "full"
               },
               {
                 "username": "cu1",
                 "key-coverage": "full"
               },
               {
                 "username": "cu4",
                 "key-coverage": "full"
               },
               {
                 "username": "cu5",
                 "key-coverage": "full"
               },
               {
                 "username": "cu6",
                 "key-coverage": "full"
               },
               {
                 "username": "cu7",
                 "key-coverage": "full"
               },
               {
                 "username": "alice",
                 "key-coverage": "full"
               }
             ],
             "key-quorum-values": {
               "manage-key-quorum-value": 0,
               "use-key-quorum-value": 0
             },
             "cluster-coverage": "full"
           },
           "attributes": {
             "key-type": "rsa",
             "label": "rsa_key_to_share",
             "id": "",
             "check-value": "0xae8ff0",
             "class": "private-key",
             "encrypt": false,
             "decrypt": true,
             "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": true,
             "verify": false,
             "wrap": false,
             "wrap-with-trusted": false,
             "key-length-bytes": 1219,
             "public-exponent": "0x010001",
             "modulus": "0xa8855cba933cec0c21a4df0450ec31675c024f3e65b2b215a53d2bda6dcd191f75729150b59b4d86df58254c8f518f7d000cc04d8e958e7502c7c33098e28da4d94378ef34fb57d1cc7e042d9119bd79be0df728421a980a397095157da24cf3cc2b6dab12225d33fdca11f0c6ed1a5127f12488cda9a556814b39b06cd8373ff5d371db2212887853621b8510faa7b0779fbdec447e1f1d19f343acb02b22526487a31f6c704f8f003cb4f7013136f90cc17c2c20e414dc1fc7bcfb392d59c767900319679fc3307388633485657ce2e1a3deab0f985b0747ef4ed339de78147d1985d14fdd8634219321e49e3f5715e79c298f18658504bab04086bfbdcd3b",
             "modulus-size-bits": 2048
           }
         }
       ],
       "total_key_count": 1,
       "returned_key_count": 1
     }
   }
   ```

1. 在 `shared-users` 输出中确认 `alice`，然后运行以下 **key unshare** 命令取消与 `alice` 共享密钥。

   ```
   aws-cloudhsm > key unshare --filter attr.label="rsa_key_to_share" attr.class=private-key --username alice --role crypto-user
   {
     "error_code": 0,
     "data": {
       "message": "Key unshared successfully"
     }
   }
   ```

1. 再次运行 `key list` 命令以确认已取消与 `alice` 共享该密钥。

   ```
   aws-cloudhsm > key list --filter attr.label="rsa_key_to_share" attr.class=private-key --verbose
   {
     "error_code": 0,
     "data": {
       "matched_keys": [
         {
           "key-reference": "0x00000000001c0686",
           "key-info": {
             "key-owners": [
               {
                 "username": "cu3",
                 "key-coverage": "full"
               }
             ],
             "shared-users": [
               {
                 "username": "cu2",
                 "key-coverage": "full"
               },
               {
                 "username": "cu1",
                 "key-coverage": "full"
               },
               {
                 "username": "cu4",
                 "key-coverage": "full"
               },
               {
                 "username": "cu5",
                 "key-coverage": "full"
               },
               {
                 "username": "cu6",
                 "key-coverage": "full"
               },
               {
                 "username": "cu7",
                 "key-coverage": "full"
               },
             ],
             "key-quorum-values": {
               "manage-key-quorum-value": 0,
               "use-key-quorum-value": 0
             },
             "cluster-coverage": "full"
           },
           "attributes": {
             "key-type": "rsa",
             "label": "rsa_key_to_share",
             "id": "",
             "check-value": "0xae8ff0",
             "class": "private-key",
             "encrypt": false,
             "decrypt": true,
             "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": true,
             "verify": false,
             "wrap": false,
             "wrap-with-trusted": false,
             "key-length-bytes": 1219,
             "public-exponent": "0x010001",
             "modulus": "0xa8855cba933cec0c21a4df0450ec31675c024f3e65b2b215a53d2bda6dcd191f75729150b59b4d86df58254c8f518f7d000cc04d8e958e7502c7c33098e28da4d94378ef34fb57d1cc7e042d9119bd79be0df728421a980a397095157da24cf3cc2b6dab12225d33fdca11f0c6ed1a5127f12488cda9a556814b39b06cd8373ff5d371db2212887853621b8510faa7b0779fbdec447e1f1d19f343acb02b22526487a31f6c704f8f003cb4f7013136f90cc17c2c20e414dc1fc7bcfb392d59c767900319679fc3307388633485657ce2e1a3deab0f985b0747ef4ed339de78147d1985d14fdd8634219321e49e3f5715e79c298f18658504bab04086bfbdcd3b",
             "modulus-size-bits": 2048
           }
         }
       ],
       "total_key_count": 1,
       "returned_key_count": 1
     }
   }
   ```

## 参数
<a name="chsm-cli-key-unshare-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择要删除的匹配密钥。  
有关支持的密钥属性的列表，请参阅 [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)。  
是否必需：是

***<USERNAME>***  
为用户指定友好名称。最大长度为 31 个字符。唯一允许的特殊字符是下划线 ( \$1 )。此命令中的用户名不区分大小写，用户名始终以小写形式显示。  
是否必需：是

***<ROLE>***  
指定分配给该用户的角色。此参数为必需参数。要获取用户的角色，请使用 user list 命令。有关 HSM 上的用户类型的详细信息，请参阅 [CloudHSM CLI 的 HSM 用户类型](understanding-users.md)。  
是否必需：是

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="chsm-cli-key-unshare-see-also"></a>
+ [使用 CloudHSM CLI 筛选密钥](manage-keys-cloudhsm-cli-filtering.md)
+ [CloudHSM CLI 的密钥属性](cloudhsm_cli-key-attributes.md)

# CloudHSM CLI 中的 key unwrap 命令
<a name="cloudhsm_cli-key-unwrap"></a>

CloudHSM CLI 中的 **key unwrap** 父命令将加密（包装）的对称或非对称私有密钥从文件导入 HSM。此命令用于导入由 [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md) 命令包装的加密密钥，但也可用于解包由其他工具包装的密钥。不过，在这些情况下，我们建议使用 PKCS\$111 或 JCE 软件库来解开包装密钥。
+ [aes-gcm](cloudhsm_cli-key-unwrap-aes-gcm.md)
+ [aes-no-pad](cloudhsm_cli-key-unwrap-aes-no-pad.md)
+ [aes-pkcs5-pad](cloudhsm_cli-key-unwrap-aes-pkcs5-pad.md)
+ [aes-zero-pad](cloudhsm_cli-key-unwrap-aes-zero-pad.md)
+ [cloudhsm-aes-gcm](cloudhsm_cli-key-unwrap-cloudhsm-aes-gcm.md)
+ [rsa-aes](cloudhsm_cli-key-unwrap-rsa-aes.md)
+ [rsa-oaep](cloudhsm_cli-key-unwrap-rsa-oaep.md)
+ [rsa-pkcs](cloudhsm_cli-key-unwrap-rsa-pkcs.md)

# 使用 CloudHSM CLI 通过 AES-GCM 解包密钥
<a name="cloudhsm_cli-key-unwrap-aes-gcm"></a>

使用 CloudHSM CLI 中的 **key unwrap aes-gcm** 命令，通过 AES 包装密钥和 `AES-GCM` 解包机制将有效载荷密钥解包到集群中。

未封装的密钥的使用方式与生成的 AWS CloudHSM密钥相同。为了表明它们不是本地生成的，其 `local` 属性设置为 `false`。

要使用该**key unwrap aes-gcm**命令，您的 AWS CloudHSM 集群中必须有 AES 包装密钥，并且其`unwrap`属性必须设置为`true`。

## 用户类型
<a name="cloudhsm_cli-key-unwrap-aes-gcm-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-unwrap-aes-gcm-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-unwrap-aes-gcm-syntax"></a>

```
aws-cloudhsm > help key unwrap aes-gcm
Usage: key unwrap aes-gcm [OPTIONS] --filter [<FILTER>...] --tag-length-bits <TAG_LENGTH_BITS> --key-type-class <KEY_TYPE_CLASS> --label <LABEL> --iv <IV> <--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
      --share-crypto-users [<SHARE_CRYPTO_USERS;...]
          Space separated list of Crypto User usernames to share the unwrapped key with
      --manage-key-quorum-value <MANAGE_KEY_QUORUM_VALUE;
          The quorum value for key management operations for the unwrapped key
      --use-key-quorum-value <USE_KEY_QUORUM_VALUE;
          The quorum value for key usage operations for the unwrapped key
      --aad <AAD>
          Aes GCM Additional Authenticated Data (AAD) value, in hex
      --tag-length-bits <TAG_LENGTH_BITS>
          Aes GCM tag length in bits
      --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
      --iv <IV>
          Initial value used to wrap the key, in hex
      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-unwrap-aes-gcm-examples"></a>

这些示例展示了如何通过将 `unwrap` 属性值设置为 `true` 的 AES 密钥来使用 **key unwrap aes-gcm** 命令。

**Example 示例：从 Base64 编码的包装密钥数据中解包有效载荷密钥**  

```
aws-cloudhsm > key unwrap aes-gcm --key-type-class aes --label aes-unwrapped --filter attr.label=aes-example --tag-length-bits 64  --aad 0x10 --iv 0xf90613bb8e337ec0339aad21 --data xvslgrtg8kHzrvekny97tLSIeokpPwV8
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000001808e4",
      "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": "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
      }
    }
  }
}
```

**Example 示例：解包通过数据路径提供的有效载荷密钥**  

```
aws-cloudhsm > key unwrap aes-gcm --key-type-class aes --label aes-unwrapped --filter attr.label=aes-example --tag-length-bits 64  --aad 0x10 --iv 0xf90613bb8e337ec0339aad21 --data-path payload-key.pem
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000001808e4",
      "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": "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
      }
    }
  }
}
```

## 参数
<a name="cloudhsm_cli-key-unwrap-aes-gcm-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择要用于解包的密钥。  
是否必需：是

***<DATA\$1PATH>***  
包含包装的密钥数据的二进制文件的路径。  
必需：是（除非通过 Base64 编码的数据提供）

***<DATA>***  
Base64 编码的包装密钥数据。  
必需：是（除非通过数据路径提供）

***<ATTRIBUTES>***  
包装密钥的空格分隔的密钥属性列表，采用 `KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式。  
必需：否

***<AAD>***  
Aes GCM 额外验证数据（AAD）值（十六进制）。  
必需：否

***<TAG\$1LENGTH\$1BITS>***  
Aes GCM 标签长度（以位为单位）。  
是否必需：是

***<KEY\$1TYPE\$1CLASS>***  
包装密钥的密钥类型和类[可能的值：`aes`、`des3`、`ec-private`、`generic-secret`、`rsa-private`]。  
是否必需：是

***<LABEL>***  
解包密钥的标签。  
是否必需：是

***<SESSION>***  
创建仅在当前会话中存在的会话密钥。会话结束后，密钥无法恢复。  
必需：否

***<IV>***  
用于包装密钥的初始值（十六进制）。  
必需：否

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当解包密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-unwrap-aes-gcm-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# AES-NO-PAD使用 CloudHSM CLI 解开密钥
<a name="cloudhsm_cli-key-unwrap-aes-no-pad"></a>

使用 CloudHSM CLI 中的**key unwrap aes-no-pad**命令使用 AES 包装密钥和解包机制将有效负载密钥解包 AWS CloudHSM 到集群中。`AES-NO-PAD`

未封装的密钥的使用方式与生成的 AWS CloudHSM密钥相同。为了表明它们不是本地生成的，其 `local` 属性设置为 `false`。

要使用该**key unwrap aes-no-pad**命令，您的 AWS CloudHSM 集群中必须有 AES 包装密钥，并且其`unwrap`属性必须设置为`true`。

## 用户类型
<a name="cloudhsm_cli-key-unwrap-aes-no-pad-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-unwrap-aes-no-pad-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-unwrap-aes-no-pad-syntax"></a>

```
aws-cloudhsm > help key unwrap aes-no-pad
Usage: key unwrap aes-no-pad [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
      --share-crypto-users [<SHARE_CRYPTO_USERS;...]
          Space separated list of Crypto User usernames to share the unwrapped key with
      --manage-key-quorum-value <MANAGE_KEY_QUORUM_VALUE;
          The quorum value for key management operations for the unwrapped key
      --use-key-quorum-value <USE_KEY_QUORUM_VALUE;
          The quorum value for key usage operations 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
      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-unwrap-aes-no-pad-examples"></a>

这些示例展示了如何通过将 `unwrap` 属性值设置为 `true` 的 AES 密钥来使用 **key unwrap aes-no-pad** 命令。

**Example 示例：从 Base64 编码的包装密钥数据中解包有效载荷密钥**  

```
aws-cloudhsm > key unwrap aes-no-pad --key-type-class aes --label aes-unwrapped --filter attr.label=aes-example --data eXK3PMAOnKM9y3YX6brbhtMoC060EOH9
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000001c08ec",
      "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": "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
      }
    }
  }
}
```

**Example 示例：解包通过数据路径提供的有效载荷密钥**  

```
aws-cloudhsm > key unwrap aes-no-pad --key-type-class aes --label aes-unwrapped --filter attr.label=aes-example --data-path payload-key.pem
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000001c08ec",
      "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": "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
      }
    }
  }
}
```

## 参数
<a name="cloudhsm_cli-key-unwrap-aes-no-pad-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择要用于解包的密钥。  
是否必需：是

***<DATA\$1PATH>***  
包含包装的密钥数据的二进制文件的路径。  
必需：是（除非通过 Base64 编码的数据提供）

***<DATA>***  
Base64 编码的包装密钥数据。  
必需：是（除非通过数据路径提供）

***<ATTRIBUTES>***  
包装密钥的空格分隔的密钥属性列表，采用 `KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式。  
必需：否

***<KEY\$1TYPE\$1CLASS>***  
包装密钥的密钥类型和类[可能的值：`aes`、`des3`、`ec-private`、`generic-secret`、`rsa-private`]。  
是否必需：是

***<LABEL>***  
解包密钥的标签。  
是否必需：是

***<SESSION>***  
创建仅在当前会话中存在的会话密钥。会话结束后，密钥无法恢复。  
必需：否

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当解包密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-unwrap-aes-no-pad-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# 使用 CloudHSM CLI 使用 AES PKCS5--PAD 解开密钥
<a name="cloudhsm_cli-key-unwrap-aes-pkcs5-pad"></a>

使用 CloudHSM CLI 中的 **key unwrap aes-pkcs5-pad** 命令，通过 AES 包装密钥和 `AES-PKCS5-PAD` 解包机制来解包有效载荷密钥。

未封装的密钥的使用方式与生成的 AWS CloudHSM密钥相同。为了表明它们不是本地生成的，其 `local` 属性设置为 `false`。

要使用该**key unwrap aes-pkcs5-pad**命令，您的 AWS CloudHSM 集群中必须有 AES 包装密钥，并且其`unwrap`属性必须设置为`true`。

## 用户类型
<a name="cloudhsm_cli-key-unwrap-aes-pkcs5-pad-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-unwrap-aes-pkcs5-pad-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-unwrap-aes-pkcs5-pad-syntax"></a>

```
aws-cloudhsm > help key unwrap aes-pkcs5-pad
Usage: key unwrap aes-pkcs5-pad [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
      --share-crypto-users [<SHARE_CRYPTO_USERS;...]
          Space separated list of Crypto User usernames to share the unwrapped key with
      --manage-key-quorum-value <MANAGE_KEY_QUORUM_VALUE;
          The quorum value for key management operations for the unwrapped key
      --use-key-quorum-value <USE_KEY_QUORUM_VALUE;
          The quorum value for key usage operations 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
      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-unwrap-aes-pkcs5-pad-examples"></a>

这些示例展示了如何通过将 `unwrap` 属性值设置为 `true` 的 AES 密钥来使用 **key unwrap aes-pkcs5-pad** 命令。

**Example 示例：从 Base64 编码的包装密钥数据中解包有效载荷密钥**  

```
aws-cloudhsm > key unwrap aes-pkcs5-pad --key-type-class aes --label aes-unwrapped --filter attr.label=aes-example --data MbuYNresfOKyGNnxKWen88nSfX+uUE/0qmGofSisicY=
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000001c08e3",
      "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": "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
      }
    }
  }
}
```

**Example 示例：解包通过数据路径提供的有效载荷密钥**  

```
aws-cloudhsm > key unwrap aes-pkcs5-pad --key-type-class aes --label aes-unwrapped --filter attr.label=aes-example --data-path payload-key.pem
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000001c08e3",
      "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": "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
      }
    }
  }
}
```

## 参数
<a name="cloudhsm_cli-key-unwrap-aes-pkcs5-pad-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择要用于解包的密钥。  
是否必需：是

***<DATA\$1PATH>***  
包含包装的密钥数据的二进制文件的路径。  
必需：是（除非通过 Base64 编码的数据提供）

***<DATA>***  
Base64 编码的包装密钥数据。  
必需：是（除非通过数据路径提供）

***<ATTRIBUTES>***  
包装密钥的空格分隔的密钥属性列表，采用 `KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式。  
必需：否

***<KEY\$1TYPE\$1CLASS>***  
包装密钥的密钥类型和类[可能的值：`aes`、`des3`、`ec-private`、`generic-secret`、`rsa-private`]。  
是否必需：是

***<LABEL>***  
解包密钥的标签。  
是否必需：是

***<SESSION>***  
创建仅在当前会话中存在的会话密钥。会话结束后，密钥无法恢复。  
必需：否

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当解包密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-unwrap-aes-pkcs5-pad-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# AES-ZERO-PAD使用 CloudHSM CLI 解开密钥
<a name="cloudhsm_cli-key-unwrap-aes-zero-pad"></a>

使用 CloudHSM CLI 中的**key unwrap aes-zero-pad**命令使用 AES 包装密钥和解包机制将有效负载密钥解包 AWS CloudHSM 到集群中。`AES-ZERO-PAD`

未封装的密钥的使用方式与生成的 AWS CloudHSM密钥相同。为了表明它们不是本地生成的，其 `local` 属性设置为 `false`。

要使用该**key unwrap aes-no-pad**命令，您的 AWS CloudHSM 集群中必须有 AES 包装密钥，并且其`unwrap`属性必须设置为`true`。

## 用户类型
<a name="cloudhsm_cli-key-unwrap-aes-zero-pad-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-unwrap-aes-zero-pad-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-unwrap-aes-zero-pad-syntax"></a>

```
aws-cloudhsm > help key unwrap aes-zero-pad
Usage: key unwrap aes-zero-pad [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
      --share-crypto-users [<SHARE_CRYPTO_USERS;...]
          Space separated list of Crypto User usernames to share the unwrapped key with
      --manage-key-quorum-value <MANAGE_KEY_QUORUM_VALUE;
          The quorum value for key management operations for the unwrapped key
      --use-key-quorum-value <USE_KEY_QUORUM_VALUE;
          The quorum value for key usage operations 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
      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-unwrap-aes-zero-pad-examples"></a>

这些示例展示了如何通过将 `unwrap` 属性值设置为 `true` 的 AES 密钥来使用 **key unwrap aes-zero-pad** 命令。

**Example 示例：从 Base64 编码的包装密钥数据中解包有效载荷密钥**  

```
aws-cloudhsm > key unwrap aes-zero-pad --key-type-class aes --label aes-unwrapped --filter attr.label=aes-example --data L1wVlL/YeBNVAw6Mpk3owFJZXBzDLONt
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000001c08e7",
      "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": "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
      }
    }
  }
}
```

**Example 示例：解包通过数据路径提供的有效载荷密钥**  

```
aws-cloudhsm > key unwrap aes-zero-pad --key-type-class aes --label aes-unwrapped --filter attr.label=aes-example --data-path payload-key.pem
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000001c08e7",
      "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": "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
      }
    }
  }
}
```

## 参数
<a name="cloudhsm_cli-key-unwrap-aes-zero-pad-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择要用于解包的密钥。  
是否必需：是

***<DATA\$1PATH>***  
包含包装的密钥数据的二进制文件的路径。  
必需：是（除非通过 Base64 编码的数据提供）

***<DATA>***  
Base64 编码的包装密钥数据。  
必需：是（除非通过数据路径提供）

***<ATTRIBUTES>***  
包装密钥的空格分隔的密钥属性列表，采用 `KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式。  
必需：否

***<KEY\$1TYPE\$1CLASS>***  
包装密钥的密钥类型和类[可能的值：`aes`、`des3`、`ec-private`、`generic-secret`、`rsa-private`]。  
是否必需：是

***<LABEL>***  
解包密钥的标签。  
是否必需：是

***<SESSION>***  
创建仅在当前会话中存在的会话密钥。会话结束后，密钥无法恢复。  
必需：否

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当解包密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-unwrap-aes-zero-pad-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# CLOUDHSM-AES-GCM使用 CloudHSM CLI 解开密钥
<a name="cloudhsm_cli-key-unwrap-cloudhsm-aes-gcm"></a>

使用 CloudHSM CLI 中的**key unwrap cloudhsm-aes-gcm**命令使用 AES 包装密钥和解包机制将有效负载密钥解包 AWS CloudHSM 到集群中。`CLOUDHSM-AES-GCM`

未封装的密钥的使用方式与生成的 AWS CloudHSM密钥相同。为了表明它们不是本地生成的，其 `local` 属性设置为 `false`。

要使用该**key unwrap cloudhsm-aes-gcm**命令，您的 AWS CloudHSM 集群中必须有 AES 封装密钥，并且其`unwrap`属性必须设置为`true`。

## 用户类型
<a name="cloudhsm_cli-key-unwrap-cloudhsm-aes-gcm-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-unwrap-cloudhsm-aes-gcm-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-unwrap-cloudhsm-aes-gcm-syntax"></a>

```
aws-cloudhsm > help key unwrap cloudhsm-aes-gcm
Usage: key unwrap cloudhsm-aes-gcm [OPTIONS] --filter [<FILTER>...] --tag-length-bits <TAG_LENGTH_BITS> --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
      --share-crypto-users [<SHARE_CRYPTO_USERS;...]
          Space separated list of Crypto User usernames to share the unwrapped key with
      --manage-key-quorum-value <MANAGE_KEY_QUORUM_VALUE;
          The quorum value for key management operations for the unwrapped key
      --use-key-quorum-value <USE_KEY_QUORUM_VALUE;
          The quorum value for key usage operations for the unwrapped key
      --aad <AAD>
          Aes GCM Additional Authenticated Data (AAD) value, in hex
      --tag-length-bits <TAG_LENGTH_BITS>
          Aes GCM tag length in bits
      --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
      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-unwrap-cloudhsm-aes-gcm-examples"></a>

这些示例展示了如何通过将 `unwrap` 属性值设置为 `true` 的 AES 密钥来使用 **key unwrap cloudhsm-aes-gcm** 命令。

**Example 示例：从 Base64 编码的包装密钥数据中解包有效载荷密钥**  

```
aws-cloudhsm > key unwrap cloudhsm-aes-gcm --key-type-class aes --label aes-unwrapped --filter attr.label=aes-example --tag-length-bits 64  --aad 0x10 --data 6Rn8nkjEriDYlnP3P8nPkYQ8hplOEJ899zsrF+aTB0i/fIlZ
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000001408e8",
      "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": "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
      }
    }
  }
}
```

**Example 示例：解包通过数据路径提供的有效载荷密钥**  

```
aws-cloudhsm > key unwrap cloudhsm-aes-gcm --key-type-class aes --label aes-unwrapped --filter attr.label=aes-example --tag-length-bits 64  --aad 0x10 --data-path payload-key.pem
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000001408e8",
      "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": "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
      }
    }
  }
}
```

## 参数
<a name="cloudhsm_cli-key-unwrap-cloudhsm-aes-gcm-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择要用于解包的密钥。  
是否必需：是

***<DATA\$1PATH>***  
包含包装的密钥数据的二进制文件的路径。  
必需：是（除非通过 Base64 编码的数据提供）

***<DATA>***  
Base64 编码的包装密钥数据。  
必需：是（除非通过数据路径提供）

***<ATTRIBUTES>***  
包装密钥的空格分隔的密钥属性列表，采用 `KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式。  
必需：否

***<AAD>***  
Aes GCM 额外验证数据（AAD）值（十六进制）。  
必需：否

***<TAG\$1LENGTH\$1BITS>***  
Aes GCM 标签长度（以位为单位）。  
是否必需：是

***<KEY\$1TYPE\$1CLASS>***  
包装密钥的密钥类型和类[可能的值：`aes`、`des3`、`ec-private`、`generic-secret`、`rsa-private`]。  
是否必需：是

***<LABEL>***  
解包密钥的标签。  
是否必需：是

***<SESSION>***  
创建仅在当前会话中存在的会话密钥。会话结束后，密钥无法恢复。  
必需：否

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当解包密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-unwrap-cloudhsm-aes-gcm-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# 使用 CloudHSM CLI 通过 RSA-AES 解包密钥
<a name="cloudhsm_cli-key-unwrap-rsa-aes"></a>

使用 CloudHSM CLI 中的 **key unwrap rsa-aes** 命令通过 RSA 私有密钥和 `RSA-AES` 解包机制来解包有效载荷密钥。

未封装的密钥的使用方式与生成的 AWS CloudHSM密钥相同。为了表明它们不是本地生成的，其 `local` 属性设置为 `false`。

要使用**key unwrap rsa-aes**，您的 AWS CloudHSM 集群中必须有 RSA 公用包装密钥的 RSA 私钥，并且其`unwrap`属性必须设置为。`true`

**注意**  
此命令仅适用于 CloudHSM CLI 5.11\$1。

## 用户类型
<a name="cloudhsm_cli-key-unwrap-rsa-aes-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-unwrap-rsa-aes-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-unwrap-rsa-aes-syntax"></a>

```
aws-cloudhsm > help key unwrap rsa-aes
Usage: key unwrap rsa-aes [OPTIONS] --filter [<FILTER>...] --hash-function <HASH_FUNCTION> --mgf <MGF> --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
      --share-crypto-users [<SHARE_CRYPTO_USERS;...]
          Space separated list of Crypto User usernames to share the unwrapped key with
      --manage-key-quorum-value <MANAGE_KEY_QUORUM_VALUE;
          The quorum value for key management operations for the unwrapped key
      --use-key-quorum-value <USE_KEY_QUORUM_VALUE;
          The quorum value for key usage operations for the unwrapped key
      --hash-function <HASH_FUNCTION>
          Hash algorithm [possible values: sha1, sha224, sha256, sha384, sha512]
      --mgf <MGF>
          Mask Generation Function algorithm [possible values: mgf1-sha1, mgf1-sha224, mgf1-sha256, mgf1-sha384, mgf1-sha512]
      --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
      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-unwrap-rsa-aes-examples"></a>

这些示例展示了如何通过将 `unwrap` 属性值设置为 `true` 的 RSA 私有密钥来使用 **key unwrap rsa-aes** 命令。

**Example 示例：从 Base64 编码的包装密钥数据中解包有效载荷密钥**  

```
aws-cloudhsm > key unwrap rsa-aes --key-type-class aes --label aes-unwrapped --filter attr.label=rsa-private-key-example --hash-function sha256 --mgf mgf1-sha256 --data HrSE1DEyLjIeyGdPa9R+ebiqB5TIJGyamPker31ZebPwRA+NcerbAJO8DJ1lXPygZcI21vIFSZJuWMEiWpe1R9D/5WSYgxLVKex30xCFqebtEzxbKuv4DOmU4meSofqREYvtb3EoIKwjyxCMRQFgoyUCuP4y0f0eSv0k6rSJh4NuCsHptXZbtgNeRcR4botN7LlzkEIUcq4fVHaatCwd0J1QGKHKyRhkol+RL5WGXKe4nAboAkC5GO7veI5yHL1SaKlssSJtTL/CFpbSLsAFuYbv/NUCWwMY5mwyVTCSlw+HlgKK+5TH1MzBaSi8fpfyepLT8sHy2Q/VRl6ifb49p6m0KQFbRVvz/OWUd6l4d97BdgtaEz6ueg==
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000001808e2",
      "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": "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
      }
    }
  }
}
```

**Example 示例：解包通过数据路径提供的有效载荷密钥**  

```
aws-cloudhsm > key unwrap rsa-aes --key-type-class aes --label aes-unwrapped --filter attr.label=rsa-private-key-example --hash-function sha256 --mgf mgf1-sha256 --data-path payload-key.pem
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000001808e2",
      "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": "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
      }
    }
  }
}
```

## 参数
<a name="cloudhsm_cli-key-unwrap-rsa-aes-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择要用于解包的密钥。  
是否必需：是

***<DATA\$1PATH>***  
包含包装的密钥数据的二进制文件的路径。  
必需：是（除非通过 Base64 编码的数据提供）

***<DATA>***  
Base64 编码的包装密钥数据。  
必需：是（除非通过数据路径提供）

***<ATTRIBUTES>***  
包装密钥的空格分隔的密钥属性列表，采用 `KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式。  
必需：否

***<KEY\$1TYPE\$1CLASS>***  
包装密钥的密钥类型和类[可能的值：`aes`、`des3`、`ec-private`、`generic-secret`、`rsa-private`]。  
是否必需：是

***<HASH\$1FUNCTION>***  
指定哈希函数。  
有效值：  
+ sha1
+ sha224
+ sha256
+ sha384
+ sha512
是否必需：是

***<MGF>***  
指定掩码生成函数。  
掩码生成函数哈希函数必须与签名机制哈希函数相匹配。
有效值：  
+ mgf1-sha1
+ mgf1-sha224
+ mgf1-sha256
+ mgf1-sha384
+ mgf1-sha512
是否必需：是

***<LABEL>***  
解包密钥的标签。  
是否必需：是

***<SESSION>***  
创建仅在当前会话中存在的会话密钥。会话结束后，密钥无法恢复。  
必需：否

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当解包密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-unwrap-rsa-aes-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# 使用 CloudHSM CLI 通过 RSA-OAEP 解包密钥
<a name="cloudhsm_cli-key-unwrap-rsa-oaep"></a>

使用 CloudHSM CLI 中的 **key unwrap rsa-oaep** 命令通过 RSA 私有密钥和 `RSA-OAEP` 解包机制来解包有效载荷密钥。

未封装的密钥的使用方式与生成的 AWS CloudHSM密钥相同。为了表明它们不是本地生成的，其 `local` 属性设置为 `false`。

要使用该**key unwrap rsa-oaep**命令，您的 AWS CloudHSM 集群中必须有 RSA 公用包装密钥的 RSA 私钥，并且其`unwrap`属性必须设置为。`true`

## 用户类型
<a name="cloudhsm_cli-key-unwrap-rsa-oaep-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-unwrap-rsa-oaep-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-unwrap-rsa-oaep-syntax"></a>

```
aws-cloudhsm > help key unwrap rsa-oaep
Usage: key unwrap rsa-oaep [OPTIONS] --filter [<FILTER>...] --hash-function <HASH_FUNCTION> --mgf <MGF> --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
      --share-crypto-users [<SHARE_CRYPTO_USERS;...]
          Space separated list of Crypto User usernames to share the unwrapped key with
      --manage-key-quorum-value <MANAGE_KEY_QUORUM_VALUE;
          The quorum value for key management operations for the unwrapped key
      --use-key-quorum-value <USE_KEY_QUORUM_VALUE;
          The quorum value for key usage operations for the unwrapped key
      --hash-function <HASH_FUNCTION>
          Hash algorithm [possible values: sha1, sha224, sha256, sha384, sha512]
      --mgf <MGF>
          Mask Generation Function algorithm [possible values: mgf1-sha1, mgf1-sha224, mgf1-sha256, mgf1-sha384, mgf1-sha512]
      --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
      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-unwrap-rsa-oaep-examples"></a>

这些示例展示了如何通过将 `unwrap` 属性值设置为 `true` 的 RSA 私有密钥来使用 **key unwrap rsa-oaep** 命令。

**Example 示例：从 Base64 编码的包装密钥数据中解包有效载荷密钥**  

```
aws-cloudhsm > key unwrap rsa-oaep --key-type-class aes --label aes-unwrapped --filter attr.label=rsa-private-example-key --hash-function sha256 --mgf mgf1-sha256 --data OjJe4msobPLz9TuSAdULEu17T5rMDWtSlLyBSkLbaZnYzzpdrhsbGLbwZJCtB/jGkDNdB4qyTAOQwEpggGf6v+Yx6JcesNeKKNU8XZal/YBoHC8noTGUSDI2qr+u2tDc84NPv6d+F2KOONXsSxMhmxzzNG/gzTVIJhOuy/B1yHjGP4mOXoDZf5+7f5M1CjxBmz4Vva/wrWHGCSG0yOaWblEvOiHAIt3UBdyKmU+/My4xjfJv7WGGu3DFUUIZ06TihRtKQhUYU1M9u6NPf9riJJfHsk6QCuSZ9yWThDT9as6i7e3htnyDhIhGWaoK8JU855cN/YNKAUqkNpC4FPL3iw==
{
  "data": {
    "key": {
      "key-reference": "0x00000000001808e9",
      "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": "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
      }
    }
  }
}
```

**Example 示例：解包通过数据路径提供的有效载荷密钥**  

```
aws-cloudhsm > key unwrap rsa-oaep --key-type-class aes --label aes-unwrapped --filter attr.label=rsa-private-example-key --hash-function sha256 --mgf mgf1-sha256 --data-path payload-key.pem
{
  "error_code": 0,
  "data": {
    "key": {
      "key-reference": "0x00000000001808e9",
      "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": "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
      }
    }
  }
}
```

## 参数
<a name="cloudhsm_cli-key-unwrap-rsa-oaep-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择要用于解包的密钥。  
是否必需：是

***<DATA\$1PATH>***  
包含包装的密钥数据的二进制文件的路径。  
必需：是（除非通过 Base64 编码的数据提供）

***<DATA>***  
Base64 编码的包装密钥数据。  
必需：是（除非通过数据路径提供）

***<ATTRIBUTES>***  
包装密钥的空格分隔的密钥属性列表，采用 `KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式。  
必需：否

***<KEY\$1TYPE\$1CLASS>***  
包装密钥的密钥类型和类[可能的值：`aes`、`des3`、`ec-private`、`generic-secret`、`rsa-private`]。  
是否必需：是

***<HASH\$1FUNCTION>***  
指定哈希函数。  
有效值：  
+ sha1
+ sha224
+ sha256
+ sha384
+ sha512
是否必需：是

***<MGF>***  
指定掩码生成函数。  
掩码生成函数哈希函数必须与签名机制哈希函数相匹配。
有效值：  
+ mgf1-sha1
+ mgf1-sha224
+ mgf1-sha256
+ mgf1-sha384
+ mgf1-sha512
是否必需：是

***<LABEL>***  
解包密钥的标签。  
是否必需：是

***<SESSION>***  
创建仅在当前会话中存在的会话密钥。会话结束后，密钥无法恢复。  
必需：否

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当解包密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-unwrap-rsa-oaep-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# 使用 CloudHSM CLI 通过 RSA-PKCS 解包密钥
<a name="cloudhsm_cli-key-unwrap-rsa-pkcs"></a>

使用 CloudHSM CLI 中的 **key unwrap rsa-pkcs** 命令通过 RSA 私有密钥和 `RSA-PKCS` 解包机制来解包有效载荷密钥。

未封装的密钥的使用方式与生成的 AWS CloudHSM密钥相同。为了表明它们不是本地生成的，其 `local` 属性设置为 `false`。

要使用 key **unwrap rsa-pkcs** 命令，您的 AWS CloudHSM 集群中必须有 RSA 公用包装密钥的 RSA 私钥，并且其`unwrap`属性必须设置为。`true`

## 用户类型
<a name="cloudhsm_cli-key-unwrap-rsa-pkcs-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-unwrap-rsa-pkcs-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-unwrap-rsa-pkcs-syntax"></a>

```
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
      --share-crypto-users [<SHARE_CRYPTO_USERS;...]
          Space separated list of Crypto User usernames to share the unwrapped key with
      --manage-key-quorum-value <MANAGE_KEY_QUORUM_VALUE;
          The quorum value for key management operations for the unwrapped key
      --use-key-quorum-value <USE_KEY_QUORUM_VALUE;
          The quorum value for key usage operations 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
      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-unwrap-rsa-pkcs-examples"></a>

这些示例展示了如何通过将 `unwrap` 属性值设置为 `true` 的 AES 密钥来使用 **key unwrap rsa-oaep** 命令。

**Example 示例：从 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": [],
        "key-quorum-values": {
          "manage-key-quorum-value": 0,
          "use-key-quorum-value": 0
        },
        "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
      }
    }
  }
}
```

**Example 示例：解包通过数据路径提供的有效载荷密钥**  

```
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": [],
        "key-quorum-values": {
          "manage-key-quorum-value": 0,
          "use-key-quorum-value": 0
        },
        "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
      }
    }
  }
}
```

## 参数
<a name="cloudhsm_cli-key-unwrap-rsa-pkcs-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择要用于解包的密钥。  
是否必需：是

***<DATA\$1PATH>***  
包含包装的密钥数据的二进制文件的路径。  
必需：是（除非通过 Base64 编码的数据提供）

***<DATA>***  
Base64 编码的包装密钥数据。  
必需：是（除非通过数据路径提供）

***<ATTRIBUTES>***  
包装密钥的空格分隔的密钥属性列表，采用 `KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式。  
必需：否

***<KEY\$1TYPE\$1CLASS>***  
包装密钥的密钥类型和类[可能的值：`aes`、`des3`、`ec-private`、`generic-secret`、`rsa-private`]。  
是否必需：是

***<LABEL>***  
解包密钥的标签。  
是否必需：是

***<SESSION>***  
创建仅在当前会话中存在的会话密钥。会话结束后，密钥无法恢复。  
必需：否

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当解包密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-unwrap-rsa-pkcs-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# CloudHSM CLI 中的 key wrap 命令
<a name="cloudhsm_cli-key-wrap"></a>

CloudHSM CLI 中的 **key wrap** 命令将对称或非对称私有密钥的加密副本从硬件安全模块（HSM)）导出到文件中。运行 **key wrap** 时，需要指定两项内容：要导出的密钥和输出文件。要导出的密钥是 HSM 上的密钥，它将加密（包装）您要导出的密钥。

**key wrap** 命令不会从 HSM 中删除该密钥，也不会阻止您将它用于加密操作。您可以多次导出相同的密钥。要将加密的密钥导入 HSM 中，请使用 [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)。只有密钥的所有者（即创建密钥的加密用户（CU））才能包装密钥。与其共享密钥的用户只能在加密操作中使用该密钥。

**key wrap** 命令由以下子命令组成：
+ [aes-gcm](cloudhsm_cli-key-wrap-aes-gcm.md)
+ [aes-no-pad](cloudhsm_cli-key-wrap-aes-no-pad.md)
+ [aes-pkcs5-pad](cloudhsm_cli-key-wrap-aes-pkcs5-pad.md)
+ [aes-zero-pad](cloudhsm_cli-key-wrap-aes-zero-pad.md)
+ [cloudhsm-aes-gcm](cloudhsm_cli-key-wrap-cloudhsm-aes-gcm.md)
+ [rsa-aes](cloudhsm_cli-key-wrap-rsa-aes.md)
+ [rsa-oaep](cloudhsm_cli-key-wrap-rsa-oaep.md)
+ [rsa-pkcs](cloudhsm_cli-key-wrap-rsa-pkcs.md)

# 使用 CloudHSM CLI 通过 AES-GCM 解包密钥
<a name="cloudhsm_cli-key-wrap-aes-gcm"></a>

使用 CloudHSM CLI 中的 **key wrap aes-gcm** 命令通过硬件安全模块（HSM）上的 AES 密钥和 `AES-GCM` 包装机制包装有效载荷密钥。有效载荷密钥的 `extractable` 属性必须设置为 `true`。

只有密钥的所有者（即创建密钥的加密用户（CU））才能包装密钥。共享密钥的用户可以使用该密钥进行加密操作。

要使用该**key wrap aes-gcm**命令，您必须先在 AWS CloudHSM 集群中拥有 AES 密钥。您可以使用 [使用 CloudHSM CLI 生成对称 AES 密钥](cloudhsm_cli-key-generate-symmetric-aes.md) 命令并将 `wrap` 属性设置为 `true` 来生成用于包装的 AES 密钥。

## 用户类型
<a name="cloudhsm_cli-key-wrap-aes-gcm-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-wrap-aes-gcm-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-wrap-aes-gcm-syntax"></a>

```
aws-cloudhsm > help key wrap aes-gcm
Usage: key wrap aes-gcm [OPTIONS] --payload-filter [<PAYLOAD_FILTER>...] --wrapping-filter [<WRAPPING_FILTER>...] --tag-length-bits <TAG_LENGTH_BITS>

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
      --payload-filter [<PAYLOAD_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 payload key
      --wrapping-filter [<WRAPPING_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 wrapping key
      --path <PATH>
          Path to the binary file where the wrapped key data will be saved
      --wrapping-approval <WRAPPING_APPROVALR>
          File path of signed quorum token file to approve operation for wrapping key
      --payload-approval <PAYLOAD_APPROVALR>
          File path of signed quorum token file to approve operation for payload key
      --aad <AAD>
          Aes GCM Additional Authenticated Data (AAD) value, in hex
      --tag-length-bits <TAG_LENGTH_BITS>
          Aes GCM tag length in bits
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-wrap-aes-gcm-examples"></a>

此示例演示如何通过 AES 密钥使用 **key wrap aes-gcm** 命令。

**Example**  

```
aws-cloudhsm > key wrap aes-gcm --payload-filter attr.label=payload-key --wrapping-filter attr.label=aes-example --tag-length-bits 64  --aad 0x10
{
  "error_code": 0,
  "data": {
    "payload_key_reference": "0x00000000001c08f1",
    "wrapping_key_reference": "0x00000000001c08ea",
    "iv": "0xf90613bb8e337ec0339aad21",
    "wrapped_key_data": "xvslgrtg8kHzrvekny97tLSIeokpPwV8"
  }
}
```

## 参数
<a name="cloudhsm_cli-key-wrap-aes-gcm-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<PAYLOAD\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择有效载荷密钥。  
是否必需：是

***<PATH>***  
保存包装密钥数据的二进制文件的路径。  
必需：否

***<WRAPPING\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择包装密钥。  
是否必需：是

***<AAD>***  
AES GCM 额外验证数据（AAD）值（十六进制）。  
必需：否

***<TAG\$1LENGTH\$1BITS>***  
AES GCM 标签长度（以位为单位）。  
是否必需：是

***<WRAPPING\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准包装密钥的操作。仅当包装密钥的密钥管理服务仲裁值大于 1 时才需要。

***<PAYLOAD\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准有效载荷密钥的操作。仅当有效载荷密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-wrap-aes-gcm-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# AES-NO-PAD使用 CloudHSM CLI 封装密钥
<a name="cloudhsm_cli-key-wrap-aes-no-pad"></a>

使用 CloudHSM CLI 中的 **key wrap aes-no-pad** 命令通过硬件安全模块（HSM）上的 AES 密钥和 `AES-NO-PAD` 包装机制包装有效载荷密钥。有效载荷密钥的 `extractable` 属性必须设置为 `true`。

只有密钥的所有者（即创建密钥的加密用户（CU））才能包装密钥。共享密钥的用户可以使用该密钥进行加密操作。

要使用该**key wrap aes-no-pad**命令，您必须先在 AWS CloudHSM 集群中拥有 AES 密钥。您可以使用 [使用 CloudHSM CLI 生成对称 AES 密钥](cloudhsm_cli-key-generate-symmetric-aes.md) 命令并将 `wrap` 属性设置为 `true` 来生成用于包装的 AES 密钥。

## 用户类型
<a name="cloudhsm_cli-key-wrap-aes-no-pad-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-wrap-aes-no-pad-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-wrap-aes-no-pad-syntax"></a>

```
aws-cloudhsm > help key wrap aes-no-pad
Usage: key wrap aes-no-pad [OPTIONS] --payload-filter [<PAYLOAD_FILTER>...] --wrapping-filter [<WRAPPING_FILTER>...]

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
      --payload-filter [<PAYLOAD_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 payload key
      --wrapping-filter [<WRAPPING_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 wrapping key
      --path <PATH>
          Path to the binary file where the wrapped key data will be saved
      --wrapping-approval <WRAPPING_APPROVALR>
          File path of signed quorum token file to approve operation for wrapping key
      --payload-approval <PAYLOAD_APPROVALR>
          File path of signed quorum token file to approve operation for payload key
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-wrap-aes-no-pad-examples"></a>

此示例展示了如何通过 AES 密钥使用 **key wrap aes-no-pad** 命令并将 `wrap` 属性值设置为 `true`。

**Example**  

```
aws-cloudhsm > key wrap aes-no-pad --payload-filter attr.label=payload-key --wrapping-filter attr.label=aes-example
{
  "error_code": 0,
  "data": {
    "payload_key_reference": "0x00000000001c08f1",
    "wrapping_key_reference": "0x00000000001c08ea",
    "wrapped_key_data": "eXK3PMAOnKM9y3YX6brbhtMoC060EOH9"
  }
}
```

## 参数
<a name="cloudhsm_cli-key-wrap-aes-no-pad-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<PAYLOAD\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择有效载荷密钥。  
是否必需：是

***<PATH>***  
保存包装密钥数据的二进制文件的路径。  
必需：否

***<WRAPPING\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择包装密钥。  
是否必需：是

***<WRAPPING\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准包装密钥的操作。仅当包装密钥的密钥管理服务仲裁值大于 1 时才需要。

***<PAYLOAD\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准有效载荷密钥的操作。仅当有效载荷密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-wrap-aes-no-pad-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# 使用 CloudHSM CLI 用 AES-PKCS5-PAD 封装密钥
<a name="cloudhsm_cli-key-wrap-aes-pkcs5-pad"></a>

使用 CloudHSM CLI 中的 **key wrap aes-pkcs5-pad** 命令通过硬件安全模块（HSM）上的 AES 密钥和 `AES-PKCS5-PAD` 包装机制包装有效载荷密钥。有效载荷密钥的 `extractable` 属性必须设置为 `true`。

只有密钥的所有者（即创建密钥的加密用户（CU））才能包装密钥。共享密钥的用户可以使用该密钥进行加密操作。

要使用该**key wrap aes-pkcs5-pad**命令，您必须先在 AWS CloudHSM 集群中拥有 AES 密钥。您可以使用 [使用 CloudHSM CLI 生成对称 AES 密钥](cloudhsm_cli-key-generate-symmetric-aes.md) 命令并将 `wrap` 属性设置为 `true` 来生成用于包装的 AES 密钥。

## 用户类型
<a name="cloudhsm_cli-key-wrap-aes-pkcs5-pad-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-wrap-aes-pkcs5-pad-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-wrap-aes-pkcs5-pad-syntax"></a>

```
aws-cloudhsm > help key wrap aes-pkcs5-pad
Usage: key wrap aes-pkcs5-pad [OPTIONS] --payload-filter [<PAYLOAD_FILTER>...] --wrapping-filter [<WRAPPING_FILTER>...]

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
      --payload-filter [<PAYLOAD_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 payload key
      --wrapping-filter [<WRAPPING_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 wrapping key
      --path <PATH>
          Path to the binary file where the wrapped key data will be saved
      --wrapping-approval <WRAPPING_APPROVALR>
          File path of signed quorum token file to approve operation for wrapping key
      --payload-approval <PAYLOAD_APPROVALR>
          File path of signed quorum token file to approve operation for payload key
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-wrap-aes-pkcs5-pad-examples"></a>

此示例展示了如何通过 AES 密钥使用 **key wrap aes-pkcs5-pad** 命令并将 `wrap` 属性值设置为 `true`。

**Example**  

```
aws-cloudhsm > key wrap aes-pkcs5-pad --payload-filter attr.label=payload-key --wrapping-filter attr.label=aes-example
{
  "error_code": 0,
  "data": {
    "payload_key_reference": "0x00000000001c08f1",
    "wrapping_key_reference": "0x00000000001c08ea",
    "wrapped_key_data": "MbuYNresfOKyGNnxKWen88nSfX+uUE/0qmGofSisicY="
  }
}
```

## 参数
<a name="cloudhsm_cli-key-wrap-aes-pkcs5-pad-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<PAYLOAD\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择有效载荷密钥。  
是否必需：是

***<PATH>***  
保存包装密钥数据的二进制文件的路径。  
必需：否

***<WRAPPING\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择包装密钥。  
是否必需：是

***<WRAPPING\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准包装密钥的操作。仅当包装密钥的密钥管理服务仲裁值大于 1 时才需要。

***<PAYLOAD\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准有效载荷密钥的操作。仅当有效载荷密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-wrap-aes-pkcs5-pad-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# AES-ZERO-PAD使用 CloudHSM CLI 封装密钥
<a name="cloudhsm_cli-key-wrap-aes-zero-pad"></a>

使用 CloudHSM CLI 中的 **key wrap aes-zero-pad** 命令通过硬件安全模块（HSM）上的 AES 密钥和 `AES-ZERO-PAD` 包装机制包装有效载荷密钥。有效载荷密钥的 `extractable` 属性必须设置为 `true`。

只有密钥的所有者（即创建密钥的加密用户（CU））才能包装密钥。共享密钥的用户可以使用该密钥进行加密操作。

要使用该**key wrap aes-zero-pad**命令，您必须先在 AWS CloudHSM 集群中拥有 AES 密钥。您可以使用 [使用 CloudHSM CLI 生成对称 AES 密钥](cloudhsm_cli-key-generate-symmetric-aes.md) 命令并将 `wrap` 属性设置为 `true` 来生成用于包装的 AES 密钥。

## 用户类型
<a name="cloudhsm_cli-key-wrap-aes-zero-pad-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-wrap-aes-zero-pad-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-wrap-aes-zero-pad-syntax"></a>

```
aws-cloudhsm > help key wrap aes-zero-pad
Usage: key wrap aes-zero-pad [OPTIONS] --payload-filter [<PAYLOAD_FILTER>...] --wrapping-filter [<WRAPPING_FILTER>...]

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
      --payload-filter [<PAYLOAD_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 payload key
      --wrapping-filter [<WRAPPING_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 wrapping key
      --path <PATH>
          Path to the binary file where the wrapped key data will be saved
      --wrapping-approval <WRAPPING_APPROVALR>
          File path of signed quorum token file to approve operation for wrapping key
      --payload-approval <PAYLOAD_APPROVALR>
          File path of signed quorum token file to approve operation for payload key
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-wrap-aes-zero-pad-examples"></a>

此示例展示了如何通过 AES 密钥使用 **key wrap aes-zero-pad ** 命令并将 `wrap` 属性值设置为 `true`。

**Example**  

```
aws-cloudhsm > key wrap aes-zero-pad --payload-filter attr.label=payload-key --wrapping-filter attr.label=aes-example
{
  "error_code": 0,
  "data": {
    "payload_key_reference": "0x00000000001c08f1",
    "wrapping_key_reference": "0x00000000001c08ea",
    "wrapped_key_data": "L1wVlL/YeBNVAw6Mpk3owFJZXBzDLONt"
  }
}
```

## 参数
<a name="cloudhsm_cli-key-wrap-aes-zero-pad-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<PAYLOAD\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择有效载荷密钥。  
是否必需：是

***<PATH>***  
保存包装密钥数据的二进制文件的路径。  
必需：否

***<WRAPPING\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择包装密钥。  
是否必需：是

***<WRAPPING\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准包装密钥的操作。仅当包装密钥的密钥管理服务仲裁值大于 1 时才需要。

***<PAYLOAD\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准有效载荷密钥的操作。仅当有效载荷密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-wrap-aes-zero-pad-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# CLOUDHSM-AES-GCM使用 CloudHSM CLI 封装密钥
<a name="cloudhsm_cli-key-wrap-cloudhsm-aes-gcm"></a>

使用 CloudHSM CLI 中的 **key wrap cloudhsm-aes-gcm** 命令通过硬件安全模块（HSM）上的 AES 密钥和 `CLOUDHSM-AES-GCM` 包装机制包装有效载荷密钥。有效载荷密钥的 `extractable` 属性必须设置为 `true`。

只有密钥的所有者（即创建密钥的加密用户（CU））才能包装密钥。共享密钥的用户可以使用该密钥进行加密操作。

要使用该**key wrap cloudhsm-aes-gcm**命令，您必须先在 AWS CloudHSM 集群中拥有 AES 密钥。您可以使用 [使用 CloudHSM CLI 生成对称 AES 密钥](cloudhsm_cli-key-generate-symmetric-aes.md) 命令并将 `wrap` 属性设置为 `true` 来生成用于包装的 AES 密钥。

## 用户类型
<a name="cloudhsm_cli-key-wrap-cloudhsm-aes-gcm-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-wrap-cloudhsm-aes-gcm-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-wrap-cloudhsm-aes-gcm-syntax"></a>

```
aws-cloudhsm > help key wrap cloudhsm-aes-gcm
Usage: key wrap cloudhsm-aes-gcm [OPTIONS] --payload-filter [<PAYLOAD_FILTER>...] --wrapping-filter [<WRAPPING_FILTER>...] --tag-length-bits <TAG_LENGTH_BITS>

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
      --payload-filter [<PAYLOAD_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 payload key
      --wrapping-filter [<WRAPPING_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 wrapping key
      --path <PATH>
          Path to the binary file where the wrapped key data will be saved
      --wrapping-approval <WRAPPING_APPROVALR>
          File path of signed quorum token file to approve operation for wrapping key
      --payload-approval <PAYLOAD_APPROVALR>
          File path of signed quorum token file to approve operation for payload key
      --aad <AAD>
          Aes GCM Additional Authenticated Data (AAD) value, in hex
      --tag-length-bits <TAG_LENGTH_BITS>
          Aes GCM tag length in bits
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-wrap-cloudhsm-aes-gcm-examples"></a>

此示例演示如何通过 AES 密钥使用 **key wrap cloudhsm-aes-gcm** 命令。

**Example**  

```
aws-cloudhsm > key wrap cloudhsm-aes-gcm --payload-filter attr.label=payload-key --wrapping-filter attr.label=aes-example --tag-length-bits 64 --aad 0x10
{
  "error_code": 0,
  "data": {
    "payload_key_reference": "0x00000000001c08f1",
    "wrapping_key_reference": "0x00000000001c08ea",
    "wrapped_key_data": "6Rn8nkjEriDYlnP3P8nPkYQ8hplOEJ899zsrF+aTB0i/fIlZ"
  }
}
```

## 参数
<a name="cloudhsm_cli-key-wrap-cloudhsm-aes-gcm-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<PAYLOAD\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择有效载荷密钥。  
是否必需：是

***<PATH>***  
保存包装密钥数据的二进制文件的路径。  
必需：否

***<WRAPPING\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择包装密钥。  
是否必需：是

***<AAD>***  
AES GCM 额外验证数据（AAD）值（十六进制）。  
必需：否

***<TAG\$1LENGTH\$1BITS>***  
AES GCM 标签长度（以位为单位）。  
是否必需：是

***<WRAPPING\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准包装密钥的操作。仅当包装密钥的密钥管理服务仲裁值大于 1 时才需要。

***<PAYLOAD\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准有效载荷密钥的操作。仅当有效载荷密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-wrap-cloudhsm-aes-gcm-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# 使用 CloudHSM CLI 通过 RSA-AES 解包密钥
<a name="cloudhsm_cli-key-wrap-rsa-aes"></a>

使用 CloudHSM CLI 中的 **key wrap rsa-aes** 命令通过硬件安全模块（HSM）上的 RSA 公有密钥和 RSA-AES 包装机制包装有效载荷密钥。有效载荷密钥的 `extractable` 属性必须设置为 `true`。

只有密钥的所有者（即创建密钥的加密用户（CU））才能包装密钥。共享密钥的用户可以使用该密钥进行加密操作。

要使用该**key wrap rsa-aes**命令，您必须先在 AWS CloudHSM 集群中拥有 RSA 密钥。可以使用 [CloudHSM CLI 中的 generate-asymmetric-pair类别](cloudhsm_cli-key-generate-asymmetric-pair.md) 命令并将 `wrap` 属性设置为 `true` 生成 RSA 密钥对。

## 用户类型
<a name="cloudhsm_cli-key-wrap-rsa-aes-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-wrap-rsa-aes-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-wrap-rsa-aes-syntax"></a>

```
aws-cloudhsm > help key wrap rsa-aes
Usage: key wrap rsa-aes [OPTIONS] --payload-filter [<PAYLOAD_FILTER>...] --wrapping-filter [<WRAPPING_FILTER>...] --hash-function <HASH_FUNCTION> --mgf <MGF>

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
      --payload-filter [<PAYLOAD_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 payload key
      --wrapping-filter [<WRAPPING_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 wrapping key
      --path <PATH>
          Path to the binary file where the wrapped key data will be saved
      --wrapping-approval <WRAPPING_APPROVALR>
          File path of signed quorum token file to approve operation for wrapping key
      --payload-approval <PAYLOAD_APPROVALR>
          File path of signed quorum token file to approve operation for payload key
      --hash-function <HASH_FUNCTION>
          Hash algorithm [possible values: sha1, sha224, sha256, sha384, sha512]
      --mgf <MGF>
          Mask Generation Function algorithm [possible values: mgf1-sha1, mgf1-sha224, mgf1-sha256, mgf1-sha384, mgf1-sha512]
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-wrap-rsa-aes-examples"></a>

此示例展示了如何通过 RSA 公有密钥使用 **key wrap rsa-ae** 命令并将 `wrap` 属性值设置为 `true`。

**Example**  

```
aws-cloudhsm > key wrap rsa-aes --payload-filter attr.label=payload-key --wrapping-filter attr.label=rsa-public-key-example --hash-function sha256 --mgf mgf1-sha256
{
  "error_code": 0,
  "data": {
    "payload-key-reference": "0x00000000001c08f1",
    "wrapping-key-reference": "0x00000000007008da",
    "wrapped-key-data": "HrSE1DEyLjIeyGdPa9R+ebiqB5TIJGyamPker31ZebPwRA+NcerbAJO8DJ1lXPygZcI21vIFSZJuWMEiWpe1R9D/5WSYgxLVKex30xCFqebtEzxbKuv4DOmU4meSofqREYvtb3EoIKwjyxCMRQFgoyUCuP4y0f0eSv0k6rSJh4NuCsHptXZbtgNeRcR4botN7LlzkEIUcq4fVHaatCwd0J1QGKHKyRhkol+RL5WGXKe4nAboAkC5GO7veI5yHL1SaKlssSJtTL/CFpbSLsAFuYbv/NUCWwMY5mwyVTCSlw+HlgKK+5TH1MzBaSi8fpfyepLT8sHy2Q/VRl6ifb49p6m0KQFbRVvz/OWUd6l4d97BdgtaEz6ueg=="
  }
}
```

## 参数
<a name="cloudhsm_cli-key-wrap-rsa-aes-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<PAYLOAD\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择有效载荷密钥。  
是否必需：是

***<PATH>***  
保存包装密钥数据的二进制文件的路径。  
必需：否

***<WRAPPING\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择包装密钥。  
是否必需：是

***<MGF>***  
指定掩码生成函数。  
掩码生成函数哈希函数必须与签名机制哈希函数相匹配。
有效值  
+ mgf1-sha1
+ mgf1-sha224
+ mgf1-sha256
+ mgf1-sha384
+ mgf1-sha512
是否必需：是

***<WRAPPING\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准包装密钥的操作。仅当包装密钥的密钥管理服务仲裁值大于 1 时才需要。

***<PAYLOAD\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准有效载荷密钥的操作。仅当有效载荷密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-wrap-rsa-aes-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# 使用 CloudHSM CLI 通过 RSA-OAEP 解包密钥
<a name="cloudhsm_cli-key-wrap-rsa-oaep"></a>

使用 CloudHSM CLI 中的 **key wrap rsa-oaep** 命令通过硬件安全模块（HSM）上的 RSA 公有密钥和 `RSA-OAEP` 包装机制包装有效载荷密钥。有效载荷密钥的 `extractable` 属性必须设置为 `true`。

只有密钥的所有者（即创建密钥的加密用户（CU））才能包装密钥。共享密钥的用户可以使用该密钥进行加密操作。

要使用该**key wrap rsa-oaep**命令，您必须先在 AWS CloudHSM 集群中拥有 RSA 密钥。可以使用 [CloudHSM CLI 中的 generate-asymmetric-pair类别](cloudhsm_cli-key-generate-asymmetric-pair.md) 命令并将 `wrap` 属性设置为 `true` 生成 RSA 密钥对。

## 用户类型
<a name="cloudhsm_cli-key-unwrap-rsa-aes-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-unwrap-rsa-aes-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-unwrap-rsa-aes-syntax"></a>

```
aws-cloudhsm > help key wrap rsa-oaep
Usage: key wrap rsa-oaep [OPTIONS] --payload-filter [<PAYLOAD_FILTER>...] --wrapping-filter [<WRAPPING_FILTER>...] --hash-function <HASH_FUNCTION> --mgf <MGF>

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
      --payload-filter [<PAYLOAD_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 payload key
      --wrapping-filter [<WRAPPING_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 wrapping key
      --path <PATH>
          Path to the binary file where the wrapped key data will be saved
      --wrapping-approval <WRAPPING_APPROVALR>
          File path of signed quorum token file to approve operation for wrapping key
      --payload-approval <PAYLOAD_APPROVALR>
          File path of signed quorum token file to approve operation for payload key
      --hash-function <HASH_FUNCTION>
          Hash algorithm [possible values: sha1, sha224, sha256, sha384, sha512]
      --mgf <MGF>
          Mask Generation Function algorithm [possible values: mgf1-sha1, mgf1-sha224, mgf1-sha256, mgf1-sha384, mgf1-sha512]
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-unwrap-rsa-aes-examples"></a>

此示例展示了如何通过 RSA 公有密钥使用 **key wrap rsa-oaep** 命令并将 `wrap` 属性值设置为 `true`。

**Example**  

```
aws-cloudhsm > key wrap rsa-oaep --payload-filter attr.label=payload-key --wrapping-filter attr.label=rsa-public-key-example --hash-function sha256 --mgf mgf1-sha256
{
  "error_code": 0,
  "data": {
    "payload-key-reference": "0x00000000001c08f1",
    "wrapping-key-reference": "0x00000000007008da",
    "wrapped-key-data": "OjJe4msobPLz9TuSAdULEu17T5rMDWtSlLyBSkLbaZnYzzpdrhsbGLbwZJCtB/jGkDNdB4qyTAOQwEpggGf6v+Yx6JcesNeKKNU8XZal/YBoHC8noTGUSDI2qr+u2tDc84NPv6d+F2KOONXsSxMhmxzzNG/gzTVIJhOuy/B1yHjGP4mOXoDZf5+7f5M1CjxBmz4Vva/wrWHGCSG0yOaWblEvOiHAIt3UBdyKmU+/My4xjfJv7WGGu3DFUUIZ06TihRtKQhUYU1M9u6NPf9riJJfHsk6QCuSZ9yWThDT9as6i7e3htnyDhIhGWaoK8JU855cN/YNKAUqkNpC4FPL3iw=="
  }
}
```

## 参数
<a name="cloudhsm_cli-key-unwrap-rsa-aes-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<PAYLOAD\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择有效载荷密钥。  
是否必需：是

***<PATH>***  
保存包装密钥数据的二进制文件的路径。  
必需：否

***<WRAPPING\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择包装密钥。  
是否必需：是

***<MGF>***  
指定掩码生成函数。  
掩码生成函数哈希函数必须与签名机制哈希函数相匹配。
有效值  
+ mgf1-sha1
+ mgf1-sha224
+ mgf1-sha256
+ mgf1-sha384
+ mgf1-sha512
是否必需：是

***<WRAPPING\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准包装密钥的操作。仅当包装密钥的密钥管理服务仲裁值大于 1 时才需要。

***<PAYLOAD\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准有效载荷密钥的操作。仅当有效载荷密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-unwrap-rsa-aes-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# 使用 CloudHSM CLI 通过 RSA-PKCS 解包密钥
<a name="cloudhsm_cli-key-wrap-rsa-pkcs"></a>

使用 CloudHSM CLI 中的 **key wrap rsa-pkcs** 命令通过硬件安全模块（HSM）上的 RSA 公有密钥和 `RSA-PKCS` 包装机制包装有效载荷密钥。有效载荷密钥的 `extractable` 属性必须设置为 `true`。

只有密钥的所有者（即创建密钥的加密用户（CU））才能包装密钥。共享密钥的用户可以使用该密钥进行加密操作。

要使用该**key wrap rsa-pkcs**命令，您必须先在 AWS CloudHSM 集群中拥有 RSA 密钥。可以使用 [CloudHSM CLI 中的 generate-asymmetric-pair类别](cloudhsm_cli-key-generate-asymmetric-pair.md) 命令并将 `wrap` 属性设置为 `true` 生成 RSA 密钥对。

## 用户类型
<a name="cloudhsm_cli-key-wrap-rsa-pkcs-userType"></a>

以下类型的用户均可运行此命令。
+ 加密用户 (CUs)

## 要求
<a name="cloudhsm_cli-key-wrap-rsa-pkcs-requirements"></a>
+ 要运行此命令，必须以 CU 身份登录。

## 语法
<a name="cloudhsm_cli-key-wrap-rsa-pkcs-syntax"></a>

```
aws-cloudhsm > help key wrap rsa-pkcs
Usage: key wrap rsa-pkcs [OPTIONS] --payload-filter [<PAYLOAD_FILTER>...] --wrapping-filter [<WRAPPING_FILTER>...]

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
      --payload-filter [<PAYLOAD_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 payload key
      --wrapping-filter [<WRAPPING_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 wrapping key
      --path <PATH>
          Path to the binary file where the wrapped key data will be saved
      --wrapping-approval <WRAPPING_APPROVALR>
          File path of signed quorum token file to approve operation for wrapping key
      --payload-approval <PAYLOAD_APPROVALR>
          File path of signed quorum token file to approve operation for payload key
  -h, --help
          Print help
```

## 示例
<a name="cloudhsm_cli-key-wrap-rsa-pkcs-examples"></a>

此示例演示如何通过 RSA 公有密钥使用 **key wrap rsa-pkcs** 命令。

**Example**  

```
aws-cloudhsm > key wrap rsa-pkcs --payload-filter attr.label=payload-key --wrapping-filter attr.label=rsa-public-key-example
{
  "error_code": 0,
  "data": {
    "payload_key_reference": "0x00000000001c08f1",
    "wrapping_key_reference": "0x00000000007008da",
    "wrapped_key_data": "am0Nc7+YE8FWs+5HvU7sIBcXVb24QA0l65nbNAD+1bK+e18BpSfnaI3P+r8Dp+pLu1ofoUy/vtzRjZoCiDofcz4EqCFnGl4GdcJ1/3W/5WRvMatCa2d7cx02swaeZcjKsermPXYRO1lGlfq6NskwMeeTkV8R7Rx9artFrs1y0DdIgIKVaiFHwnBIUMnlQrR2zRmMkfwU1jxMYmOYyD031F5VbnjSrhfMwkww2la7uf/c3XdFJ2+0Bo94c6og/yfPcpOOobJlITCoXhtMRepSdO4OggYq/6nUDuHCtJ86pPGnNahyr7+sAaSI3a5ECQLUjwaIARUCyoRh7EFK3qPXcg=="
  }
```

## 参数
<a name="cloudhsm_cli-key-wrap-rsa-pkcs-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<PAYLOAD\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择有效载荷密钥。  
是否必需：是

***<PATH>***  
保存包装密钥数据的二进制文件的路径。  
必需：否

***<WRAPPING\$1FILTER>***  
密钥引用（例如 `key-reference=0xabc`）或空格分隔的密钥属性列表，采用 `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` 形式，可选择包装密钥。  
是否必需：是

***<WRAPPING\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准包装密钥的操作。仅当包装密钥的密钥管理服务仲裁值大于 1 时才需要。

***<PAYLOAD\$1APPROVALR>***  
指定已签名仲裁令牌文件的文件路径，进而批准有效载荷密钥的操作。仅当有效载荷密钥的密钥管理服务仲裁值大于 1 时才需要。

## 相关主题
<a name="cloudhsm_cli-key-wrap-rsa-pkcs-seealso"></a>
+ [CloudHSM CLI 中的 key wrap 命令](cloudhsm_cli-key-wrap.md)
+ [CloudHSM CLI 中的 key unwrap 命令](cloudhsm_cli-key-unwrap.md)

# 使用 CloudHSM CLI 登录 HSM
<a name="cloudhsm_cli-login"></a>

您可以使用 CloudHSM CLI 中的**login**命令登录和注销集群中的每种硬件安全 (HSM)。 AWS CloudHSM 此命令具有以下子命令：
+ [mfa-token-sign](cloudhsm_cli-login-mfa-token-sign.md)

**注意**  
如果错误登录尝试满五次，则将锁定账户。要解锁账户，管理员必须使用 cloudhsm\$1cli 中的 [user change-password](cloudhsm_cli-user-change-password.md) 命令重置您的密码。

## 对登录和注销进行故障排除
<a name="troubleshoot-login-logout"></a>

如果您的集群中有多个 HSM，在锁定账户前，可能会允许您尝试更多次错误登录。这是因为 CloudHSM 客户端会平衡各种负载。 HSMs因此，您的登录尝试可能不是每次都在相同的 HSM 上开始的。如果您要测试此功能，我们建议您在仅具有一个活动 HSM 的集群上测试。

如果您的集群是在 2018 年 2 月前创建的，则在错误登录尝试满 20 次后锁定账户。

## 用户类型
<a name="chsm-cli-login-logout-userType"></a>

以下用户均可运行这些命令。
+ 未激活的管理员
+ Admin
+ 加密用户 (CU)

## 语法
<a name="chsm-cli-login-syntax"></a>

```
aws-cloudhsm > help login
Login to your cluster  
        
USAGE:
    cloudhsm-cli login [OPTIONS] --username <USERNAME> --role <ROLE> [COMMAND]
    
Commands:
  mfa-token-sign  Login with token-sign mfa
  help            Print this message or the help of the given subcommand(s)

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

        --username <USERNAME>
            Username to access the Cluster
        
        --role <ROLE>
            Role the user has in the Cluster
            
           Possible values:
           - crypto-user: A CryptoUser has the ability to manage and use keys
           - admin:       An Admin has the ability to manage user accounts

        --password <PASSWORD>
           Optional: Plaintext user's password. If you do not include this argument you will be prompted for it

  -h, --help
          Print help (see a summary with '-h')
```

## 示例
<a name="chsm-cli-login-example"></a>

**Example**  
此命令使用名为的管理员用户的凭据登录到集群 HSMs 中的所有人`admin1`。  

```
aws-cloudhsm > login --username admin1 --role admin
Enter password:
{
  "error_code": 0,
  "data": {
    "username": "admin1",
    "role": "admin"
  }
}
```

## 参数
<a name="login-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<USERNAME>***  
为用户指定友好名称。最大长度为 31 个字符。唯一允许的特殊字符是下划线 ( \$1 )。此命令中的用户名不区分大小写，用户名始终以小写形式显示。  
是否必需：是

***<ROLE>***  
指定分配给该用户的角色。有效值为 **admin**、**crypto-user**。  
要获取用户的角色，请使用**user list**命令。有关 HSM 上的用户类型的详细信息，请参阅[了解 HSM 用户](manage-hsm-users.md)。  
是否必需：是

***<PASSWORD>***  
指定正在登录的用户的密码 HSMs。  
必需：客户必须通过`--password`命令行参数提供密码，或者将其省略以交互方式提示。  
在命令行上使用`--password`参数可能会暴露你的 shell 历史记录中的凭据。可以考虑以交互方式提示输入密码，或者在使用后清除 shell 历史记录。

## 相关主题
<a name="login-seeAlso"></a>
+ [CloudHSM CLI 入门](cloudhsm_cli-getting-started.md)
+ [激活集群](activate-cluster.md)

# 使用 CloudHSM CLI 通过 MFA 登录到 HSM
<a name="cloudhsm_cli-login-mfa-token-sign"></a>

使用 C AWS CloudHSM loudHSM CLI 中的**login mfa-token-sign**命令使用多重身份验证 (MFA) 登录硬件安全模块 (HSM)。要使用此命令，您必须先为 [CloudHSM CLI 设置 MFA](login-mfa-token-sign.md)。

## 用户类型
<a name="cloudhsm_cli-login-mfa-token-userType"></a>

以下用户均可运行这些命令。
+ Admin
+ 加密用户 (CU)

## 语法
<a name="cloudhsm_cli-login-mfa-token-syntax"></a>

```
aws-cloudhsm > help login mfa-token-sign
Login with token-sign mfa

USAGE:
    login --username <username> --role <role> mfa-token-sign --token <token>

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
      --token <TOKEN>            Filepath where the unsigned token file will be written
  -h, --help                     Print help
```

## 示例
<a name="cloudhsm_cli-login-mfa-token-example"></a>

**Example**  

```
aws-cloudhsm > login --username test_user --role admin mfa-token-sign --token /home/valid.token
Enter password:
Enter signed token file path (press enter if same as the unsigned token file):
{
  "error_code": 0,
  "data": {
    "username": "test_user",
    "role": "admin"
  }
}
```

## 参数
<a name="cloudhsm_cli-login-mfa-token-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<TOKEN>***  
将写入未签名令牌文件的文件路径。  
是否必需：是

## 相关主题
<a name="cloudhsm_cli-login-mfa-token-seeAlso"></a>
+ [CloudHSM CLI 入门](cloudhsm_cli-getting-started.md)
+ [激活集群](activate-cluster.md)
+ [使用 CloudHSM CLI 管理 MFA](login-mfa-token-sign.md)

# 使用 CloudHSM CLI 退出 HSM
<a name="cloudhsm_cli-logout"></a>

使用 CloudHSM CLI 中的**logout**命令注销集群中的每个硬件安全模块 (HSM)。 AWS CloudHSM 

## 用户类型
<a name="chsm-cli-logout-userType"></a>

以下用户均可运行此命令。
+ Admin
+ 加密用户 (CU)

## 语法
<a name="chsm-cli-logout-syntax"></a>

```
aws-cloudhsm > help logout
Logout of your cluster

USAGE:
    logout

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
    -h, --help                    Print help information
    -V, --version                 Print version information
```

## 示例
<a name="chsm-cli-logout-example"></a>

**Example**  
此命令将您从集群中的所有 HSMs 内容中注销。  

```
aws-cloudhsm > logout
{
  "error_code": 0,
  "data": "Logout successful"
}
```

## 相关主题
<a name="logout-seeAlso"></a>
+ [CloudHSM CLI 入门](cloudhsm_cli-getting-started.md)
+ [激活集群](activate-cluster.md)

# CloudHSM CLI 中的 user 类别
<a name="cloudhsm_cli-user"></a>

在 CloudHSM CLI 中，**user** 是一组命令的父类别，当这些命令与父类别结合使用时，会创建特定于用户的命令。当前，用户类别由以下命令组成：
+ [user change-mfa](cloudhsm_cli-user-change-mfa.md)
+ [user change-password](cloudhsm_cli-user-change-password.md)
+ [user create](cloudhsm_cli-user-create.md)
+ [user delete](cloudhsm_cli-user-delete.md)
+ [user list](cloudhsm_cli-user-list.md)
+ [用户复制](cloudhsm_cli-user-replicate.md)

# CloudHSM CLI 中的 user change-mfa 类别
<a name="cloudhsm_cli-user-change-mfa"></a>

在 CloudHSM CLI 中，**user change-mfa** 是一组命令的父类别，当这些命令与父类别结合使用时，会创建专门用户更改用户的多重身份验证（MFA）的命令。

目前，此类别由以下子命令组成：
+ [token-sign](cloudhsm_cli-user-change-mfa-token-sign.md)

# 使用 CloudHSM CLI 更改用户的 MFA 设置
<a name="cloudhsm_cli-user-change-mfa-token-sign"></a>

使用 CloudHSM CLI 中的 **user change-mfa token-sign** 命令更新用户账户的多重身份验证（MFA）设置。任何用户账户均可运行此命令。担当管理员角色的账户可为其他用户运行此命令。

## 用户类型
<a name="user-change-mfa-type"></a>

以下用户均可运行此命令。
+ Admin
+ 加密用户

## 语法
<a name="user-change-mfa-syntax"></a>

目前，只有一种多重策略可供用户使用：令牌签名。

```
aws-cloudhsm > help user change-mfa
Change a user's Mfa Strategy

Usage:
    user change-mfa <COMMAND>
  
Commands:
  token-sign  Register or Deregister a public key using token-sign mfa strategy
  help        Print this message or the help of the given subcommand(s)
```

令牌签名策略要求提供一个用于写入未签名令牌的令牌文件。

```
aws-cloudhsm > help user change-mfa token-sign
Register or Deregister a public key using token-sign mfa strategy

Usage: user change-mfa token-sign [OPTIONS] --username <USERNAME> --role <ROLE> <--token <TOKEN>|--deregister>

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

      --username <USERNAME>
          Username of the user that will be modified

      --role <ROLE>
          Role the user has in the cluster

          Possible values:
          - crypto-user: A CryptoUser has the ability to manage and use keys
          - admin:       An Admin has the ability to manage user accounts

      --change-password <CHANGE_PASSWORD>
          Optional: Plaintext user's password. If you do not include this argument you will be prompted for it

      --token <TOKEN>
          Filepath where the unsigned token file will be written. Required for enabling MFA for a user

      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation

      --deregister
          Deregister the MFA public key, if present

      --change-quorum
          Change the Quorum public key along with the MFA key

  -h, --help
          Print help (see a summary with '-h')
```

## 示例
<a name="user-change-mfa-examples"></a>

此命令将集群中的每个 HSM 的一个未签名令牌写入 `token` 指定的文件中。出现系统提示时，对文件中的令牌签名。

**Example ：将集群中的每个 HSM 中的一个未签名令牌写入**  

```
aws-cloudhsm > user change-mfa token-sign --username cu1 --change-password password --role crypto-user --token /path/myfile
Enter signed token file path (press enter if same as the unsigned token file):
Enter public key PEM file path:/path/mypemfile
{
  "error_code": 0,
  "data": {
    "username": "test_user",
    "role": "admin"
  }
}
```

### 参数
<a name="user-change-mfa-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<ROLE>***  
指定赋予用户账户的角色。此参数为必需参数。有关 HSM 上的用户类型的详细信息，请参阅[了解 HSM 用户](manage-hsm-users.md)。  
**有效值**  
+ **管理员**：管理员可以管理用户，却无法管理密钥。
+ **加密用户**：加密用户可以创建管理密钥并在加密操作中使用密钥。

***<USERNAME>***  
为用户指定友好名称。最大长度为 31 个字符。唯一允许的特殊字符是下划线 ( \$1 )。  
用户名在创建之后无法更改。在 CloudHSM CLI 命令中，角色和密码区分大小写，但用户名不区分大小写。  
**是否必需**：是

***<CHANGE\$1PASSWORD>***  
指定要注册/注销 MFA 的用户的纯文本新密码。  
**是否必需**：是

***<TOKEN>***  
将写入未签名令牌文件的文件路径。  
**是否必需**：是

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当仲裁用户服务仲裁值大于 1 时才需要。

***<DEREGISTER>***  
注销 MFA 公有密钥（如有）。

***<CHANGE-QUORUM>***  
更改仲裁公有密钥和 MFA 密钥。

## 相关主题
<a name="user-change-mfa-seealso"></a>
+ [了解 HSM 用户的 2FA](login-mfa-token-sign.md)

# 使用 CloudHSM CLI 更改用户的密码
<a name="cloudhsm_cli-user-change-password"></a>

使用 CloudHSM CLI 中的**user change-password**命令更改集群中现有用户的 AWS CloudHSM 密码。要对用户启用 MFA，请使用 `user change-mfa` 命令。

所有用户都可更改自己的密码。此外，具有管理员角色的用户可以更改集群中其他用户的密码。您无需输入当前密码即可进行此更改。

**注意**  
您无法更改当前已登录集群的用户的密码。

## 用户类型
<a name="change-password-user-type"></a>

以下用户均可运行此命令。
+ Admin
+ 加密用户 (CU)

## 语法
<a name="change-password-syntax"></a>

**注意**  
 要对用户启用多重身份验证（MFA），请使用 **user change-mfa** 命令。

```
aws-cloudhsm > help user change-password
Change a user's password

    Usage:
        cloudhsm-cli user change-password [OPTIONS] --username <USERNAME> --role <ROLE> [--password <PASSWORD>]
    
    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

      --username <USERNAME>
          Username of the user that will be modified

      --role <ROLE>
          Role the user has in the cluster

          Possible values:
          - crypto-user: A CryptoUser has the ability to manage and use keys
          - admin:       An Admin has the ability to manage user accounts

      --password <PASSWORD>
          Optional: Plaintext user's password. If you do not include this argument you will be prompted for it

      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation
          
      --deregister-mfa <DEREGISTER-MFA>
          Deregister the user's mfa public key, if present
          
      --deregister-quorum <DEREGISTER-QUORUM>
          Deregister the user's quorum public key, if present
 -h, --help
          Print help (see a summary with '-h')
```

## 示例
<a name="change-password-examples"></a>

以下示例说明如何使用 **user change-password** 重置当前用户或集群中的任何其他用户的密码。

**Example ：更改您的密码**  
集群中的任何用户都可使用 **user change-password** 更改自己的密码。  
以下输出显示 Bob 目前已以加密用户 (CU) 身份登录。  

```
aws-cloudhsm > user change-password --username bob --role crypto-user
Enter password:
Confirm password:
{
  "error_code": 0,
  "data": {
    "username": "bob",
    "role": "crypto-user"
  }
}
```

## 参数
<a name="change-password-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当仲裁用户服务仲裁值大于 1 时才需要。

***<DEREGISTER-MFA>***  
注销 MFA 公有密钥（如有）。

***<DEREGISTER-QUORUM>***  
注销仲裁公有密钥（如有）。

***<PASSWORD>***  
指定用户的纯文本新密码。不允许以下字符：  
**是否必需**：是

***<ROLE>***  
指定赋予用户账户的角色。此参数为必需参数。有关 HSM 上的用户类型的详细信息，请参阅[了解 HSM 用户](manage-hsm-users.md)。  
**有效值**  
+ **管理员**：管理员可以管理用户，却无法管理密钥。
+ **加密用户**：加密用户可以创建管理密钥并在加密操作中使用密钥。

***<USERNAME>***  
为用户指定友好名称。最大长度为 31 个字符。唯一允许的特殊字符是下划线 ( \$1 )。  
用户名在创建之后无法更改。在 CloudHSM CLI 命令中，角色和密码区分大小写，但用户名不区分大小写。  
**是否必需**：是

## 相关主题
<a name="change-password-seealso"></a>
+ [user list](cloudhsm_cli-user-list.md)
+ [user create](cloudhsm_cli-user-create.md)
+ [user delete](cloudhsm_cli-user-delete.md)

# CloudHSM CLI 中的 user change-quorum 类别
<a name="cloudhsm_cli-user-chqm"></a>

在 CloudHSM CLI 中，**user change-quorum** 是一组命令的父类别，当这些命令与父类别结合使用时，会创建专门用于更改用户仲裁的命令。

**user change-quorum** 用于使用指定的仲裁策略注册用户仲裁身份验证。从 SDK 5.8.0 版开始，只有一种仲裁策略可供用户使用，如下所示。

目前，此类别由以下类别和子命令组成：
+ [token-sign](cloudhsm_cli-user-chqm-token.md)
  + [register](cloudhsm_cli-user-chqm-token-reg.md)

# CloudHSM CLI 中的 user change-quorum token-sign 类别
<a name="cloudhsm_cli-user-chqm-token"></a>

在 CloudHSM CLI 中，**user change-quorum token-sign** 是某些命令的父类别，当这些命令与此父类别结合使用时，会创建特定于令牌签名仲裁操作的命令。

当前，此类别由以下命令组成：
+ [register](cloudhsm_cli-user-chqm-token-reg.md)

# 使用 CloudHSM CLI 注册用户的令牌签名仲裁策略
<a name="cloudhsm_cli-user-chqm-token-reg"></a>

使用 CloudHSM CLI 中的 **user change-quorum token-sign register** 命令为管理员用户注册令牌签名仲裁策略。

## 用户类型
<a name="token-register-user-type"></a>

以下用户均可运行此命令。
+ Admin

## 语法
<a name="token-register-syntax"></a>

```
aws-cloudhsm > help user change-quorum token-sign register
Register a user for quorum authentication with a public key

Usage: user change-quorum token-sign register --public-key <PUBLIC_KEY> --signed-token <SIGNED_TOKEN>

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
      --public-key <PUBLIC_KEY>      Filepath to public key PEM file
      --signed-token <SIGNED_TOKEN>  Filepath with token signed by user private key
  -h, --help Print help (see a summary with '-h')
```

## 示例
<a name="token-register-examples"></a>

**Example**  
要运行此命令，您需要以您想要 **register quorum token-sign** 的用户身份登录。  

```
aws-cloudhsm > login --username admin1 --role admin
Enter password:
{
  "error_code": 0,
  "data": {
    "username": "admin1",
    "role": "admin"
  }
}
```
该 **user change-quorum token-sign register** 命令将向 HSM 注册您的公有密钥。因此，它将使您有资格成为仲裁批准者，以执行需要用户获取仲裁签名才能满足必要的仲裁阈值的仲裁要求的操作。  

```
aws-cloudhsm > user change-quorum token-sign register \
    --public-key /home/mypemfile \
    --signed-token /home/mysignedtoken
{
  "error_code": 0,
  "data": {
    "username": "admin1",
    "role": "admin"
  }
}
```
现在，您可以运行 **user list** 命令并确认已为此用户注册了仲裁令牌签名。  

```
aws-cloudhsm > user list
{
  "error_code": 0,
  "data": {
    "users": [
      {
        "username": "admin",
        "role": "admin",
        "locked": "false",
        "mfa": [],
        "quorum": [],
        "cluster-coverage": "full"
      },
      {
        "username": "admin1",
        "role": "admin",
        "locked": "false",
        "mfa": [],
        "quorum": [
          {        
            "strategy": "token-sign",
            "status": "enabled"
          }
        ],
        "cluster-coverage": "full"
      }
    ]
  }
}
```

## 参数
<a name="token-register-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<PUBLIC-KEY>***  
公有密钥 PEM 文件的文件路径。  
**是否必需**：是

***<SIGNED-TOKEN>***  
带有由用户私有密钥签名的令牌的文件路径。  
**是否必需**：是

## 相关主题
<a name="token-register-seealso"></a>
+ [使用 CloudHSM CLI 管理仲裁身份验证](quorum-auth-chsm-cli.md)
+ [使用面向管理员的仲裁身份验证：首次设置](quorum-auth-chsm-cli-first-time.md)
+ [更改管理员的仲裁最小值](quorum-auth-chsm-cli-min-value.md)
+ [支持仲裁身份验证的服务名称和类型](quorum-auth-chsm-cli-service-names.md)

# 使用 CloudHSM CLI 创建 AWS CloudHSM 用户
<a name="cloudhsm_cli-user-create"></a>

CloudHSM CLI 中的**user create**命令会在您的集群中创建一个用户 AWS CloudHSM 。只有具有管理员角色的用户帐户才能运行此命令。

## 用户类型
<a name="user-create-userType"></a>

以下类型的用户均可运行此命令。
+ Admin

## 要求
<a name="user-create-requirements"></a>

若要运行此命令，您必须以管理员身份登录

## 语法
<a name="user-create-syntax"></a>

```
aws-cloudhsm > help user create
Create a new user

Usage: cloudhsm-cli user create [OPTIONS] --username <USERNAME> --role <ROLE> [--password <PASSWORD>]

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

      --username <USERNAME>
          Username to access the HSM cluster

      --role <ROLE>
          Role the user has in the cluster

          Possible values:
          - crypto-user: A CryptoUser has the ability to manage and use keys
          - admin:       An Admin has the ability to manage user accounts

      --password <PASSWORD>
          Optional: Plaintext user's password. If you do not include this argument you will be prompted for it

      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation

  -h, --help
          Print help (see a summary with '-h')
```

## 示例
<a name="user-create-examples"></a>

这些示例说明了**user create**如何使用在中创建新用户 HSMs。

**Example ：创建加密用户**  
此示例在您的 AWS CloudHSM 集群中创建了一个具有加密用户角色的账户。  

```
aws-cloudhsm > user create --username alice --role crypto-user
Enter password:
Confirm password:
{
  "error_code": 0,
  "data": {
    "username": "alice",
    "role": "crypto-user"
  }
}
```

## 参数
<a name="user-create-arguments"></a>

*<CLUSTER\$1ID>*  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

*<USERNAME>*  
为用户指定友好名称。最大长度为 31 个字符。唯一允许的特殊字符是下划线 ( \$1 )。此命令中的用户名不区分大小写，用户名始终以小写形式显示。  
是否必需：是

*<ROLE>*  
指定分配给该用户的角色。此参数为必需参数。有效值为 **admin**、**crypto-user**。  
要获取用户的角色，请使用 **user list** 命令。有关 HSM 上的用户类型的详细信息，请参阅[了解 HSM 用户](manage-hsm-users.md)。

*<PASSWORD>*  
指定正在登录的用户的密码 HSMs。不允许以下字符：  
是否必需：是

*<APPROVAL>*  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当仲裁用户服务仲裁值大于 1 时才需要。

## 相关主题
<a name="user-create-seealso"></a>
+ [user list](cloudhsm_cli-user-list.md)
+ [user delete](cloudhsm_cli-user-delete.md)
+ [user change-password](cloudhsm_cli-user-change-password.md)

# 使用 CloudHSM CLI 删除 AWS CloudHSM 用户
<a name="cloudhsm_cli-user-delete"></a>

CloudHSM CLI 中的**user delete**命令将用户 AWS CloudHSM 从您的集群中删除。只有担当管理员角色的用户账户可运行此命令。您无法删除当前登录到 HSM 的用户。

## 用户类型
<a name="user-delete-userType"></a>

以下类型的用户均可运行此命令。
+ Admin

## 要求
<a name="user-delete-requirements"></a>
+ 您无法删除拥有密钥的用户帐户。
+ 您的用户帐户必须具有管理员角色才能运行此命令。

## 语法
<a name="user-delete-syntax"></a>

由于此命令没有命名参数，因此您必须按语法图中指定的顺序输入参数。

```
aws-cloudhsm > help user delete
Delete a user

Usage: user delete [OPTIONS] --username <USERNAME> --role <ROLE>

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

      --username <USERNAME>
          Username to access the HSM cluster

      --role <ROLE>
          Role the user has in the cluster

          Possible values:
          - crypto-user: A CryptoUser has the ability to manage and use keys
          - admin:       An Admin has the ability to manage user accounts

      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation
```

## 示例
<a name="user-delete-examples"></a>

```
aws-cloudhsm > user delete --username alice --role crypto-user
{
  "error_code": 0,
  "data": {
    "username": "alice",
    "role": "crypto-user"
  }
}
```

## 参数
<a name="user-delete-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<USERNAME>***  
为用户指定友好名称。最大长度为 31 个字符。唯一允许的特殊字符是下划线 ( \$1 )。此命令中的用户名不区分大小写，用户名始终以小写形式显示。  
是否必需：是

***<ROLE>***  
指定分配给该用户的角色。此参数为必需参数。有效值为 **admin**、**crypto-user**。  
要获取用户的角色，请使用 **user list** 命令。有关 HSM 上的用户类型的详细信息，请参阅[了解 HSM 用户](manage-hsm-users.md)。  
是否必需：是

***<APPROVAL>***  
指定要批准操作的已签名仲裁令牌文件的文件路径。仅当仲裁用户服务仲裁值大于 1 时才需要。  
是否必需：是

## 相关主题
<a name="user-delete-seealso"></a>
+ [user list](cloudhsm_cli-user-list.md)
+ [user create](cloudhsm_cli-user-create.md)
+ [user change-password](cloudhsm_cli-user-change-password.md)

# 使用 CloudHSM CLI 列出所有 AWS CloudHSM 用户
<a name="cloudhsm_cli-user-list"></a>

CloudHSM CLI 中的**user list**命令列出了您的集群中存在 AWS CloudHSM 的用户帐户。您不必登录 CloudHSM CLI 即可运行此命令。

**注意**  
如果添加或删除 HSMs，请更新 AWS CloudHSM 客户端和命令行工具使用的配置文件。否则，您所做的更改可能不会对集群 HSMs 中的所有人生效。

## 用户类型
<a name="user-list-userType"></a>

以下类型的用户均可运行此命令。
+ 所有用户。您不必登录即可运行此命令。

## 语法
<a name="chsm-cli-user-list-syntax"></a>

```
aws-cloudhsm > help user list
List the users in your cluster

USAGE:
    user list

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
  -h, --help                     Print help
```

## 示例
<a name="chsm-cli-user-list-examples"></a>

此命令列出了您的 CloudHSM 集群中存在的用户。

```
aws-cloudhsm > user list
{
  "error_code": 0,
  "data": {
    "users": [
      {
        "username": "admin",
        "role": "admin",
        "locked": "false",
        "mfa": [],
        "cluster-coverage": "full"
      },
      {
        "username": "test_user",
        "role": "admin",
        "locked": "false",
        "mfa": [
          {
            "strategy": "token-sign",
            "status": "enabled"
          }
        ],
        "cluster-coverage": "full"
      },
      {
        "username": "app_user",
        "role": "internal(APPLIANCE_USER)",
        "locked": "false",
        "mfa": [],
        "cluster-coverage": "full"
      }
    ]
  }
}
```

输出包含以下用户属性：
+ **用户名**：显示用户的用户定义友好名称。用户名始终以小写形式显示。
+ **角色**：确定用户可在 HSM 上执行的操作。
+ **已锁定**：表示此用户帐户是否已被锁定。
+ **MFA**：表示此用户账户支持的多重身份验证机制。
+ **集群覆盖范围**：表示此用户帐户在集群范围内的可用性。

## 相关主题
<a name="chsm-user-list-seealso"></a>
+ key\$1mgmt\$1util 中的 [listUsers](key_mgmt_util-listUsers.md)
+ [user create](cloudhsm_cli-user-create.md)
+ [user delete](cloudhsm_cli-user-delete.md)
+ [user change-password](cloudhsm_cli-user-change-password.md)

# 使用 CloudHSM CLI 复制用户
<a name="cloudhsm_cli-user-replicate"></a>

使用 CloudHSM CLI 中的**user replicate**命令将用户从 AWS CloudHSM 源集群复制到目标集群。 AWS CloudHSM 

## 用户类型
<a name="chsm-cli-user-replicate-user-type"></a>

以下类型的用户均可运行此命令。
+ 管理员 () COs

## 要求
<a name="cloudhsm_cli-user-replicate-requirements"></a>
+ 源集群和目标集群必须是克隆。这意味着其中一个是从另一个的备份创建的，或者它们都是从公共备份创建的。请参阅[使用备份创建集群](create-cluster-from-backup.md)了解更多信息。
+ 要运行此命令，必须以管理员身份登录源集群和目标集群。
  +  在单命令模式下，该命令将使用 CLOUDHSM\$1PIN 和 CLOUDHSM\$1ROLE 环境变量在源集群上进行身份验证。请参阅[单命令模式](cloudhsm_cli-modes.md#cloudhsm_cli-mode-single-command)了解更多信息。要为目标集群提供凭证，您需要设置两个额外的环境变量：DESTINATION\$1CLOUDHSM\$1PIN 和 DESTINATION\$1CLOUDHSM\$1ROLE：

    ```
    $ export DESTINATION_CLOUDHSM_ROLE=<role>
    ```

    ```
    $ export DESTINATION_CLOUDHSM_PIN=<username:password>
    ```
  +  在交互模式下，用户需要明确登录源集群和目标集群。

## 语法
<a name="chsm-cli-user-replicate-syntax"></a>

```
aws-cloudhsm > help user replicate
Replicate a user from a source to a destination cluster

Usage: user replicate --username <USERNAME> --role <ROLE> --source-cluster-id <SOURCE_CLUSTER_ID> --destination-cluster-id <DESTINATION_CLUSTER_ID>

Options:
      --username <USERNAME>
          Username of the user to replicate

      --role <ROLE>
          Role the user has in the cluster

          Possible values:
          - crypto-user: A CryptoUser has the ability to manage and use keys
          - admin:       An Admin has the ability to manage user accounts

      --source-cluster-id <SOURCE_CLUSTER_ID>
          Source cluster ID

      --destination-cluster-id <DESTINATION_CLUSTER_ID>
          Destination cluster ID

  -h, --help
          Print help (see a summary with '-h')
```

## 示例
<a name="chsm-cli-user-replicate-examples"></a>

**Example 示例：复制用户**  
此命令将用户从源集群复制到克隆的目标集群。以下示例演示了在两个集群上以管理员身份登录时的输出。  

```
admin-user@cluster-1234abcdefg > user replicate \
      --username example-admin \
      --role admin \
      --source-cluster-id cluster-1234abcdefg \
      --destination-cluster-id cluster-2345bcdefgh
{
  "error_code": 0,
  "data": {
    "user": {
      "username": "example-admin",
      "role": "admin",
      "locked": "false",
      "mfa": [],
      "quorum": [],
      "cluster-coverage": "full"
    },
    "message": "Successfully replicated user"
  }
}
```

## 参数
<a name="user-replicate-arguments"></a>

***<USERNAME>***  
指定要在源集群中复制的用户的用户名。  
是否必需：是

***<ROLE>***  
指定分配给该用户的角色。此参数为必需参数。有效值为 **admin**、**crypto-user**。  
要获取用户的角色，请使用 **user list** 命令。有关 HSM 上的用户类型的详细信息，请参阅[了解 HSM 用户](manage-hsm-users.md)。  
是否必需：是

***<SOURCE\$1CLUSTER\$1ID>***  
源集群 ID。  
是否必需：是

***<DESTINATION\$1CLUSTER\$1ID>***  
目标集群 ID。  
是否必需：是

## 相关主题
<a name="chsm-user-replicate-seealso"></a>
+ [使用 CloudHSM CLI 连接到多个集群](cloudhsm_cli-configs-multi-cluster.md)

# CloudHSM CLI 中的 quorum 类别
<a name="cloudhsm_cli-qm"></a>

在 CloudHSM CLI 中，**quorum** 是一组命令的父类别，当这些命令与 **quorum** 结合使用时，会创建特定于仲裁身份验证或 M of N 操作的命令。目前，该类别由**token-sign**子类别组成，该子类别包含其自己的命令。有关详细信息，请单击以下链接。
+ [token-sign](cloudhsm_cli-qm-token.md)

**管理员服务**：仲裁身份验证用于管理员特权服务，例如创建用户、删除用户、更改用户密码、设置仲裁值以及停用仲裁和 MFA 功能。

**加密用户服务**：法定身份验证用于与特定密钥关联的加密用户特权服务，例如使用密钥、密钥、 sharing/unsharing 密钥进行签名以及设置密钥的属性。 wrapping/unwrapping 关联密钥的仲裁值是在生成、导入或解包密钥时配置的。仲裁值必须等于或小于与该密钥关联的用户数，其中包括与之共享密钥的用户和密钥所有者。

每个服务类型都进一步细分为限定服务名称，其中包含一组特定的、可执行的仲裁支持服务操作。


****  

| 服务名称 | 服务类型 | 服务操作 | 
| --- | --- | --- | 
| 用户 | Admin |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/cloudhsm/latest/userguide/cloudhsm_cli-qm.html)  | 
| 仲裁 | Admin |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/cloudhsm/latest/userguide/cloudhsm_cli-qm.html)  | 
| cluster1 | Admin |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/cloudhsm/latest/userguide/cloudhsm_cli-qm.html)  | 
| 密钥管理 | 加密用户 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/cloudhsm/latest/userguide/cloudhsm_cli-qm.html)  | 
| 密钥使用 | 加密用户 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/cloudhsm/latest/userguide/cloudhsm_cli-qm.html)  | 

[1] 集群服务仅在 hsm2m.medium 上可用

## 相关主题
<a name="cloudhsm_cli-qm-seealso"></a>
+ [AWS CloudHSM 使用 CloudHSM CLI 为管理员设置法定身份验证](quorum-auth-chsm-cli-first-time.md)
+ [使用 CloudHSM CLI 管理仲裁身份验证（M of N 访问控制）](quorum-auth-chsm-cli.md)

# CloudHSM CLI 中的 quorum token-sign 类别
<a name="cloudhsm_cli-qm-token"></a>

在 CloudHSM CLI 中，**quorum token-sign** 是一组命令的类别，当这些命令与 **quorum token-sign** 结合使用时，会创建特定于仲裁身份验证或 M of N 操作的命令。

目前，此类别由以下命令组成：
+ [删除](cloudhsm_cli-qm-token-del.md)
+ [生成](cloudhsm_cli-qm-token-gen.md)
+ [列表](cloudhsm_cli-qm-token-list.md)
+ [list-quorum-values](cloudhsm_cli-qm-token-list-qm.md)
+ [set-quorum-value](cloudhsm_cli-qm-token-set-qm.md)

# 使用 CloudHSM CLI 删除仲裁令牌
<a name="cloudhsm_cli-qm-token-del"></a>

使用 CloudHSM CLI 中的 **quorum token-sign delete** 命令删除仲裁授权服务的一个或多个令牌。

## 用户类型
<a name="quorum-token-delete-user-type"></a>

以下用户均可运行此命令。
+ Admin

## 语法
<a name="quorum-token-delete-syntax"></a>

```
aws-cloudhsm > help quorum token-sign delete 
Delete one or more Quorum Tokens

Usage: quorum token-sign delete --scope <SCOPE>

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

      --scope <SCOPE>
          Scope of which token(s) will be deleted

          Possible values:
          - user: Deletes all token(s) of currently logged in user
          - all:  Deletes all token(s) on the HSM
  -h, --help
          Print help (see a summary with '-h')
```

## 示例
<a name="quorum-token-delete-examples"></a>

下面的示例显示了如何使用 CloudHSM CLI 中的 **quorum token-sign delete** 命令删除仲裁授权服务的一个或多个令牌。

**Example ：删除仲裁授权服务的一个或多个令牌**  

```
aws-cloudhsm > quorum token-sign delete --scope all
{
  "error_code": 0,
  "data": "Deletion of quorum token(s) successful"
}
```

## 参数
<a name="quorum-token-delete-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<SCOPE>***  
 AWS CloudHSM 集群中将删除令牌的范围。  
**有效值**  
+ **用户**：仅用于删除已登录用户所拥有的令牌。
+ **全部**：用于删除 AWS CloudHSM 集群中的所有令牌。

## 相关主题
<a name="quorum-token-delete-seealso"></a>
+ [user list](cloudhsm_cli-user-list.md)
+ [user create](cloudhsm_cli-user-create.md)
+ [user delete](cloudhsm_cli-user-delete.md)

# 使用 CloudHSM CLI 生成仲裁令牌
<a name="cloudhsm_cli-qm-token-gen"></a>

使用 CloudHSM CLI 中的 **quorum token-sign generate** 命令为仲裁授权服务生成令牌。

对于服务用户和仲裁，在 HSM 集群中每个服务每位用户只能获得一个活动令牌。此限制不适用于与密钥服务相关的令牌。

**注意**  
只有管理员和加密用户才能生成特定的服务令牌。有关服务类型和名称的更多信息，请参阅[支持仲裁身份验证的服务名称和类型](quorum-auth-chsm-cli-service-names.md)。

**管理员服务**：仲裁身份验证用于管理员特权服务，例如创建用户、删除用户、更改用户密码、设置仲裁值以及停用仲裁和 MFA 功能。

**加密用户服务**：法定身份验证用于与特定密钥关联的加密用户特权服务，例如使用密钥、密钥、 sharing/unsharing 密钥进行签名以及设置密钥的属性。 wrapping/unwrapping 关联密钥的仲裁值是在生成、导入或解包密钥时配置的。仲裁值必须等于或小于与该密钥关联的用户数，其中包括与之共享密钥的用户和密钥所有者。

每个服务类型都进一步细分为限定服务名称，其中包含一组特定的、可执行的仲裁支持服务操作。


****  

| 服务名称 | 服务类型 | 服务操作 | 
| --- | --- | --- | 
| 用户 | Admin |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/cloudhsm/latest/userguide/cloudhsm_cli-qm-token-gen.html)  | 
| 仲裁 | Admin |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/cloudhsm/latest/userguide/cloudhsm_cli-qm-token-gen.html)  | 
| cluster1 | Admin |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/cloudhsm/latest/userguide/cloudhsm_cli-qm-token-gen.html)  | 
| 密钥管理 | 加密用户 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/cloudhsm/latest/userguide/cloudhsm_cli-qm-token-gen.html)  | 
| 密钥使用 | 加密用户 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/cloudhsm/latest/userguide/cloudhsm_cli-qm-token-gen.html)  | 

[1] 集群服务仅在 hsm2m.medium 上可用

## 用户类型
<a name="quorum-token-generate-user-type"></a>

以下用户均可运行此命令。
+ Admin
+ 加密用户 (CU)

## 语法
<a name="quorum-token-generate-syntax"></a>

```
aws-cloudhsm > help quorum token-sign generate
Generate a token

Usage: quorum token-sign generate --service <SERVICE> --token <TOKEN>

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

      --service <SERVICE>
          Service the token will be used for

          Possible values:
          - user:
            User management service is used for executing quorum authenticated user management operations
          - quorum:
            Quorum management service is used for setting quorum values for any quorum service
          - cluster: 
            Cluster management service is used for executing quorum for cluster wide configuration managements like mtls enforcement, mtls registration and mtls deregistration
          - registration:
            Registration service is used for registering a public key for quorum authentication
          - key-usage:
            Key usage service is used for executing quorum authenticated key usage operations
          - key-management:
            Key management service is used for executing quorum authenticated key management operations

      --token <TOKEN>
          Filepath where the unsigned token file will be written
  -h, --help                     Print help
```

## 示例
<a name="quorum-token-generate-examples"></a>

此命令将集群中的每个 HSM 的一个未签名令牌写入 `token` 指定的文件中。

**Example ：将集群中的每个 HSM 中的一个未签名令牌写入**  

```
aws-cloudhsm > quorum token-sign generate --service user --token /home/tfile
{
  "error_code": 0,
  "data": {
    "filepath": "/home/tfile"
  }
}
```

## 参数
<a name="quorum-token-generate-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<SERVICE>***  
指定要为其生成令牌的仲裁授权服务。此参数为必需参数。  
**有效值**  
+ **用户**：用于执行仲裁授权用户管理操作的用户管理服务。
+ **仲裁**：用于为任何仲裁授权服务设置仲裁授权仲裁值的仲裁管理服务。
+ **cluster**：用于执行集群范围配置管理（如 mtls 强制执行、mtls 注册和 mtls 取消注册）仲裁的集群管理服务。
+ **注册**：生成用于注册仲裁授权公有密钥的未签名令牌。
+ **key-usage**：生成用于执行仲裁授权密钥使用操作的未签名令牌。
+ **key-management**：生成用于执行仲裁授权密钥管理操作的未签名令牌。
**是否必需**：是

***<TOKEN>***  
将写入未签名令牌文件的文件路径。  
**是否必需**：是

## 相关主题
<a name="quorum-token-generate-seealso"></a>
+ [支持仲裁身份验证的服务名称和类型](quorum-auth-chsm-cli-service-names.md)

# 使用 CloudHSM CLI 列出仲裁令牌
<a name="cloudhsm_cli-qm-token-list"></a>

使用 CloudHSM CLI 中的**quorum token-sign list**命令列出集群中存在的所有令牌签名法定令牌。 AWS CloudHSM 这包括其他用户生成的令牌。令牌绑定到用户，因此，虽然您可能会看到来自其他用户的令牌，但只能使用与当前登录的用户关联的令牌。

有关服务类型和名称的更多信息，请参阅 [支持仲裁身份验证的服务名称和类型](quorum-auth-chsm-cli-service-names.md)。有关所列令牌中显示的内容的更多信息，请参阅 [使用 AWS CloudHSM CloudHSM CLI 时启用法定身份验证的密钥管理和使用](key-quorum-auth-chsm-cli-crypto-user.md) 了解与 `key-management` 和 `key-usage` 服务关联的令牌，参阅 [使用 AWS CloudHSM CloudHSM CLI 时启用了法定身份验证的用户管理](quorum-auth-chsm-cli-admin.md) 了解与 `user`、`quorum` 或 `cluster` 服务关联的令牌。

## 用户类型
<a name="quorum-token-list-user-type"></a>

以下用户均可运行此命令。
+ Admin
+ 加密用户 (CU)

## 语法
<a name="quorum-token-list-syntax"></a>

```
aws-cloudhsm > help quorum token-sign list
List the token-sign tokens in your cluster

Usage: quorum token-sign list

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
  -h, --help                     Print help
```

## 示例
<a name="quorum-token-list-examples"></a>

此命令将列出集群中存在的所有令牌签名令牌。 AWS CloudHSM 这包括其他用户生成的令牌。令牌绑定到用户，因此，虽然您可能会看到来自其他用户的令牌，但只能使用与当前登录的用户关联的令牌。

**Example**  

```
aws-cloudhsm > quorum token-sign list
{
  "error_code": 0,
  "data": {
    "tokens": [
      {
        "username": "admin",
        "service": "quorum",
        "approvals-required": 2,
        "number-of-approvals": 0,
        "token-timeout-seconds": 397,
        "cluster-coverage": "full"
      },
      {
        "username": "admin",
        "service": "user",
        "approvals-required": 2,
        "number-of-approvals": 0,
        "token-timeout-seconds": 588,
        "cluster-coverage": "full"
      },
      {
        "username": "crypto_user1",
        "service": "key-management",
        "key-reference": "0x00000000002c33f7",
        "minimum-token-count": 1
      },
      {
        "username": "crypto_user1",
        "service": "key-usage",
        "key-reference": "0x00000000002c33f7",
        "minimum-token-count": 1
      }
    ]
  }
}
```

## 相关主题
<a name="quorum-token-list-seealso"></a>
+ [quorum token-sign generate](cloudhsm_cli-qm-token-gen.md)

# 使用 CloudHSM CLI 显示仲裁值
<a name="cloudhsm_cli-qm-token-list-qm"></a>

使用 CloudHSM CLI 中的**quorum token-sign list-quorum-values**命令列出集群中设置的法定值。 AWS CloudHSM 

## 用户类型
<a name="quorum-token-list-qm-user-type"></a>

以下用户均可运行此命令。
+ 所有用户。您不必登录即可运行此命令。

## 语法
<a name="quorum-token-list-qm-syntax"></a>

```
aws-cloudhsm > help quorum token-sign list-quorum-values
List current quorum values

Usage: quorum token-sign list-quorum-values

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
  -h, --help                     Print help
```

## 示例
<a name="quorum-token-list-qm-examples"></a>

此命令列出 AWS CloudHSM 集群中为每项服务设置的法定值。

**Example**  
**hsm1.medium**：  

```
aws-cloudhsm > quorum token-sign list-quorum-values
{
  "error_code": 0,
  "data": {
    "user": 1,
    "quorum": 1
  }
}
```
**hsm2m.medium**：  

```
aws-cloudhsm > quorum token-sign list-quorum-values
{
  "error_code": 0,
  "data": {
    "user": 1,
    "quorum": 1,
    "cluster": 1
  }
}
```

## 相关主题
<a name="quorum-token-list-qm-seealso"></a>
+ [支持仲裁身份验证的服务名称和类型](quorum-auth-chsm-cli-service-names.md)
+  [设置 mTLS（推荐）](getting-started-setup-mtls.md) 

# 使用 CloudHSM CLI 更新仲裁值
<a name="cloudhsm_cli-qm-token-set-qm"></a>

使用 CloudHSM CLI 中的 **quorum token-sign set-quorum-value** 命令为仲裁授权服务设置新的仲裁值。

## 用户类型
<a name="quorum-token-set-qm-user-type"></a>

以下用户均可运行此命令。
+ Admin

## 语法
<a name="quorum-token-set-qm-syntax"></a>

```
aws-cloudhsm > help quorum token-sign set-quorum-value
Set a quorum value

Usage: quorum token-sign set-quorum-value [OPTIONS] --service <SERVICE> --value <VALUE>

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

      --service <SERVICE>
          Service the token will be used for

          Possible values:
          - user:
            User management service is used for executing quorum authenticated user management operations
          - quorum:
            Quorum management service is used for setting quorum values for any quorum service
          - cluster: 
            Cluster management service is used for executing quorum for cluster wide configuration managements like mtls enforcement, mtls registration and mtls deregistration

      --value <VALUE>
          Value to set for service

      --approval <APPROVAL>
          Filepath of signed quorum token file to approve operation

  -h, --help
          Print help (see a summary with '-h')
```

## 示例
<a name="quorum-token-set-qm-examples"></a>

**Example**  
在下面的示例中，此命令会将集群中每个 HSM 的一个未签名令牌写入令牌指定的文件中。出现系统提示时，对文件中的令牌签名。  

```
aws-cloudhsm > quorum token-sign set-quorum-value --service quorum --value 2
{
  "error_code": 0,
  "data": "Set Quorum Value successful"
}
```
然后，您可以运行 **list-quorum-values** 命令来确认是否已设置仲裁管理服务的仲裁值：  
**hsm1.medium**：  

```
aws-cloudhsm > quorum token-sign list-quorum-values
{
  "error_code": 0,
  "data": {
    "user": 1,
    "quorum": 2
  }
}
```
**hsm2m.medium**：  

```
aws-cloudhsm > quorum token-sign list-quorum-values
{
  "error_code": 0,
  "data": {
    "user": 1,
    "quorum": 2,
    "cluster": 1
  }
}
```

## 参数
<a name="quorum-token-set-qm-arguments"></a>

***<CLUSTER\$1ID>***  
要运行此操作的集群的 ID。  
必需：如果[已配置](cloudhsm_cli-configs-multi-cluster.md)多个集群。

***<APPROVAL>***  
要在 HSM 上批准已签名令牌文件的文件路径。

***<SERVICE>***  
指定要为其生成令牌的仲裁授权服务。此参数为必需参数。有关服务类型和名称的更多信息，请参阅 [支持仲裁身份验证的服务名称和类型](quorum-auth-chsm-cli-service-names.md)。  
**有效值**  
+ **用户**：用户管理服务。用于执行仲裁授权用户管理操作的服务。
+ **仲裁**：仲裁管理服务。用于为任何仲裁授权服务设置仲裁授权仲裁值的服务。
+ **cluster**：用于执行集群范围配置管理（如 mtls 强制执行、mtls 注册和 mtls 取消注册）仲裁的集群管理服务。
+ **注册**：生成用于注册仲裁授权公有密钥的未签名令牌。
**是否必需**：是

***<VALUE>***  
指定要设置的仲裁值。最大仲裁值为八 (8)。  
**必需**：是

## 相关主题
<a name="quorum-token-set-qm-seealso"></a>
+ [法定代币符号 list-quorum-values](cloudhsm_cli-qm-token-list-qm.md)
+ [支持仲裁身份验证的服务名称和类型](quorum-auth-chsm-cli-service-names.md)
+ [设置 mTLS（推荐）](getting-started-setup-mtls.md)