NEW VERSION: 1.4.0

1. update boot.bin to v1.5;
2. phy version to 762;
3. add wifi_station_set/get_hostname api;
4. optimize net80211;
5. optimize ssl;
6. optimize ota;
7. optimize dhcp client;
8. update smartconfig to version 2.5.3;
9. support gpio wakeup;
10.enable IGMP in lwip;
11.some modify due to phy update;
12.add espconn_init in espconn.h;
13.update cjson/freertos/ssl;
14.add lwip/nopoll source code;
15.add libairkiss.a/airkiss.h, update smart_config;
16.update esp_init_data_default.bin;
17.irom0 too large, start addr change to 0x20000;
18.some modifications for system stability;
19.many other optimization;
This commit is contained in:
Espressif Systems
2016-02-26 20:40:06 +08:00
committed by Wu Jian Gang
parent 50459308c1
commit dba89f9aba
166 changed files with 70205 additions and 1766 deletions

View File

@@ -252,7 +252,8 @@ void ICACHE_FLASH_ATTR SHA256_Final(uint8_t *digest, SHA256_CTX *ctx)
uint32_t last, padn;
uint32_t high, low;
uint8_t msglen[8];
uint8_t *sha256_padding_ram = malloc(64);
uint8_t *sha256_padding_ram = (uint8_t *)SSL_MALLOC(64);
memcpy(sha256_padding_ram, sha256_padding, 64);
@@ -278,5 +279,5 @@ void ICACHE_FLASH_ATTR SHA256_Final(uint8_t *digest, SHA256_CTX *ctx)
PUT_UINT32(ctx->state[6], digest, 24);
PUT_UINT32(ctx->state[7], digest, 28);
free(sha256_padding_ram);
SSL_FREE(sha256_padding_ram);
}

View File

@@ -195,7 +195,8 @@ void ICACHE_FLASH_ATTR SHA512_Final(uint8_t *digest, SHA512_CTX *ctx)
int i;
size_t paddingSize;
uint64_t totalSize;
uint8_t *padding_ram = malloc(128);
uint8_t *padding_ram = (uint8_t *)SSL_MALLOC(128);
memcpy(padding_ram, padding, 128);
@@ -223,6 +224,6 @@ void ICACHE_FLASH_ATTR SHA512_Final(uint8_t *digest, SHA512_CTX *ctx)
if (digest != NULL)
memcpy(digest, ctx->h_dig.digest, SHA512_SIZE);
free(padding_ram);
SSL_FREE(padding_ram);
}

View File

@@ -179,10 +179,11 @@ void ICACHE_FLASH_ATTR AES_set_key(AES_CTX *ctx, const uint8_t *key,
{
int i, ii;
uint32_t *W, tmp, tmp2;
unsigned char *Rcon_ram = malloc(32);
unsigned char *ip;
int words;
unsigned char *Rcon_ram = (unsigned char *)SSL_MALLOC(32);
switch (mode)
{
case AES_MODE_128:
@@ -245,7 +246,7 @@ void ICACHE_FLASH_ATTR AES_set_key(AES_CTX *ctx, const uint8_t *key,
W[i]=W[i-words]^tmp;
}
free(Rcon_ram);
SSL_FREE(Rcon_ram);
/* copy the iv across */
memcpy(ctx->iv, iv, 16);

View File

@@ -94,7 +94,7 @@ static void check(const bigint *bi);
BI_CTX * ICACHE_FLASH_ATTR bi_initialize(void)
{
/* calloc() sets everything to zero */
BI_CTX *ctx = (BI_CTX *)zalloc(sizeof(BI_CTX));
BI_CTX *ctx = (BI_CTX *)SSL_ZALLOC(sizeof(BI_CTX));
/* the radix */
ctx->bi_radix = alloc(ctx, 2);
@@ -126,7 +126,7 @@ void ICACHE_FLASH_ATTR bi_terminate(BI_CTX *ctx)
}
bi_clear_cache(ctx);
free(ctx);
SSL_FREE(ctx);
}
/**
@@ -142,8 +142,8 @@ void ICACHE_FLASH_ATTR bi_clear_cache(BI_CTX *ctx)
for (p = ctx->free_list; p != NULL; p = pn)
{
pn = p->next;
free(p->comps);
free(p);
SSL_FREE(p->comps);
SSL_FREE(p);
}
ctx->free_count = 0;
@@ -1062,10 +1062,19 @@ int ICACHE_FLASH_ATTR bi_compare(bigint *bia, bigint *bib)
*/
static void ICACHE_FLASH_ATTR more_comps(bigint *bi, int n)
{
comp * bi_backs = NULL;
if (n > bi->max_comps)
{
bi->max_comps = max(bi->max_comps * 2, n);
bi->comps = (comp*)realloc(bi->comps, bi->max_comps * COMP_BYTE_SIZE);
if(bi->comps) {
//bi->comps = (comp*)SSL_REALLOC(bi->comps, bi->max_comps * COMP_BYTE_SIZE);
bi_backs = (comp*)SSL_ZALLOC(bi->max_comps * COMP_BYTE_SIZE);
if(bi_backs) {
memcpy(bi_backs,bi->comps,bi->max_comps * COMP_BYTE_SIZE);
SSL_FREE(bi->comps);
bi->comps = bi_backs;
}
}
}
if (n > bi->size)
@@ -1104,8 +1113,8 @@ static bigint * ICACHE_FLASH_ATTR alloc(BI_CTX *ctx, int size)
else
{
/* No free bigints available - create a new one. */
biR = (bigint *)malloc(sizeof(bigint));
biR->comps = (comp*)malloc(size * COMP_BYTE_SIZE);
biR = (bigint *)SSL_MALLOC(sizeof(bigint));
biR->comps = (comp*)SSL_MALLOC(size * COMP_BYTE_SIZE);
biR->max_comps = size; /* give some space to spare */
}
@@ -1311,7 +1320,7 @@ static void ICACHE_FLASH_ATTR precompute_slide_window(BI_CTX *ctx, int window, b
k <<= 1;
}
ctx->g = (bigint **)malloc(k*sizeof(bigint *));
ctx->g = (bigint **)SSL_MALLOC(k*sizeof(bigint *));
ctx->g[0] = bi_clone(ctx, g1);
bi_permanent(ctx->g[0]);
g2 = bi_residue(ctx, bi_square(ctx, ctx->g[0])); /* g^2 */
@@ -1365,7 +1374,7 @@ bigint * ICACHE_FLASH_ATTR bi_mod_power(BI_CTX *ctx, bigint *bi, bigint *biexp)
/* work out the slide constants */
precompute_slide_window(ctx, window_size, bi);
#else /* just one constant */
ctx->g = (bigint **)malloc(sizeof(bigint *));
ctx->g = (bigint **)SSL_MALLOC(sizeof(bigint *));
ctx->g[0] = bi_clone(ctx, bi);
ctx->window = 1;
bi_permanent(ctx->g[0]);
@@ -1417,7 +1426,7 @@ bigint * ICACHE_FLASH_ATTR bi_mod_power(BI_CTX *ctx, bigint *bi, bigint *biexp)
bi_free(ctx, ctx->g[i]);
}
free(ctx->g);
SSL_FREE(ctx->g);
bi_free(ctx, bi);
bi_free(ctx, biexp);
#if defined CONFIG_BIGINT_MONTGOMERY

View File

@@ -83,7 +83,7 @@ int ICACHE_FLASH_ATTR get_file(const char *filename, uint8_t **buf)
/* Win CE doesn't support stat() */
fseek(stream, 0, SEEK_END);
filesize = ftell(stream);
*buf = (uint8_t *)malloc(filesize);
*buf = (uint8_t *)SSL_MALLOC(filesize);
fseek(stream, 0, SEEK_SET);
do
@@ -120,7 +120,7 @@ int ICACHE_FLASH_ATTR get_file(const char *filename, uint8_t **buf)
return 0;
}
filesize = stream_stat.st_size;
*buf = (uint8_t *) zalloc(filesize);
*buf = (uint8_t *) SSL_ZALLOC(filesize);
do {
bytes_read = read(stream, *buf + total_bytes, filesize - total_bytes);
@@ -334,7 +334,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] =
static const uint8_t map[128] ICACHE_RODATA_ATTR STORE_ATTR =
{
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
@@ -355,11 +355,13 @@ EXP_FUNC int STDCALL ICACHE_FLASH_ATTR base64_decode(const char *in, int len,
int g, t, x, y, z;
uint8_t c;
int ret = -1;
uint8* base64_map = (uint8*)SSL_ZALLOC(128);
memcpy(base64_map, map, 128);
g = 3;
for (x = y = z = t = 0; x < len; x++)
{
if ((c = map[in[x]&0x7F]) == 0xff)
if ((c = base64_map[in[x]&0x7F]) == 0xff)
continue;
if (c == 254) /* this is the end... */
@@ -404,6 +406,7 @@ error:
ssl_printf("Error: Invalid base64\n"); //TTY_FLUSH();
#endif
//TTY_FLUSH();
SSL_FREE(base64_map);
return ret;
}

View File

@@ -45,12 +45,12 @@ void ICACHE_FLASH_ATTR ssl_hmac_md5(const uint8_t *msg, int length, const uint8_
int key_len, uint8_t *digest)
{
MD5_CTX context;
uint8_t k_ipad[64];
uint8_t k_opad[64];
uint8_t *k_ipad = (uint8_t *)SSL_ZALLOC(64);
uint8_t *k_opad = (uint8_t *)SSL_ZALLOC(64);
int i;
memset(k_ipad, 0, sizeof k_ipad);
memset(k_opad, 0, sizeof k_opad);
// memset(k_ipad, 0, sizeof k_ipad);
// memset(k_opad, 0, sizeof k_opad);
memcpy(k_ipad, key, key_len);
memcpy(k_opad, key, key_len);
@@ -68,6 +68,8 @@ void ICACHE_FLASH_ATTR ssl_hmac_md5(const uint8_t *msg, int length, const uint8_
MD5_Update(&context, k_opad, 64);
MD5_Update(&context, digest, MD5_SIZE);
MD5_Final(digest, &context);
SSL_FREE(k_ipad);
SSL_FREE(k_opad);
}
/**
@@ -78,12 +80,12 @@ void ICACHE_FLASH_ATTR ssl_hmac_sha1(const uint8_t *msg, int length, const uint8
int key_len, uint8_t *digest)
{
SHA1_CTX context;
uint8_t k_ipad[64];
uint8_t k_opad[64];
uint8_t *k_ipad = (uint8_t *)SSL_ZALLOC(64);
uint8_t *k_opad = (uint8_t *)SSL_ZALLOC(64);
int i;
memset(k_ipad, 0, sizeof k_ipad);
memset(k_opad, 0, sizeof k_opad);
// memset(k_ipad, 0, sizeof k_ipad);
// memset(k_opad, 0, sizeof k_opad);
memcpy(k_ipad, key, key_len);
memcpy(k_opad, key, key_len);
@@ -101,4 +103,7 @@ void ICACHE_FLASH_ATTR ssl_hmac_sha1(const uint8_t *msg, int length, const uint8
SHA1_Update(&context, k_opad, 64);
SHA1_Update(&context, digest, SHA1_SIZE);
SHA1_Final(digest, &context);
SSL_FREE(k_ipad);
SSL_FREE(k_opad);
}

View File

@@ -82,7 +82,7 @@ void ICACHE_FLASH_ATTR RSA_pub_key_new(RSA_CTX **ctx,
RSA_free(*ctx);
bi_ctx = bi_initialize();
*ctx = (RSA_CTX *)zalloc(sizeof(RSA_CTX));
*ctx = (RSA_CTX *)SSL_ZALLOC(sizeof(RSA_CTX));
rsa_ctx = *ctx;
rsa_ctx->bi_ctx = bi_ctx;
rsa_ctx->num_octets = mod_len;
@@ -124,7 +124,7 @@ void ICACHE_FLASH_ATTR RSA_free(RSA_CTX *rsa_ctx)
}
bi_terminate(bi_ctx);
free(rsa_ctx);
SSL_FREE(rsa_ctx);
}
/**
@@ -143,7 +143,7 @@ int ICACHE_FLASH_ATTR RSA_decrypt(const RSA_CTX *ctx, const uint8_t *in_data,
const int byte_size = ctx->num_octets;
int i = 0, size;
bigint *decrypted_bi, *dat_bi;
uint8_t *block = (uint8_t *)malloc(byte_size);
uint8_t *block = (uint8_t *)SSL_MALLOC(byte_size);
int pad_count = 0;
if (out_len < byte_size) /* check output has enough size */
@@ -194,7 +194,7 @@ int ICACHE_FLASH_ATTR RSA_decrypt(const RSA_CTX *ctx, const uint8_t *in_data,
if (size > 0)
memcpy(out_data, &block[i], size);
free(block);
SSL_FREE(block);
return size ? size : -1;
}