本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
匯出金鑰
若要從 HSM 匯出私密金鑰 (即:對稱金鑰和非對稱私有金鑰),您必須先建立包裝金鑰。您可以直接匯出公有金鑰,而不需包裝金鑰。
只有金鑰擁有者可以匯出金鑰。共用金鑰的使用者可以在密碼編譯操作中使用此金鑰,但無法匯出此金鑰。執行這個範例時,請務必匯出您建立的金鑰。
匯出私密金鑰
完成以下步驟,以匯出私密金鑰。
匯出私密金鑰
-
使用指genSymKey令建立環繞索引鍵。以下命令會建立僅對目前工作階段而言有效的 128 位元 AES 包裝金鑰。
Command:
genSymKey -t 31 -s 16 -sess -l export-wrapping-key
Cfm3GenerateSymmetricKey returned: 0x00 : HSM Return: SUCCESS Symmetric Key Created. Key Handle: 524304 Cluster Error Status Node id 2 and err state 0x00000000 : HSM Return: SUCCESS
-
依據您要匯出的私密金鑰類型而定,使用以下其中一個命令。
-
若要匯出對稱金鑰,請使用指exSymKey令。以下命令會將 AES 金鑰匯出到名為
aes256.key.exp
的檔案。若要查看所有可用的選項,請使用 exSymKey -h 命令。Command:
exSymKey -k 524295 -out aes256.key.exp -w 524304
Cfm3WrapKey returned: 0x00 : HSM Return: SUCCESS Cfm3UnWrapHostKey returned: 0x00 : HSM Return: SUCCESS Wrapped Symmetric Key written to file "aes256.key.exp"
注意
命令的輸出顯示「包裝對稱金鑰」已寫入輸出檔。不過,輸出檔案包含純文字 (而非包裝) 金鑰。若要將包裝 (加密) 金鑰匯出到檔案,請使用 wrapKey 命令。
-
若要匯出私有金鑰,請使用 exportPrivateKey 命令。以下命令會將私有金鑰匯出到名為
rsa2048.key.exp
的檔案。若要查看所有可用的選項,請使用 exportPrivateKey -h 命令。Command:
exportPrivateKey -k 524296 -out rsa2048.key.exp -w 524304
Cfm3WrapKey returned: 0x00 : HSM Return: SUCCESS Cfm3UnWrapHostKey returned: 0x00 : HSM Return: SUCCESS PEM formatted private key is written to rsa2048.key.exp
-
匯出公有金鑰
使用 exportPubKey 命令來匯出公有金鑰。若要查看所有可用的選項,請使用 exportPubKey -h 命令。
以下範例將 RSA 公有金鑰匯出到名為 rsa2048.pub.exp
的檔案。
Command:
exportPubKey -k 524294 -out rsa2048.pub.exp
PEM formatted public key is written to rsa2048.pub.key Cfm3ExportPubKey returned: 0x00 : HSM Return: SUCCESS