This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2745R10-Q1:HSM

Guru**** 2328790 points
Other Parts Discussed in Thread: CC2745R10-Q1
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1500128/cc2745r10-q1-hsm

器件型号:CC2745R10-Q1

工具/软件:

您好;  

我们尝试探索 CC2745中的 HSM 模块、问题是 SDK 中引入的示例仅提供如何操作结果(例如、对于 AESCBC、在调试后、我们仅选择1或2、我们无法输入明文。

这里的问题是、是否有一个 关于如何使用 HSM、 其主应用程序加密、密钥存储...或有关如何利用 HSM 的更多信息的结构化示例。

谢谢您;

此致

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好:

    您指的是哪个示例项目?

    此致、

    Nima Behmanesh

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好;  

    "C:\ti\simplelink_lowpower_f3_sdk_8_40_00_61\examples\nortos\LP_EM_CC2745R10-Q1\drivers\aescbc"上的 AESCBC 示例。

    但问题是在哪里可以找到有关如何在工程中包含 HSM 的说明、或者有引导式指令说明。

    谢谢您;

    谨致问候;

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好:

    对于 TI 驱动程序、HSM 的使用基于加密密钥的编码。 请参阅以下代码:

    #include <ti/drivers/AESCCM.h>
        #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
    
        #define USE_HSM 
    
        AESCCM_Params params;
        AESCCM_Handle handle;
        CryptoKey cryptoKey;
        int_fast16_t encryptionResult;
        uint8_t nonce[] = "Thisisanonce";
        uint8_t aad[] = "This string will be authenticated but not encrypted.";
        uint8_t plaintext[] = "This string will be encrypted and authenticated.";
        uint8_t mac[16];
        uint8_t ciphertext[sizeof(plaintext)];
        uint8_t keyingMaterial[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
                                      0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
                                      0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
                                      0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F};
        AESCCM_Params_init(&params)
        params.returnBehavior = AESCCM_RETURN_BEHAVIOR_POLLING;
        handle = AESCCM_open(0, &params);
        if (handle == NULL) {
            /* If the handle is returned as NULL, this indicates that the HSM 
             * firmware has not been flashed.
             */
            // handle error
        }
    
        #ifdef USE_HSM
        /* This is the API uses the HSM. */
        CryptoKeyPlaintextHSM_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
        #else
        /* This uses the LAES engine. */
        CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
        #endif
    
        AESCCM_OneStepOperation operation;
        AESCCM_OneStepOperation_init(&operation);
        operation.key           = &cryptoKey;
        operation.aad           = aad;
        operation.aadLength     = sizeof(aad);
        operation.input         = plaintext;
        operation.output        = ciphertext;
        operation.inputLength   = sizeof(plaintext);
        operation.nonce         = nonce;
        operation.nonceLength   = sizeof(nonce);
        operation.mac           = mac;
        operation.macLength     = sizeof(mac);
        encryptionResult = AESCCM_oneStepEncrypt(handle, &operation);
        if (encryptionResult != AESCCM_STATUS_SUCCESS) {
            // handle error
        }
        AESCCM_close(handle);


    通过  在上面的示例代码中定义 USE_HSM、可以看到、编码密钥材料的方式使用不同的 API。

        #ifdef USE_HSM
        /* This is the API uses the HSM. */
        CryptoKeyPlaintextHSM_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
        #else
        /* This uses the LAES engine. */
        CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
        #endif

    如果  使用 CryptoKeyPlainetxHSM_initKey 初始化密钥、则 HSM 用于涉及该密钥的操作。

    相反、如果使用  CryptoKeyPlainetxt_initKey 初始化密钥、则使用 LAES 引擎。

    其它加密驱动程序的说明位于驱动程序文档中。 例如、对于 AES-CBC、您可以在此处找到它: AESCBC.h 文件参考。 你会看到一个带有标题的代码片段(我会直接链接到它,但没有办法做到这一点):

    以下代码片段仅适用于 CC27XX 器件、并利用 HSM (一个单独的硬件加速器)

    对于密钥库、您将需要使用 PSA API (1简介—PSA Certified Crypto API 1.3)。  

    HSM、密钥库和 PSA 文档即将发布、将使此信息正规化。

    此致、

    Nima Behmanesh