Merge branch 'feature/ssl_refactor' into 'refactor'

Re-structure axtls/mbedtls/openssl

See merge request sdk/ESP8266_RTOS_SDK!54
This commit is contained in:
Wu Jian Gang
2018-04-12 11:34:21 +08:00
203 changed files with 168 additions and 153 deletions

View File

@ -1,6 +0,0 @@
#
# Component Makefile
#
COMPONENT_ADD_INCLUDEDIRS += include/ssl
COMPONENT_SRCDIRS := source/ssl source/crypto

View File

@ -1,8 +0,0 @@
#
# Component Makefile
#
COMPONENT_ADD_INCLUDEDIRS += include/mbedtls
COMPONENT_SRCDIRS += source/library source/platform
CFLAGS += -DMBEDTLS_CONFIG_FILE='"config_esp.h"'

View File

@ -1,6 +0,0 @@
#
# Component Makefile
#
COMPONENT_ADD_INCLUDEDIRS += include/openssl include/internal include/platform
COMPONENT_SRCDIRS := source/library source/platform

17
components/ssl/Kconfig Normal file
View File

@ -0,0 +1,17 @@
menu "SSL"
choice SSL_LIBRARY_CHOOSE
prompt "Choose SSL/TLS library"
default SSL_USING_MBEDTLS
help
Choose the SSL/TLS library which you want to use.
Currently we support mbedTLS and axTLS.
config SSL_USING_MBEDTLS
bool "mbedTLS"
config SSL_USING_AXTLS
bool "axTLS"
endchoice
endmenu

View File

@ -0,0 +1,6 @@
# Anyone compiling mbedTLS code needs the name of the
# alternative config file
#ifdef CONFIG_SSL_USING_MBEDTLS
CPPFLAGS += -DMBEDTLS_CONFIG_FILE='"mbedtls/config_esp.h"'
#endif

View File

@ -55,7 +55,7 @@ static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
(b)[(i) + 3] = (uint8_t) ((n) ); \
}
static const uint8_t sha256_padding[64] ICACHE_RODATA_ATTR STORE_ATTR =
static const uint8_t sha256_padding[64] =
{
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

View File

@ -49,7 +49,7 @@
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
static const uint8_t padding[128] ICACHE_RODATA_ATTR STORE_ATTR =
static const uint8_t padding[128] =
{
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -61,7 +61,7 @@ static const uint8_t padding[128] ICACHE_RODATA_ATTR STORE_ATTR =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const uint64_t k[80] ICACHE_RODATA_ATTR STORE_ATTR =
static const uint64_t k[80] =
{
0x428A2F98D728AE22ULL, 0x7137449123EF65CDULL, 0xB5C0FBCFEC4D3B2FULL, 0xE9B5DBA58189DBBCULL,
0x3956C25BF348B538ULL, 0x59F111F1B605D019ULL, 0x923F82A4AF194F9BULL, 0xAB1C5ED5DA6D8118ULL,

View File

@ -81,7 +81,7 @@ static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
/*
* AES S-box
*/
static const uint8_t aes_sbox[256] ICACHE_RODATA_ATTR STORE_ATTR =
static const uint8_t aes_sbox[256] =
{
0x63,0x7C,0x77,0x7B,0xF2,0x6B,0x6F,0xC5,
0x30,0x01,0x67,0x2B,0xFE,0xD7,0xAB,0x76,
@ -120,7 +120,7 @@ static const uint8_t aes_sbox[256] ICACHE_RODATA_ATTR STORE_ATTR =
/*
* AES is-box
*/
static const uint8_t aes_isbox[256] ICACHE_RODATA_ATTR STORE_ATTR =
static const uint8_t aes_isbox[256] =
{
0x52,0x09,0x6a,0xd5,0x30,0x36,0xa5,0x38,
0xbf,0x40,0xa3,0x9e,0x81,0xf3,0xd7,0xfb,
@ -156,7 +156,7 @@ static const uint8_t aes_isbox[256] ICACHE_RODATA_ATTR STORE_ATTR =
0xe1,0x69,0x14,0x63,0x55,0x21,0x0c,0x7d
};
static const unsigned char Rcon[30] ICACHE_RODATA_ATTR STORE_ATTR =
static const unsigned char Rcon[30] =
{
0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,
0x1b,0x36,0x6c,0xd8,0xab,0x4d,0x9a,0x2f,

View File

@ -61,7 +61,7 @@ static HCRYPTPROV gCryptProv;
static uint8_t entropy_pool[ENTROPY_POOL_SIZE];
#endif
const char unsupported_str[] ICACHE_RODATA_ATTR STORE_ATTR = "Error: Feature not supported\n";
const char unsupported_str[] = "Error: Feature not supported\n";
#ifndef CONFIG_SSL_SKELETON_MODE
/**
@ -338,7 +338,7 @@ EXP_FUNC void STDCALL print_blob(const char *format, const unsigned char *data,
#if defined(CONFIG_SSL_HAS_PEM) || defined(CONFIG_HTTP_HAS_AUTHORIZATION)
/* base64 to binary lookup table */
static const uint8_t map[128] ICACHE_RODATA_ATTR STORE_ATTR =
static const uint8_t map[128] =
{
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,

View File

@ -191,7 +191,7 @@ void ICACHE_FLASH_ATTR ssl_obj_free(SSLObjLoader *ssl_obj)
#define IS_PRIVATE_KEY 2
#define IS_CERTIFICATE 3
static const char begins[NUM_PEM_TYPES][40] ICACHE_RODATA_ATTR STORE_ATTR =
static const char begins[NUM_PEM_TYPES][40] =
{
"-----BEGIN RSA PRIVATE KEY-----",
"-----BEGIN ENCRYPTED PRIVATE KEY-----",
@ -199,7 +199,7 @@ static const char begins[NUM_PEM_TYPES][40] ICACHE_RODATA_ATTR STORE_ATTR =
"-----BEGIN CERTIFICATE-----",
};
static const char ends[NUM_PEM_TYPES][40] ICACHE_RODATA_ATTR STORE_ATTR =
static const char ends[NUM_PEM_TYPES][40] =
{
"-----END RSA PRIVATE KEY-----",
"-----END ENCRYPTED PRIVATE KEY-----",
@ -207,7 +207,7 @@ static const char ends[NUM_PEM_TYPES][40] ICACHE_RODATA_ATTR STORE_ATTR =
"-----END CERTIFICATE-----",
};
static const char aes_str[2][24] ICACHE_RODATA_ATTR STORE_ATTR =
static const char aes_str[2][24] =
{
"DEK-Info: AES-128-CBC,",
"DEK-Info: AES-256-CBC,"

View File

@ -107,7 +107,7 @@ char *ICACHE_FLASH_ATTR esp_EVP_cleanup(void)
return NULL;
}
static const unsigned char base64_enc_map[64] ICACHE_RODATA_ATTR STORE_ATTR =
static const unsigned char base64_enc_map[64] =
{
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',

View File

@ -44,10 +44,10 @@ static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
/* The session expiry time */
#define SSL_EXPIRY_TIME (CONFIG_SSL_EXPIRY_TIME*3600)
static const uint8_t g_hello_request[] ICACHE_RODATA_ATTR STORE_ATTR = { HS_HELLO_REQUEST, 0, 0, 0 };
static const uint8_t g_chg_cipher_spec_pkt[] ICACHE_RODATA_ATTR STORE_ATTR = { 1 };
static const char server_finished[] ICACHE_RODATA_ATTR STORE_ATTR = "server finished";
static const char client_finished[] ICACHE_RODATA_ATTR STORE_ATTR = "client finished";
static const uint8_t g_hello_request[] = { HS_HELLO_REQUEST, 0, 0, 0 };
static const uint8_t g_chg_cipher_spec_pkt[] = { 1 };
static const char server_finished[] = "server finished";
static const char client_finished[] = "client finished";
static int do_handshake(SSL *ssl, uint8_t *buf, int read_len);
static int set_key_block(SSL *ssl, int is_write);
@ -65,7 +65,7 @@ const uint8_t ssl_prot_prefs[NUM_PROTOCOLS] =
#else
static void session_free(SSL_SESSION *ssl_sessions[], int sess_index);
const uint8_t ssl_prot_prefs[NUM_PROTOCOLS] ICACHE_RODATA_ATTR STORE_ATTR =
const uint8_t ssl_prot_prefs[NUM_PROTOCOLS] =
#ifdef CONFIG_SSL_PROT_LOW /* low security, fast speed */
{ SSL_RC4_128_SHA, SSL_AES128_SHA, SSL_AES256_SHA, SSL_RC4_128_MD5 };
#elif CONFIG_SSL_PROT_MEDIUM /* medium security, medium speed */

View File

@ -31,7 +31,7 @@
#include "ssl/ssl_os_port.h"
#include "ssl/ssl_ssl.h"
static const uint8_t g_hello_done[] ICACHE_RODATA_ATTR STORE_ATTR = { HS_SERVER_HELLO_DONE, 0, 0, 0 };
static const uint8_t g_hello_done[] = { HS_SERVER_HELLO_DONE, 0, 0, 0 };
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
@ -435,7 +435,7 @@ error:
}
#ifdef CONFIG_SSL_CERT_VERIFICATION
static const uint8_t g_cert_request[] ICACHE_RODATA_ATTR STORE_ATTR = { HS_CERT_REQ, 0, 0, 4, 1, 0, 0, 0 };
static const uint8_t g_cert_request[] = { HS_CERT_REQ, 0, 0, 4, 1, 0, 0, 0 };
/*
* Send the certificate request message.

View File

@ -0,0 +1,15 @@
#
# Component Makefile
#
COMPONENT_ADD_INCLUDEDIRS := openssl/include
COMPONENT_PRIV_INCLUDEDIRS := openssl/include/internal openssl/include/openssl openssl/include/platform
COMPONENT_SRCDIRS := openssl/source/library openssl/source/platform
ifdef CONFIG_SSL_USING_MBEDTLS
COMPONENT_ADD_INCLUDEDIRS += mbedtls/include
COMPONENT_SRCDIRS += mbedtls/source/library mbedtls/source/platform
else
COMPONENT_ADD_INCLUDEDIRS += axtls/include
COMPONENT_SRCDIRS += axtls/source/ssl axtls/source/crypto
endif

Some files were not shown because too many files have changed in this diff Show More