mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
Now include os_port.h in tls1.h, but removed ax_malloc and friends
git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@255 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
This commit is contained in:
committed by
Yasuki Ikeuchi
parent
acc38e3ab3
commit
a9eab10499
@ -109,7 +109,7 @@ int get_file(const char *filename, uint8_t **buf)
|
|||||||
EXP_FUNC void STDCALL RNG_initialize()
|
EXP_FUNC void STDCALL RNG_initialize()
|
||||||
{
|
{
|
||||||
#if !defined(WIN32) && defined(CONFIG_USE_DEV_URANDOM)
|
#if !defined(WIN32) && defined(CONFIG_USE_DEV_URANDOM)
|
||||||
rng_fd = ax_open("/dev/urandom", O_RDONLY);
|
rng_fd = open("/dev/urandom", O_RDONLY);
|
||||||
#elif defined(WIN32) && defined(CONFIG_WIN32_USE_CRYPTO_LIB)
|
#elif defined(WIN32) && defined(CONFIG_WIN32_USE_CRYPTO_LIB)
|
||||||
if (!CryptAcquireContext(&gCryptProv,
|
if (!CryptAcquireContext(&gCryptProv,
|
||||||
NULL, NULL, PROV_RSA_FULL, 0))
|
NULL, NULL, PROV_RSA_FULL, 0))
|
||||||
@ -130,7 +130,7 @@ EXP_FUNC void STDCALL RNG_initialize()
|
|||||||
/* start of with a stack to copy across */
|
/* start of with a stack to copy across */
|
||||||
int i;
|
int i;
|
||||||
memcpy(entropy_pool, &i, ENTROPY_POOL_SIZE);
|
memcpy(entropy_pool, &i, ENTROPY_POOL_SIZE);
|
||||||
srand((unsigned int)&i);
|
rand_r((unsigned int *)entropy_pool);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ EXP_FUNC int STDCALL get_random(int num_rand_bytes, uint8_t *rand_data)
|
|||||||
#else /* nothing else to use, so use a custom RNG */
|
#else /* nothing else to use, so use a custom RNG */
|
||||||
/* The method we use when we've got nothing better. Use RC4, time
|
/* The method we use when we've got nothing better. Use RC4, time
|
||||||
and a couple of random seeds to generate a random sequence */
|
and a couple of random seeds to generate a random sequence */
|
||||||
RC4_CTX rng_ctx;
|
AES_CTX rng_ctx;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
MD5_CTX rng_digest_ctx;
|
MD5_CTX rng_digest_ctx;
|
||||||
uint8_t digest[MD5_SIZE];
|
uint8_t digest[MD5_SIZE];
|
||||||
@ -200,10 +200,10 @@ EXP_FUNC int STDCALL get_random(int num_rand_bytes, uint8_t *rand_data)
|
|||||||
MD5_Final(digest, &rng_digest_ctx);
|
MD5_Final(digest, &rng_digest_ctx);
|
||||||
|
|
||||||
/* come up with the random sequence */
|
/* come up with the random sequence */
|
||||||
RC4_setup(&rng_ctx, digest, MD5_SIZE); /* use as a key */
|
AES_set_key(&rng_ctx, digest, (const uint8_t *)ep, AES_MODE_128); /* use as a key */
|
||||||
memcpy(rand_data, entropy_pool, num_rand_bytes < ENTROPY_POOL_SIZE ?
|
memcpy(rand_data, entropy_pool, num_rand_bytes < ENTROPY_POOL_SIZE ?
|
||||||
num_rand_bytes : ENTROPY_POOL_SIZE);
|
num_rand_bytes : ENTROPY_POOL_SIZE);
|
||||||
RC4_crypt(&rng_ctx, rand_data, rand_data, num_rand_bytes);
|
AES_cbc_encrypt(&rng_ctx, rand_data, rand_data, num_rand_bytes);
|
||||||
|
|
||||||
/* move things along */
|
/* move things along */
|
||||||
for (i = ENTROPY_POOL_SIZE-1; i >= MD5_SIZE ; i--)
|
for (i = ENTROPY_POOL_SIZE-1; i >= MD5_SIZE ; i--)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, Cameron Rich
|
* Copyright (c) 2007-2016, Cameron Rich
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -91,9 +91,3 @@ EXP_FUNC int STDCALL getdomainname(char *buf, int buf_size)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef malloc
|
|
||||||
#undef realloc
|
|
||||||
#undef calloc
|
|
||||||
|
|
||||||
static const char * out_of_mem_str = "out of memory";
|
|
||||||
static const char * file_open_str = "Could not open file \"%s\"";
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007-2015, Cameron Rich
|
* Copyright (c) 2007-2016, Cameron Rich
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -189,27 +189,7 @@ EXP_FUNC int STDCALL getdomainname(char *buf, int buf_size);
|
|||||||
#endif /* Not Win32 */
|
#endif /* Not Win32 */
|
||||||
|
|
||||||
/* some functions to mutate the way these work */
|
/* some functions to mutate the way these work */
|
||||||
#define malloc(A) ax_port_malloc(A, __FILE__, __LINE__)
|
EXP_FUNC int STDCALL ax_open(const char *pathname, int flags);
|
||||||
#ifndef realloc
|
|
||||||
#define realloc(A,B) ax_port_realloc(A,B, __FILE__, __LINE__)
|
|
||||||
#endif
|
|
||||||
#define calloc(A,B) ax_port_calloc(A,B, __FILE__, __LINE__)
|
|
||||||
#define free(x) ax_port_free(x)
|
|
||||||
|
|
||||||
EXP_FUNC void * STDCALL ax_port_malloc(size_t s, const char*, int);
|
|
||||||
EXP_FUNC void * STDCALL ax_port_realloc(void *y, size_t s, const char*, int);
|
|
||||||
EXP_FUNC void * STDCALL ax_port_calloc(size_t n, size_t s, const char*, int);
|
|
||||||
EXP_FUNC void * STDCALL ax_port_free(void*);
|
|
||||||
EXP_FUNC int STDCALL ax_open(const char *pathname, int flags);
|
|
||||||
|
|
||||||
inline uint32_t htonl(uint32_t n){
|
|
||||||
return ((n & 0xff) << 24) |
|
|
||||||
((n & 0xff00) << 8) |
|
|
||||||
((n & 0xff0000UL) >> 8) |
|
|
||||||
((n & 0xff000000UL) >> 24);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ntohl htonl
|
|
||||||
|
|
||||||
#ifdef CONFIG_PLATFORM_LINUX
|
#ifdef CONFIG_PLATFORM_LINUX
|
||||||
void exit_now(const char *format, ...) __attribute((noreturn));
|
void exit_now(const char *format, ...) __attribute((noreturn));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007-2014, Cameron Rich
|
* Copyright (c) 2007-2016, Cameron Rich
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -43,6 +43,7 @@ extern "C" {
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "os_int.h"
|
#include "os_int.h"
|
||||||
|
#include "os_port.h"
|
||||||
#include "crypto.h"
|
#include "crypto.h"
|
||||||
#include "crypto_misc.h"
|
#include "crypto_misc.h"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user