mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
components/mbedtls: modify hardware encryption feature
rename "flag" and "keybites" in aes file, rename "xxx_starts" and add license in sha file.
This commit is contained in:
parent
2d80fada70
commit
1900c50d3b
@ -77,9 +77,9 @@ int esp_aes_setkey_enc( AES_CTX *ctx, const unsigned char *key,
|
||||
break;
|
||||
default : return( ERR_AES_INVALID_KEY_LENGTH );
|
||||
}
|
||||
if (ctx->enc.flag == false){
|
||||
ctx->enc.flag = true;
|
||||
ctx->enc.keybites = keybits;
|
||||
if (ctx->enc.keyflag == false){
|
||||
ctx->enc.keyflag = true;
|
||||
ctx->enc.keybits = keybits;
|
||||
memset(ctx->enc.key, 0, sizeof(ctx->enc.key));
|
||||
memcpy(ctx->enc.key, key, keybyte);
|
||||
} else {
|
||||
@ -108,9 +108,9 @@ int esp_aes_setkey_dec( AES_CTX *ctx, const unsigned char *key,
|
||||
break;
|
||||
default : return( ERR_AES_INVALID_KEY_LENGTH );
|
||||
}
|
||||
if (ctx->dec.flag == false){
|
||||
ctx->dec.flag = true;
|
||||
ctx->dec.keybites = keybits;
|
||||
if (ctx->dec.keyflag == false){
|
||||
ctx->dec.keyflag = true;
|
||||
ctx->dec.keybits = keybits;
|
||||
memset(ctx->dec.key, 0, sizeof(ctx->dec.key));
|
||||
memcpy(ctx->dec.key, key, keybyte);
|
||||
} else {
|
||||
@ -123,9 +123,9 @@ int esp_aes_setkey_dec( AES_CTX *ctx, const unsigned char *key,
|
||||
static void esp_aes_process_enable(AES_CTX *ctx, int mode)
|
||||
{
|
||||
if( mode == AES_ENCRYPT ){
|
||||
esp_aes_setkey_enc(ctx, ctx->enc.key, ctx->enc.keybites);
|
||||
esp_aes_setkey_enc(ctx, ctx->enc.key, ctx->enc.keybits);
|
||||
}else{
|
||||
esp_aes_setkey_dec(ctx, ctx->dec.key, ctx->dec.keybites);
|
||||
esp_aes_setkey_dec(ctx, ctx->dec.key, ctx->dec.keybits);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ extern "C" {
|
||||
#define ERR_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */
|
||||
|
||||
typedef struct{
|
||||
bool flag;
|
||||
uint16_t keybites;
|
||||
bool keyflag;
|
||||
uint16_t keybits;
|
||||
uint8_t key[32];
|
||||
}key_context, KEY_CTX;
|
||||
|
||||
|
@ -1,8 +1,17 @@
|
||||
/*
|
||||
* copyright (c) 2010 - 2012 Espressif System
|
||||
*
|
||||
* esf Link List Descriptor
|
||||
*/
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _ESP_SHA_H_
|
||||
#define _ESP_SHA_H_
|
||||
|
||||
@ -53,7 +62,7 @@ void esp_sha1_process(SHA1_CTX *ctx, const unsigned char data[64]);
|
||||
*
|
||||
* \param ctx context to be initialized
|
||||
*/
|
||||
void esp_sha1_starts( SHA1_CTX *ctx );
|
||||
void esp_sha1_start( SHA1_CTX *ctx );
|
||||
|
||||
/**
|
||||
* \brief SHA-1 process buffer
|
||||
@ -120,7 +129,7 @@ void esp_sha256_clone( SHA256_CTX *dst, const SHA256_CTX *src );
|
||||
* \param ctx context to be initialized
|
||||
* \param is224 0 = use SHA256, 1 = use SHA224
|
||||
*/
|
||||
void esp_sha256_starts( SHA256_CTX *ctx, int is224 );
|
||||
void esp_sha256_start( SHA256_CTX *ctx, int is224 );
|
||||
|
||||
/**
|
||||
* \brief SHA-256 process buffer
|
||||
@ -187,7 +196,7 @@ void esp_sha512_clone( SHA512_CTX *dst, const SHA512_CTX *src );
|
||||
* \param ctx context to be initialized
|
||||
* \param is384 0 = use SHA512, 1 = use SHA384
|
||||
*/
|
||||
void esp_sha512_starts( SHA512_CTX *ctx, int is384 );
|
||||
void esp_sha512_start( SHA512_CTX *ctx, int is384 );
|
||||
|
||||
/**
|
||||
* \brief SHA-512 process buffer
|
||||
|
@ -69,7 +69,7 @@ void esp_sha1_process(SHA1_CTX *ctx, const unsigned char data[64])
|
||||
/*
|
||||
* SHA-1 context setup
|
||||
*/
|
||||
void esp_sha1_starts( SHA1_CTX *ctx )
|
||||
void esp_sha1_start( SHA1_CTX *ctx )
|
||||
{
|
||||
SHA_LOCK();
|
||||
ets_sha_init(&ctx->context);
|
||||
@ -102,7 +102,7 @@ void esp_sha1_output( const unsigned char *input, size_t ilen, unsigned char out
|
||||
SHA1_CTX ctx;
|
||||
|
||||
esp_sha1_init( &ctx );
|
||||
esp_sha1_starts( &ctx );
|
||||
esp_sha1_start( &ctx );
|
||||
esp_sha1_update( &ctx, input, ilen );
|
||||
esp_sha1_finish( &ctx, output );
|
||||
esp_sha1_free( &ctx );
|
||||
@ -147,7 +147,7 @@ void esp_sha256_clone( SHA256_CTX *dst, const SHA256_CTX *src )
|
||||
/*
|
||||
* SHA-256 context setup
|
||||
*/
|
||||
void esp_sha256_starts( SHA256_CTX *ctx, int is224 )
|
||||
void esp_sha256_start( SHA256_CTX *ctx, int is224 )
|
||||
{
|
||||
SHA_LOCK();
|
||||
ets_sha_init(&ctx->context);
|
||||
@ -187,7 +187,7 @@ void esp_sha256_output( const unsigned char *input, size_t ilen, unsigned char o
|
||||
SHA256_CTX ctx;
|
||||
|
||||
esp_sha256_init( &ctx );
|
||||
esp_sha256_starts( &ctx, is224 );
|
||||
esp_sha256_start( &ctx, is224 );
|
||||
esp_sha256_update( &ctx, input, ilen );
|
||||
esp_sha256_finish( &ctx, output );
|
||||
esp_sha256_free( &ctx );
|
||||
@ -232,7 +232,7 @@ void esp_sha512_clone( SHA512_CTX *dst, const SHA512_CTX *src )
|
||||
/*
|
||||
* SHA-512 context setup
|
||||
*/
|
||||
void esp_sha512_starts( SHA512_CTX *ctx, int is384 )
|
||||
void esp_sha512_start( SHA512_CTX *ctx, int is384 )
|
||||
{
|
||||
SHA_LOCK();
|
||||
ets_sha_init(&ctx->context);
|
||||
@ -274,7 +274,7 @@ void esp_sha512_output( const unsigned char *input, size_t ilen,unsigned char ou
|
||||
SHA512_CTX ctx;
|
||||
|
||||
esp_sha512_init( &ctx );
|
||||
esp_sha512_starts( &ctx, is384 );
|
||||
esp_sha512_start( &ctx, is384 );
|
||||
esp_sha512_update( &ctx, input, ilen );
|
||||
esp_sha512_finish( &ctx, output );
|
||||
esp_sha512_free( &ctx );
|
||||
|
@ -17,7 +17,7 @@ extern "C" {
|
||||
typedef SHA1_CTX mbedtls_sha1_context;
|
||||
|
||||
#define mbedtls_sha1_init esp_sha1_init
|
||||
#define mbedtls_sha1_starts esp_sha1_starts
|
||||
#define mbedtls_sha1_starts esp_sha1_start
|
||||
#define mbedtls_sha1_clone esp_sha1_clone
|
||||
#define mbedtls_sha1_update esp_sha1_update
|
||||
#define mbedtls_sha1_finish esp_sha1_finish
|
||||
|
@ -19,7 +19,7 @@ typedef SHA256_CTX mbedtls_sha256_context;
|
||||
|
||||
#define mbedtls_sha256_init esp_sha256_init
|
||||
#define mbedtls_sha256_clone esp_sha256_clone
|
||||
#define mbedtls_sha256_starts esp_sha256_starts
|
||||
#define mbedtls_sha256_starts esp_sha256_start
|
||||
#define mbedtls_sha256_update esp_sha256_update
|
||||
#define mbedtls_sha256_finish esp_sha256_finish
|
||||
#define mbedtls_sha256_free esp_sha256_free
|
||||
|
@ -19,7 +19,7 @@ typedef SHA512_CTX mbedtls_sha512_context;
|
||||
#define mbedtls_sha512_init esp_sha512_init
|
||||
#define mbedtls_sha512_process esp_sha512_process
|
||||
#define mbedtls_sha512_clone esp_sha512_clone
|
||||
#define mbedtls_sha512_starts esp_sha512_starts
|
||||
#define mbedtls_sha512_starts esp_sha512_start
|
||||
#define mbedtls_sha512_update esp_sha512_update
|
||||
#define mbedtls_sha512_finish esp_sha512_finish
|
||||
#define mbedtls_sha512_free esp_sha512_free
|
||||
|
Loading…
Reference in New Issue
Block a user