

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# AWS CloudHSM 用戶端 SDK 3 的 PKCS \$111 程式庫中的金鑰屬性
<a name="pkcs11-v3-attributes"></a>

金鑰物件可以是公有金鑰、私有金鑰或私密金鑰。系統會透過屬性來指定金鑰物件上允許的動作。金鑰物件建立時，即會一併建立屬性。當您使用 PKCS \$111 程式庫時 AWS CloudHSM，我們會依 PKCS \$111 標準指定預設值。

AWS CloudHSM 不支援 PKCS \$111 規格中列出的所有屬性。我們會符合所有支援屬性的規格，並在個別表格中列出這些屬性。

用來建立、修改或複製物件的加密函數 (如 `C_CreateObject`、`C_GenerateKey`、`C_GenerateKeyPair`、`C_UnwrapKey` 和 `C_DeriveKey`) 會採用屬性範本做為其中一個參數。如需在建立物件期間傳遞屬性範本的詳細資訊，請參閱[透過 PKCS \$111 程式庫產生金鑰](https://github.com/aws-samples/aws-cloudhsm-pkcs11-examples/tree/master/src/generate)範例。

下列主題提供有關用戶端 SDK 3 AWS CloudHSM 金鑰屬性的詳細資訊。

**Topics**
+ [屬性資料表](pkcs11-v3-attributes-interpreting.md)
+ [修改屬性](pkcs11-v3-modify-attr.md)
+ [解譯 AWS CloudHSM 用戶端 SDK 3 的 PKCS \$111 程式庫錯誤代碼](pkcs11-v3-attr-errors.md)

# AWS CloudHSM 用戶端 SDK 3 的 PKCS \$111 程式庫屬性資料表
<a name="pkcs11-v3-attributes-interpreting"></a>

 AWS CloudHSM 用戶端 SDK 3 的 PKCS \$111 程式庫資料表包含因金鑰類型而異的屬性清單。它指出在使用特定密碼編譯函數時，特定金鑰類型是否支援指定的屬性 AWS CloudHSM。

**圖例：**
+ ✔ 表示 CloudHSM 支援特定金鑰類型的屬性。
+ ✖ 表示 CloudHSM 不支援特定金鑰類型的屬性。
+ R 表示特定金鑰類型的屬性值設定為唯讀模式。
+ S 表示屬性較為敏感，因此無法透過 `GetAttributeValue` 讀取。
+ 預設值欄位中的空白儲存格表示屬性沒有獲派指定預設值。

## GenerateKeyPair
<a name="pkcs11-v3-generatekeypair"></a>

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/cloudhsm/latest/userguide/pkcs11-v3-attributes-interpreting.html)

## GenerateKey
<a name="pkcs11-v3-generatekey"></a>

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/cloudhsm/latest/userguide/pkcs11-v3-attributes-interpreting.html)

## CreateObject
<a name="pkcs11-v3-createobject"></a>

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/cloudhsm/latest/userguide/pkcs11-v3-attributes-interpreting.html)

## UnwrapKey
<a name="pkcs11-v3-unwrapkey"></a>

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/cloudhsm/latest/userguide/pkcs11-v3-attributes-interpreting.html)

## DeriveKey
<a name="pkcs11-v3-derivekey"></a>

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/cloudhsm/latest/userguide/pkcs11-v3-attributes-interpreting.html)

## GetAttributeValue
<a name="pkcs11-v3-getattributevalue"></a>

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/cloudhsm/latest/userguide/pkcs11-v3-attributes-interpreting.html)

**屬性註釋**
+  [1] 此屬性受韌體部分支援，且需明確設定為僅限預設值。
+  [2] 必要屬性。
+  [3] **僅限於用戶端 SDK 3**。`CKA_SIGN_RECOVER` 屬性由 `CKA_SIGN` 屬性衍生而來。若已設定，該屬性就僅能設定為與 `CKA_SIGN` 相同的值。若未設定，則該屬性會衍生 `CKA_SIGN` 的預設值。CloudHSM 只支援以 RSA 為基礎的可復原簽章機制，因此屬性目前僅適用於 RSA 公有金鑰。
+  [4] **僅限於用戶端 SDK 3**。`CKA_VERIFY_RECOVER` 屬性由 `CKA_VERIFY` 屬性衍生而來。若已設定，該屬性就僅能設定為與 `CKA_VERIFY` 相同的值。若未設定，則該屬性會衍生 `CKA_VERIFY` 的預設值。CloudHSM 只支援以 RSA 為基礎的可復原簽章機制，因此此屬性目前僅適用於 RSA 公有金鑰。

# 修改 AWS CloudHSM 用戶端 SDK 3 的 PKCS \$111 程式庫屬性
<a name="pkcs11-v3-modify-attr"></a>

有些物件屬性可在物件建立後進行修改，但有些不行。若要修改屬性，請使用來自 cloudhsm\$1mgmt\$1util 的 [setAttribute](cloudhsm_mgmt_util-setAttribute.md) 命令。您也可以使用來自 cloudhsm\$1mgmt\$1util 的 [listAttribute](cloudhsm_mgmt_util-listAttributes.md) 命令，來衍生屬性和代表這些屬性的常數清單。

下列清單會顯示物件建立後可修改的屬性：
+ `CKA_LABEL`
+ `CKA_TOKEN`
**注意**  
只有在將工作階段金鑰變更為符記金鑰時，才允許進行修改。使用 key\$1mgmt\$1util 中的 [setAttribute](key_mgmt_util-setAttribute.md) 命令來變更屬性值。
+ `CKA_ENCRYPT`
+ `CKA_DECRYPT`
+ `CKA_SIGN`
+ `CKA_VERIFY`
+ `CKA_WRAP`
+ `CKA_UNWRAP`
+ `CKA_LABEL`
+ `CKA_SENSITIVE`
+ `CKA_DERIVE`
**注意**  
這個屬性支援金鑰衍生。所有公有金鑰的屬性須為 `False`，不能設定為 `True`。如果是私密金鑰和 EC 私有金鑰，則該屬性可設定為 `True` 或 `False`。
+ `CKA_TRUSTED`
**注意**  
唯有加密管理員 (CO) 可將這個屬性設定成 `True` 或 `False`。
+ `CKA_WRAP_WITH_TRUSTED`
**注意**  
將此屬性套用於可匯出的資料金鑰，以表明只能使用標記為 `CKA_TRUSTED` 的金鑰包裝此金鑰。一旦設定 `CKA_WRAP_WITH_TRUSTED` 為 true，屬性就會變成唯讀，而且您無法變更或移除屬性。

# 解譯 AWS CloudHSM 用戶端 SDK 3 的 PKCS \$111 程式庫錯誤代碼
<a name="pkcs11-v3-attr-errors"></a>

在範本中指定特定金鑰不支援的 PKCS \$111 程式庫屬性會導致錯誤。下表包含違反規格時所產生的錯誤代碼：

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/cloudhsm/latest/userguide/pkcs11-v3-attr-errors.html)