Skip to content

mbedtls with hardware SHA engine #976

Closed
@yoursunny

Description

@yoursunny

Hardware:

Board: Heltec WiFi Kit 32
Core Installation/update date: 70d0d46
IDE name: Arduino 1.8.5
Flash Frequency: 80Mhz
Upload Speed: 115200

Description:

CONFIG_MBEDTLS_HARDWARE_SHA option is disabled.
As a result, SHA256 computation is slow.

Sketch:

#include <mbedtls/sha256.h>

void setup() {
  Serial.begin(115200);
  Serial.println();
}

void loop() {
  unsigned long t0 = micros();
  mbedtls_sha256_context ctx;
  mbedtls_sha256_init(&ctx);
  for (int i = 0; i < 16777216; ++i) {
    Serial.printf("mode=%d\n", ctx.mode);
    mbedtls_sha256_update(&ctx, reinterpret_cast<const uint8_t*>("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno"), 64);
  }
  uint8_t digest[32];
  mbedtls_sha256_finish(&ctx, digest);
  mbedtls_sha256_free(&ctx);
  unsigned long t1 = micros();

  for (int i = 0; i < sizeof(digest); ++i) {
    Serial.printf("%02x", digest[i]);
  }
  Serial.println();
  Serial.printf("duration=%lu\n", t1 - t0);
}

Debug Messages:

In "alt" version of mbedtls_sha256_context, there is a mode member that indicates whether hardware or software SHA engine is selected.
The sketch does not compile because the mbedtls_sha256_context only supports software implementation.

sha256-mbedtls:13: error: 'struct mbedtls_sha256_context' has no member named 'mode'

     Serial.printf("mode=%d\n", ctx.mode);

Activity

copercini

copercini commented on Jan 8, 2018

@copercini
Contributor

It has disabled due an old bug in hardware acceleration that crash mbedltls sometimes (espressif/esp-idf#630)
It's fixed on IDF now and just waiting for the update for Arduino here: #964

yoursunny

yoursunny commented on Aug 18, 2018

@yoursunny
ContributorAuthor

Core Installation/update date: 172802b
Now that #964 is closed, but CONFIG_MBEDTLS_HARDWARE_SHA stays disabled.
Can this be enabled?

I tried modifying tools/sdk/sdkconfig but it does not seem to be effective. I don't know how to regenerate binaries in there.

stale

stale commented on Aug 1, 2019

@stale

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

yoursunny

yoursunny commented on Aug 1, 2019

@yoursunny
ContributorAuthor

This issue should remain open. Enabling hardware SHA engine is a useful performance improvement.

removed
Status: StaleIssue is stale stage (outdated/stuck)
on Aug 1, 2019
stale

stale commented on Sep 30, 2019

@stale

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

yoursunny

yoursunny commented on Sep 30, 2019

@yoursunny
ContributorAuthor

This issue should remain open. Enabling hardware SHA engine is a useful performance improvement.

stale

stale commented on Sep 30, 2019

@stale

[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future.

stale

stale commented on Nov 29, 2019

@stale

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

yoursunny

yoursunny commented on Nov 29, 2019

@yoursunny
ContributorAuthor

This issue should remain open. Enabling hardware SHA engine is a useful performance improvement.

56 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      mbedtls with hardware SHA engine · Issue #976 · espressif/arduino-esp32