1
votes

I want to recursively hash a large file, how can i do that with mbedtls ?

while(!isFileEOF(hFile))
  {
    u16FileRead(&binBuffer,200,sizeof(binBuffer),hFile);
    mbedtls_sha256_ret(&binBuffer, sizeof(binBuffer), output, 0);
    mbedtls_sha256_update_ret(&ctx, &output, sizeof(output));
    mbedtls_sha256_update_ret(&ctx, &output, sizeof(output));
  }
mbedtls_sha256_finish_ret(&ctx, hash);
1

1 Answers

1
votes

I've done it by doing:

while(!isFileEOF(hFile))
  {
    u16FileRead(&binBuffer,200,sizeof(binBuffer),hFile);
    mbedtls_sha256_update_ret(&ctx, &binBuffer, sizeof(binBuffer));
  }
mbedtls_sha256_finish_ret(&ctx, hash);