setAttribute - AWS CloudHSM

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

setAttribute

cloudhsm_mgmt_util 中的 setAttribute 命令可變更 HSM 中金鑰的標籤、加密、解密、包裝和取消包裝屬性的值。您也可以在 key_mgmt_util 中使用 setAttribute 命令,將工作階段金鑰轉換為持久性金鑰。您只能變更您所擁有金鑰的屬性。

啟動 CMU 並登入 HSM 後,方可執行任何 CMU 命令。請確認您所登入的使用者帳戶類型能夠執行您要使用的命令。

如果您新增或刪除 HSM,請更新 CMU 的組態檔案。否則,您所進行的變更可能無法在叢集中的所有 HSM 上生效。

使用者類型

下列使用者可以執行此命令。

  • 加密使用者 (CU)

語法

因為此命令未指明具體參數,所以您須依照語法圖表中指定的順序輸入引數。

setAttribute <key handle> <attribute id>

範例

此範例說明如何停用對稱金鑰的解密功能。您可使用這樣的命令來設定包裝金鑰,該金鑰應該能夠包裝和取消包裝其他金鑰,但不能加密或解密資料。

第一步是建立包裝金鑰。這個命令使用genSymKey在 key_mgmt_util 產生 256 位元的 AES 對稱金鑰。輸出顯示新金鑰的金鑰控制代碼是 14。

$ genSymKey -t 31 -s 32 -l aes256 Cfm3GenerateSymmetricKey returned: 0x00 : HSM Return: SUCCESS Symmetric Key Created. Key Handle: 14 Cluster Error Status Node id 0 and err state 0x00000000 : HSM Return: SUCCESS

接著,我們想要確認目前解密屬性的值。若要取得解密屬性的屬性 ID,請使用 listAttributes。輸出顯示代表 OBJ_ATTR_DECRYPT 屬性的常數是 261。如需金錀屬性的解譯說明,請參閱 金錀屬性參考

aws-cloudhsm> listAttributes Following are the possible attribute values for getAttribute: OBJ_ATTR_CLASS = 0 OBJ_ATTR_TOKEN = 1 OBJ_ATTR_PRIVATE = 2 OBJ_ATTR_LABEL = 3 OBJ_ATTR_TRUSTED = 134 OBJ_ATTR_KEY_TYPE = 256 OBJ_ATTR_ID = 258 OBJ_ATTR_SENSITIVE = 259 OBJ_ATTR_ENCRYPT = 260 OBJ_ATTR_DECRYPT = 261 OBJ_ATTR_WRAP = 262 OBJ_ATTR_UNWRAP = 263 OBJ_ATTR_SIGN = 264 OBJ_ATTR_VERIFY = 266 OBJ_ATTR_DERIVE = 268 OBJ_ATTR_LOCAL = 355 OBJ_ATTR_MODULUS = 288 OBJ_ATTR_MODULUS_BITS = 289 OBJ_ATTR_PUBLIC_EXPONENT = 290 OBJ_ATTR_VALUE_LEN = 353 OBJ_ATTR_EXTRACTABLE = 354 OBJ_ATTR_NEVER_EXTRACTABLE = 356 OBJ_ATTR_ALWAYS_SENSITIVE = 357 OBJ_ATTR_DESTROYABLE = 370 OBJ_ATTR_KCV = 371 OBJ_ATTR_WRAP_WITH_TRUSTED = 528 OBJ_ATTR_WRAP_TEMPLATE = 1073742353 OBJ_ATTR_UNWRAP_TEMPLATE = 1073742354 OBJ_ATTR_ALL = 512

如要取得金鑰 14 目前解密屬性的值,下一個命令會在 cloudhsm_mgmt_util 中使用 getAttribute

輸出顯示在叢集的兩個 HSM 上,解密屬性的值均為 true (1)。

aws-cloudhsm> getAttribute 14 261 Attribute Value on server 0(10.0.0.1): OBJ_ATTR_DECRYPT 0x00000001 Attribute Value on server 1(10.0.0.2): OBJ_ATTR_DECRYPT 0x00000001

此命令使用 setAttribute,將金鑰 14 的解密屬性 (屬性 261) 的值變更為 0。這將停用該金鑰的解密功能。

輸出顯示該命令在叢集中的兩個 HSM 上均成功執行。

aws-cloudhsm> setAttribute 14 261 0 *************************CAUTION******************************** This is a CRITICAL operation, should be done on all nodes in the cluster. AWS does NOT synchronize these changes automatically with the nodes on which this operation is not executed or failed, please ensure this operation is executed on all nodes in the cluster. **************************************************************** Do you want to continue(y/n)? y setAttribute success on server 0(10.0.0.1) setAttribute success on server 1(10.0.0.2)

最後的命令會重複 getAttribute 命令。同樣地,執行該命令會取得金鑰 14 的解密屬性 (屬性 261)。

此時,輸出顯示在叢集中的兩個 HSM 上,解密屬性的值均為 false (0)。

aws-cloudhsm>getAttribute 14 261 Attribute Value on server 0(10.0.3.6): OBJ_ATTR_DECRYPT 0x00000000 Attribute Value on server 1(10.0.1.7): OBJ_ATTR_DECRYPT 0x00000000

引數

setAttribute <key handle> <attribute id>
<key-handle>

指定您擁有金鑰的金鑰控制代碼。每一個命令中只能指定一個金鑰。若要取得金鑰的金鑰控制代碼,請在 key_mgmt_util 中使用 findKey。若要尋找金鑰的使用者,請使用getKeyInfo

必要:是

<attribute id>

指定常數,其代表您要變更的屬性。每一個命令中只能指定一個屬性。如要取得屬性及其整數值,請使用 listAttributes。如需金錀屬性的解譯說明,請參閱 金錀屬性參考

有效值:

  • 3OBJ_ATTR_LABEL

  • 134OBJ_ATTR_TRUSTED

  • 260OBJ_ATTR_ENCRYPT

  • 261OBJ_ATTR_DECRYPT

  • 262OBJ_ATTR_WRAP

  • 263OBJ_ATTR_UNWRAP

  • 264OBJ_ATTR_SIGN

  • 266OBJ_ATTR_VERIFY

  • 268OBJ_ATTR_DERIVE

  • 370OBJ_ATTR_DESTROYABLE

  • 528OBJ_ATTR_WRAP_WITH_TRUSTED

  • 1073742353OBJ_ATTR_WRAP_TEMPLATE

  • 1073742354OBJ_ATTR_UNWRAP_TEMPLATE

必要:是

相關主題