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 {
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 {
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;
}
#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;
-/*
- * 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_
*
* \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
* \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
* \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
/*
* 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);
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 );
/*
* 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);
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 );
/*
* 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);
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 );
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
#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
#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