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

@alberiolima

Description

@alberiolima

//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);

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions