

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

# AWS CloudHSM 用戶端 SDK 3 的 PKCS \$111 程式庫程式碼範例
<a name="pkcs11-v3-samples"></a>

GitHub 上的程式碼範例示範如何使用適用於 的 PKCS \$111 程式庫來完成基本任務 AWS CloudHSM。

## 範本程式碼先決條件
<a name="pkcs11-v3-samples-prereqs"></a>

執行範例之前，請執行以下步驟來設定您的環境：
+ 安裝並設定適用於用戶端 SDK 3 的 [PKCS \$111 程式庫](install-pkcs11-v3.md)。
+ 設定[密碼編譯使用者 (CU)](manage-hsm-users.md)。您的應用程式會使用此 HSM 帳戶在 HSM 上執行程式碼範例。

## 程式碼範例
<a name="pkcs11-v3-samples-code"></a>

適用於 PKCS\$111 AWS CloudHSM 的軟體程式庫程式碼範例可在 [GitHub](https://github.com/aws-samples/aws-cloudhsm-pkcs11-examples) 上取得。此儲存庫包括如何使用 PKCS \$111 執行一般作業的範例，包括加密、解密、簽署和驗證。
+ [產生金鑰 (AES、RSA、EC)](https://github.com/aws-samples/aws-cloudhsm-pkcs11-examples/tree/master/src/generate)
+ [列出金鑰屬性](https://github.com/aws-samples/aws-cloudhsm-pkcs11-examples/blob/master/src/attributes/)
+ [使用 AES GCM 加密和解密資料](https://github.com/aws-samples/aws-cloudhsm-pkcs11-examples/blob/master/src/encrypt/aes_gcm.c)
+ [使用 AES\$1CTR 加密和解密資料](https://github.com/aws-samples/aws-cloudhsm-pkcs11-examples/tree/master/src/encrypt/aes_ctr.c) 
+ [使用 3DES 加密和解密資料](https://github.com/aws-samples/aws-cloudhsm-pkcs11-examples/tree/master/src/encrypt/des_ecb.c) 
+ [使用 RSA 簽署和驗證資料](https://github.com/aws-samples/aws-cloudhsm-pkcs11-examples/blob/master/src/sign/rsa_sign.c)
+ [使用 HMAC KDF 衍生金鑰](https://github.com/aws-samples/aws-cloudhsm-pkcs11-examples/blob/master/src/derivation/hmac_kdf.c)
+ [使用以 PKCS \$15 填補的 AES 包裝和取消包裝金鑰](https://github.com/aws-samples/aws-cloudhsm-pkcs11-examples/blob/master/src/wrapping/aes_wrapping.c)
+ [使用不填補的 AES 包裝和取消包裝金鑰](https://github.com/aws-samples/aws-cloudhsm-pkcs11-examples/blob/master/src/wrapping/aes_no_padding_wrapping.c)
+ [使用零填補的 AES 包裝和取消包裝金鑰](https://github.com/aws-samples/aws-cloudhsm-pkcs11-examples/blob/master/src/wrapping/aes_zero_padding_wrapping.c)
+ [使用 AES-GCM 包裝和取消包裝金鑰](https://github.com/aws-samples/aws-cloudhsm-pkcs11-examples/tree/master/src/wrapping/aes_gcm_wrapping.c)
+ [使用 RSA 包裝和取消包裝金鑰](https://github.com/aws-samples/aws-cloudhsm-pkcs11-examples/blob/master/src/wrapping/rsa_wrapping.c)