setAttribute - AWS CloudHSM

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

setAttribute

key_mgmt_util 中的 setAttribute 命令可將只在目前工作階段中有效的金鑰轉換為持久性金鑰。如果不刪除,持久性金錀就會一直存在。在作法上,此命令將金鑰的字符屬性值 (OBJ_ATTR_TOKEN) 從 false (0) 變更為 true (1)。您只能變更您所擁有之金鑰的屬性。

您也可以使用 cloudhsm_mgmt_util 中的 setAttribute 命令,以變更標籤、包裝、取消包裝、加密和解密屬性。

執行任何 key_mgmt_util 命令之前,您必須先啟動 start key_mgmt_util 並以加密使用者 (CU) 的身分 登入 HSM。

語法

setAttribute -h setAttribute -o <object handle> -a 1

範例

此範例示範如何將工作階段金鑰轉換為持久性金鑰。

第一個命令使用 genSymKey-sess參數,以建立只在目前工作階段中有效的 192 位元 AES 金鑰。輸出顯示新工作階段金鑰的金鑰控制代碼是 262154

Command: genSymKey -t 31 -s 24 -l tmpAES -sess Cfm3GenerateSymmetricKey returned: 0x00 : HSM Return: SUCCESS Symmetric Key Created. Key Handle: 262154 Cluster Error Status Node id 1 and err state 0x00000000 : HSM Return: SUCCESS

此命令使用 findKey 來尋找目前工作階段中的工作階段金鑰。輸出確認金鑰 262154 是工作階段金鑰。

Command: findKey -sess 1 Total number of keys present 1 number of keys matched from start index 0::0 262154 Cluster Error Status Node id 1 and err state 0x00000000 : HSM Return: SUCCESS Node id 0 and err state 0x00000000 : HSM Return: SUCCESS Cfm3FindKey returned: 0x00 : HSM Return: SUCCESS

此命令使用 setAttribute,以將金鑰 262154 從工作階段金鑰轉換為持久性金鑰。在作法上,此命令將金鑰的權杖屬性值 (OBJ_ATTR_TOKEN) 從 0 (false) 變更為 1 (true)。如需金錀屬性的解譯說明,請參閱 金鑰屬性參考

此命令使用 -o 參數來指定金鑰控制代碼 (262154),並使用 -a 參數來指定代表字符屬性的常數 (1)。執行此命令時會提示您輸入字符屬性的值。唯一的有效值是 1 (true),此值代表持久性金鑰。

Command: setAttribute -o 262154 -a 1 This attribute is defined as a boolean value. Enter the boolean attribute value (0 or 1):1 Cfm3SetAttribute returned: 0x00 : HSM Return: SUCCESS Cluster Error Status Node id 1 and err state 0x00000000 : HSM Return: SUCCESS Node id 0 and err state 0x00000000 : HSM Return: SUCCESS

為了確認金鑰 262154 現在是持久性,此命令使用 findKey 來搜尋工作階段金鑰 (-sess 1) 和持久性金鑰 (-sess 0)。這一次,命令不會尋找任何工作階段金鑰,而是傳回在持久性金鑰清單中的 262154

Command: findKey -sess 1 Total number of keys present 0 Cluster Error Status Node id 1 and err state 0x00000000 : HSM Return: SUCCESS Node id 0 and err state 0x00000000 : HSM Return: SUCCESS Cfm3FindKey returned: 0x00 : HSM Return: SUCCESS Command: findKey -sess 0 Total number of keys present 5 number of keys matched from start index 0::4 6, 7, 524296, 9, 262154 Cluster Error Status Node id 1 and err state 0x00000000 : HSM Return: SUCCESS Node id 0 and err state 0x00000000 : HSM Return: SUCCESS Cfm3FindKey returned: 0x00 : HSM Return: SUCCESS

參數

-h

顯示命令的說明。

必要:是

-o

指定目標金鑰的金鑰控制代碼。每一個命令中只能指定一個金鑰。若要取得金鑰的金鑰控制代碼,請使用 findKey

必要:是

-a

指定常數,其代表您要變更的屬性。唯一的有效值是 1,這代表字符屬性 OBJ_ATTR_TOKEN

若要取得屬性及其整數值,請使用 listAttributes

必要:是

相關主題