Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Is it possible to separate separate esp_sha into esp_sha_init, esp_sha_update, esp_sha_finish? #2

Open
alberiolima opened this issue Mar 7, 2022 · 0 comments

Comments

@alberiolima
Copy link

alberiolima commented Mar 7, 2022

//https://github.com/pycom/esp-idf-2.0/blob/master/components/esp32/hwcrypto/sha.c

void esp_sha(esp_sha_type sha_type, const unsigned char *input, size_t ilen, unsigned char *output)
{
size_t block_len = block_length(sha_type);

esp_sha_lock_engine(sha_type);

SHA_CTX ctx;
ets_sha_init(&ctx);
while(ilen > 0) {
    size_t chunk_len = (ilen > block_len) ? block_len : ilen;
    esp_sha_lock_memory_block();
    esp_sha_wait_idle();
    ets_sha_update(&ctx, sha_type, input, chunk_len * 8);
    esp_sha_unlock_memory_block();
    input += chunk_len;
    ilen -= chunk_len;
}
esp_sha_lock_memory_block();
esp_sha_wait_idle();
ets_sha_finish(&ctx, sha_type, output);
esp_sha_unlock_memory_block();

esp_sha_unlock_engine(sha_type);

}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant