Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mbedtls with hardware SHA engine #976

Closed
yoursunny opened this issue Jan 7, 2018 · 34 comments
Closed

mbedtls with hardware SHA engine #976

yoursunny opened this issue Jan 7, 2018 · 34 comments
Labels
Milestone

Comments

@yoursunny
Copy link
Contributor

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);
@copercini
Copy link
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
Copy link
Contributor Author

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
Copy link

stale bot commented Aug 1, 2019

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.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Aug 1, 2019
@yoursunny
Copy link
Contributor Author

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

@stale stale bot removed the Status: Stale Issue is stale stage (outdated/stuck) label Aug 1, 2019
@stale
Copy link

stale bot commented Sep 30, 2019

[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.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Sep 30, 2019
@yoursunny
Copy link
Contributor Author

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

@stale
Copy link

stale bot commented Sep 30, 2019

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

@stale stale bot removed the Status: Stale Issue is stale stage (outdated/stuck) label Sep 30, 2019
@stale
Copy link

stale bot commented Nov 29, 2019

[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.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Nov 29, 2019
@yoursunny
Copy link
Contributor Author

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

@stale
Copy link

stale bot commented Nov 29, 2019

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

@stale stale bot removed the Status: Stale Issue is stale stage (outdated/stuck) label Nov 29, 2019
@stale
Copy link

stale bot commented Jan 28, 2020

[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.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Jan 28, 2020
@yoursunny
Copy link
Contributor Author

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

@stale
Copy link

stale bot commented Jan 28, 2020

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

@stale stale bot removed the Status: Stale Issue is stale stage (outdated/stuck) label Jan 28, 2020
@stale
Copy link

stale bot commented Mar 28, 2020

[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.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Mar 28, 2020
@yoursunny
Copy link
Contributor Author

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

@stale
Copy link

stale bot commented Mar 28, 2020

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

@stale stale bot removed the Status: Stale Issue is stale stage (outdated/stuck) label Mar 28, 2020
@TomZanna
Copy link

Please, enable the hardware SHA engine.

@lbernstone
Copy link
Contributor

While it certainly does accelerate the hashing by about 4x, I get stack smashing issues when I compile with CONFIG_MBEDTLS_HARDWARE_SHA=y and test @copercini 's code.

@stale
Copy link

stale bot commented Jun 11, 2020

[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.

@stale stale bot removed the Status: Stale Issue is stale stage (outdated/stuck) label Aug 10, 2020
@stale
Copy link

stale bot commented Oct 9, 2020

[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.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Oct 9, 2020
@stale
Copy link

stale bot commented Oct 9, 2020

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

@stale stale bot removed the Status: Stale Issue is stale stage (outdated/stuck) label Oct 9, 2020
@omerahmedd
Copy link

any update on this ?

how to enable sha256 hardware acceleration on esp32

@stale
Copy link

stale bot commented Feb 2, 2021

[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.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Feb 2, 2021
@stale
Copy link

stale bot commented Feb 2, 2021

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

@stale stale bot removed the Status: Stale Issue is stale stage (outdated/stuck) label Feb 2, 2021
@stale
Copy link

stale bot commented Jun 20, 2021

[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.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Jun 20, 2021
@stale
Copy link

stale bot commented Jun 20, 2021

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

@stale stale bot removed the Status: Stale Issue is stale stage (outdated/stuck) label Jun 20, 2021
@stale
Copy link

stale bot commented Aug 21, 2021

[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.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Aug 21, 2021
@stale
Copy link

stale bot commented Aug 21, 2021

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

@stale stale bot removed the Status: Stale Issue is stale stage (outdated/stuck) label Aug 21, 2021
@VojtechBartoska VojtechBartoska added the Status: Awaiting triage Issue is waiting for triage label Mar 3, 2022
@hash13
Copy link

hash13 commented Mar 17, 2022

pls solve

@igrr
Copy link
Member

igrr commented Mar 18, 2022

Should be fixed by espressif/esp32-arduino-lib-builder@d65e071 — this will be merged into arduino-esp32 as part of #6341 and will be part of the next release.

@igrr igrr added Type: Bug 🐛 All bugs Status: In Progress Issue is in progress and removed Status: Awaiting triage Issue is waiting for triage labels Mar 18, 2022
@igrr igrr added this to the 2.0.3 milestone Mar 18, 2022
@VojtechBartoska
Copy link
Collaborator

I'm closing this as mentioned PR was merged. If you still face some issues regarding this, you can reopen it. Thanks to all for your contribution.

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

No branches or pull requests

8 participants