

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

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

 AWS CloudHSM 金鑰物件可以是公有、私有或私密金鑰。系統會透過屬性來指定金鑰物件上允許的動作。金鑰物件建立時，即會一併建立屬性。當您使用 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) (以此為例)。

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

**Topics**
+ [屬性資料表](pkcs11-attributes-interpreting.md)
+ [修改屬性](modify-attr.md)
+ [解譯錯誤代碼](attr-errors.md)

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

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

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

## GenerateKeyPair
<a name="generatekeypair"></a>

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

## GenerateKey
<a name="generatekey"></a>

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

## CreateObject
<a name="createobject"></a>

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

## UnwrapKey
<a name="unwrapkey"></a>

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

## DeriveKey
<a name="derivekey"></a>

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

## GetAttributeValue
<a name="getattributevalue"></a>

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

**屬性註釋**
+  [1] 此屬性受韌體部分支援，且需明確設定為僅限預設值。
+  [2] 必要屬性。

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

物件的某些 PKCS \$111 程式庫屬性 AWS CloudHSM 可以在建立物件後修改，而有些則無法修改。若要修改屬性，請使用 CloudHSM CLI 中的[金鑰 set-attribute](cloudhsm_cli-key-set-attribute.md) 命令。您也可以使用 CloudHSM CLI 的[金鑰清單](cloudhsm_cli-key-list.md)命令來衍生屬性清單。

下列清單會顯示物件建立後可修改的屬性：
+ `CKA_LABEL`
+ `CKA_TOKEN`
**注意**  
只有在將工作階段金鑰變更為符記金鑰時，才允許進行修改。使用 CloudHSM CLI 的[金鑰 set-attribute](cloudhsm_cli-key-set-attribute.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 5 的 PKCS \$111 程式庫錯誤代碼
<a name="attr-errors"></a>

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

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