提交 00c77fda 编写于 作者: Z zhangtian 提交者: junping.pjp

BugID:21294927:[hal tls]improve random for tls

Change-Id: I0809174fd42aacce8bcae9796504aaae601f67d0
上级 1a4b0877
......@@ -57,6 +57,26 @@ static int _ssl_random(void *p_rng, unsigned char *output, size_t output_len)
return 0;
}
static void _aos_srand(unsigned int seed)
{
#define SEED_MAGIC 0x123
int ret = 0;
int seed_len = 0;
unsigned int seed_val = 0;
static char *g_seed_key = "seed_key";
seed_len = sizeof(seed_val);
ret = aos_kv_get(g_seed_key, &seed_val, &seed_len);
if (ret) {
seed_val = SEED_MAGIC;
}
seed_val += seed;
srand(seed_val);
seed_val = rand();
aos_kv_set(g_seed_key, &seed_val, sizeof(seed_val), 1);
}
static void _ssl_debug(void *ctx, int level, const char *file, int line,
const char *str)
{
......@@ -120,7 +140,7 @@ static int _ssl_client_init(mbedtls_ssl_context *ssl,
mbedtls_ssl_init(ssl);
mbedtls_ssl_config_init(conf);
mbedtls_x509_crt_init(crt509_ca);
_aos_srand(aos_now_ms());
/*verify_source->trusted_ca_crt==NULL
* 0. Initialize certificates
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册