Encryption STM32加密库的SHA-1哈希错误

Encryption STM32加密库的SHA-1哈希错误,encryption,cryptography,stm32,sha,Encryption,Cryptography,Stm32,Sha,使用TrueStudio,我正在使用STM32加密库包“STM32CubeExpansion\u Crypto\u V3.1.0”开发STM32f103RB。我想使用lib中的sha-1,但由于某些原因,我没有得到正确的结果 这是我的测试 我的输入缓冲区是:“('15434090074.11','1702635382a7b4243308035dfecc1e5e31678356bdfa39f92b6409a2')” 从,sha1的结果:c6818ce06b79c91cda7cc89f1af243e

使用TrueStudio,我正在使用STM32加密库包“STM32CubeExpansion\u Crypto\u V3.1.0”开发STM32f103RB。我想使用lib中的sha-1,但由于某些原因,我没有得到正确的结果

这是我的测试

我的输入缓冲区是:
“('15434090074.11','1702635382a7b4243308035dfecc1e5e31678356bdfa39f92b6409a2')”

从,sha1的结果:
c6818ce06b79c91cda7cc89f1af243e3d1373c1f

使用STM32加密库,我似乎无法生成正确的SHA-1和。 例如,我使用以下代码调用SHA-1哈希函数:

  SHA1ctx_stt SHA1ctx_st;            // The SHA1 context
  membuf_stt mb_st;                  // structure that will contain the preallocated buffer
  uint8_t Digest[CRL_SHA1_SIZE];     // Buffer that will contain the SHA-1 digest of the message
  uint8_t preallocated_buffer[4096]; // buffer required for internal allocation of memory

  int32_t status = HASH_SUCCESS;
  int32_t outputSize;

  const char* Message="('1543409074.11', '1702635382a7b4243308035dfecc1e5e31678356bdfa39f92b6409a2')";
  int32_t MessageSize = strlen(Message);


  // Initialize the membuf_st that must be passed to the ECC functions
  mb_st.mSize = sizeof(preallocated_buffer);
  mb_st.mUsed = 0;
  mb_st.pmBuf = preallocated_buffer;

  //Initialize it the SHA-1 Context
  SHA1ctx_st.mFlags = E_HASH_DEFAULT;

  // 20 byte of output
  SHA1ctx_st.mTagSize = CRL_SHA1_SIZE;

  // Init SHA-1
  status = SHA1_Init(&SHA1ctx_st);
  if (status == HASH_SUCCESS)
  {
    // Process the message with SHA-1
    status = SHA1_Append(&SHA1ctx_st, (const uint8_t *)Message, MessageSize);
    if (status == HASH_SUCCESS)
    {
      // Output the Digest
      status = SHA1_Finish(&SHA1ctx_st, Digest, &outputSize);
      if (status == HASH_SUCCESS)
      {
        // It's OK, but result in Digest isn't correct
      }
    }
  }
我错过了什么?有人知道可能出了什么问题吗

谢谢,我找到了解决办法。 ST历来通过探测CRC外围设备(基本上是一种质询-响应测试)将这些库锁定到STM32部件。 为此,必须启用RCC_CRC_CLK。使用CubeMX,您需要在计算选项卡中激活“CRC模式和配置”

你得到了什么结果?刚刚发现,可能是相关的?啊,所以它必须和CRC配置有关:)希望我的评论对你有所帮助。谢谢你自我回答这个问题!