mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-06-20 05:51:46 +08:00
feat(ssl): Restructure ssl folder
Put mbedtls, axtls, openssl to ssl, also add kconfig to choose ssl library. Default use mbedtls.
This commit is contained in:
80
components/ssl/axtls/source/crypto/sha384.c
Normal file
80
components/ssl/axtls/source/crypto/sha384.c
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Cameron Rich
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* * Neither the name of the axTLS project nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
//#include <string.h>
|
||||
//#include "os_port.h"
|
||||
#include "ssl/ssl_os_port.h"
|
||||
#include "ssl/ssl_crypto.h"
|
||||
//#include "crypto.h"
|
||||
#include "lwip/mem.h"
|
||||
|
||||
/**
|
||||
* Initialize the SHA384 context
|
||||
*/
|
||||
void ICACHE_FLASH_ATTR SHA384_Init(SHA384_CTX *ctx)
|
||||
{
|
||||
//Set initial hash value
|
||||
ctx->h_dig.h[0] = 0xCBBB9D5DC1059ED8ULL;
|
||||
ctx->h_dig.h[1] = 0x629A292A367CD507ULL;
|
||||
ctx->h_dig.h[2] = 0x9159015A3070DD17ULL;
|
||||
ctx->h_dig.h[3] = 0x152FECD8F70E5939ULL;
|
||||
ctx->h_dig.h[4] = 0x67332667FFC00B31ULL;
|
||||
ctx->h_dig.h[5] = 0x8EB44A8768581511ULL;
|
||||
ctx->h_dig.h[6] = 0xDB0C2E0D64F98FA7ULL;
|
||||
ctx->h_dig.h[7] = 0x47B5481DBEFA4FA4ULL;
|
||||
|
||||
// Number of bytes in the buffer
|
||||
ctx->size = 0;
|
||||
// Total length of the message
|
||||
ctx->totalSize = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts an array of octets as the next portion of the message.
|
||||
*/
|
||||
void ICACHE_FLASH_ATTR SHA384_Update(SHA384_CTX *ctx, const uint8_t * msg, int len)
|
||||
{
|
||||
// The function is defined in the exact same manner as SHA-512
|
||||
SHA512_Update(ctx, msg, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the 384-bit message digest into the user's array
|
||||
*/
|
||||
void ICACHE_FLASH_ATTR SHA384_Final(uint8_t *digest, SHA384_CTX *ctx)
|
||||
{
|
||||
// The function is defined in the exact same manner as SHA-512
|
||||
SHA512_Final(NULL, ctx);
|
||||
|
||||
// Copy the resulting digest
|
||||
if (digest != NULL)
|
||||
memcpy(digest, ctx->h_dig.digest, SHA384_SIZE);
|
||||
}
|
||||
|
Reference in New Issue
Block a user