feat(mbedtls): mbedtls using SHA/AES of util component instead of its raw algorithm

This commit is contained in:
Dong Heng
2019-12-24 13:23:57 +08:00
parent a3537856b2
commit 297294c5b9
7 changed files with 58 additions and 138 deletions

View File

@ -16,15 +16,6 @@
#include "mbedtls/sha256.h"
#include <string.h>
#ifdef MBEDTLS_SHA256_ALT
/* Wrapper only works if the libsodium context structure can be mapped
directly to the mbedTLS context structure.
See extended comments in crypto_hash_sha512_mbedtls.c
*/
#error "This wrapper only support standard software mbedTLS SHA"
#endif
/* Sanity check that all the context fields have identical sizes
(this should be more or less given from the SHA256 algorithm)
@ -55,7 +46,6 @@ static void sha256_libsodium_to_mbedtls(mbedtls_sha256_context *mb_ctx, crypto_h
memcpy(mb_ctx->total, &ls_state->count, sizeof(mb_ctx->total));
memcpy(mb_ctx->state, ls_state->state, sizeof(mb_ctx->state));
memcpy(mb_ctx->buffer, ls_state->buf, sizeof(mb_ctx->buffer));
mb_ctx->is224 = 0;
}
int

View File

@ -16,18 +16,6 @@
#include "mbedtls/sha512.h"
#include <string.h>
#ifdef MBEDTLS_SHA512_ALT
/* Wrapper only works if the libsodium context structure can be mapped
directly to the mbedTLS context structure.
For ESP8266 hardware SHA, the problems are fitting all the data in
the libsodium state structure, and also that libsodium doesn't
have mbedtls_sha512_free() or mbedtls_sha512_clone() so we can't
manage the hardware state in a clean way.
*/
#error "This wrapper only support standard software mbedTLS SHA"
#endif
/* Sanity check that all the context fields have identical sizes
(this should be more or less given from the SHA512 algorithm)
@ -59,7 +47,6 @@ static void sha512_libsodium_to_mbedtls(mbedtls_sha512_context *mb_ctx, crypto_h
memcpy(mb_ctx->total, ls_state->count, sizeof(mb_ctx->total));
memcpy(mb_ctx->state, ls_state->state, sizeof(mb_ctx->state));
memcpy(mb_ctx->buffer, ls_state->buf, sizeof(mb_ctx->buffer));
mb_ctx->is384 = 0;
}
int