Skip to content

Commit fe6e51a

Browse files
committed
Merge pull request esp8266#15 from jmue/axtls-upgrade
axtls upgrade to svn r251 (1.5.3+)
2 parents 139914f + 0c09e2c commit fe6e51a

21 files changed

+941
-298
lines changed

Diff for: Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ OBJ_FILES := \
1212
crypto/aes.o \
1313
crypto/bigint.o \
1414
crypto/hmac.o \
15-
crypto/md2.o \
1615
crypto/md5.o \
1716
crypto/rc4.o \
1817
crypto/rsa.o \
1918
crypto/sha1.o \
19+
crypto/sha256.o \
20+
crypto/sha384.o \
21+
crypto/sha512.o \
2022
ssl/asn1.o \
2123
ssl/gen_cert.o \
2224
ssl/loader.o \

Diff for: crypto/crypto.h

+50-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, Cameron Rich
2+
* Copyright (c) 2007-2015, Cameron Rich
33
*
44
* All rights reserved.
55
*
@@ -39,7 +39,6 @@
3939
extern "C" {
4040
#endif
4141

42-
#include "config.h"
4342
#include "bigint_impl.h"
4443
#include "bigint.h"
4544

@@ -124,22 +123,58 @@ void SHA1_Update(SHA1_CTX *, const uint8_t * msg, int len);
124123
void SHA1_Final(uint8_t *digest, SHA1_CTX *);
125124

126125
/**************************************************************************
127-
* MD2 declarations
126+
* SHA256 declarations
128127
**************************************************************************/
129128

130-
#define MD2_SIZE 16
129+
#define SHA256_SIZE 32
131130

132131
typedef struct
133132
{
134-
unsigned char cksum[16]; /* checksum of the data block */
135-
unsigned char state[48]; /* intermediate digest state */
136-
unsigned char buffer[16]; /* data block being processed */
137-
int left; /* amount of data in buffer */
138-
} MD2_CTX;
133+
uint32_t total[2];
134+
uint32_t state[8];
135+
uint8_t buffer[64];
136+
} SHA256_CTX;
139137

140-
EXP_FUNC void STDCALL MD2_Init(MD2_CTX *ctx);
141-
EXP_FUNC void STDCALL MD2_Update(MD2_CTX *ctx, const uint8_t *input, int ilen);
142-
EXP_FUNC void STDCALL MD2_Final(uint8_t *digest, MD2_CTX *ctx);
138+
void SHA256_Init(SHA256_CTX *c);
139+
void SHA256_Update(SHA256_CTX *, const uint8_t *input, int len);
140+
void SHA256_Final(uint8_t *digest, SHA256_CTX *);
141+
142+
/**************************************************************************
143+
* SHA512 declarations
144+
**************************************************************************/
145+
146+
#define SHA512_SIZE 64
147+
148+
typedef struct
149+
{
150+
union
151+
{
152+
uint64_t h[8];
153+
uint8_t digest[64];
154+
} h_dig;
155+
union
156+
{
157+
uint64_t w[80];
158+
uint8_t buffer[128];
159+
} w_buf;
160+
size_t size;
161+
uint64_t totalSize;
162+
} SHA512_CTX;
163+
164+
void SHA512_Init(SHA512_CTX *c);
165+
void SHA512_Update(SHA512_CTX *, const uint8_t *input, int len);
166+
void SHA512_Final(uint8_t *digest, SHA512_CTX *);
167+
168+
/**************************************************************************
169+
* SHA384 declarations
170+
**************************************************************************/
171+
172+
#define SHA384_SIZE 48
173+
174+
typedef SHA512_CTX SHA384_CTX;
175+
void SHA384_Init(SHA384_CTX *c);
176+
void SHA384_Update(SHA384_CTX *, const uint8_t *input, int len);
177+
void SHA384_Final(uint8_t *digest, SHA384_CTX *);
143178

144179
/**************************************************************************
145180
* MD5 declarations
@@ -203,7 +238,7 @@ void RSA_pub_key_new(RSA_CTX **rsa_ctx,
203238
const uint8_t *pub_exp, int pub_len);
204239
void RSA_free(RSA_CTX *ctx);
205240
int RSA_decrypt(const RSA_CTX *ctx, const uint8_t *in_data, uint8_t *out_data,
206-
int is_decryption);
241+
int out_len, int is_decryption);
207242
bigint *RSA_private(const RSA_CTX *c, bigint *bi_msg);
208243
#if defined(CONFIG_SSL_CERT_VERIFICATION) || defined(CONFIG_SSL_GENERATE_X509_CERT)
209244
bigint *RSA_sign_verify(BI_CTX *ctx, const uint8_t *sig, int sig_len,
@@ -220,8 +255,8 @@ void RSA_print(const RSA_CTX *ctx);
220255
EXP_FUNC void STDCALL RNG_initialize(void);
221256
EXP_FUNC void STDCALL RNG_custom_init(const uint8_t *seed_buf, int size);
222257
EXP_FUNC void STDCALL RNG_terminate(void);
223-
EXP_FUNC void STDCALL get_random(int num_rand_bytes, uint8_t *rand_data);
224-
void get_random_NZ(int num_rand_bytes, uint8_t *rand_data);
258+
EXP_FUNC int STDCALL get_random(int num_rand_bytes, uint8_t *rand_data);
259+
int get_random_NZ(int num_rand_bytes, uint8_t *rand_data);
225260

226261
#ifdef __cplusplus
227262
}

Diff for: crypto/crypto_misc.c

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2007, Cameron Rich
3-
*
2+
* Copyright (c) 2007-2015, Cameron Rich
3+
*
44
* All rights reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without
@@ -162,11 +162,12 @@ EXP_FUNC void STDCALL RNG_terminate(void)
162162
/**
163163
* Set a series of bytes with a random number. Individual bytes can be 0
164164
*/
165-
EXP_FUNC void STDCALL get_random(int num_rand_bytes, uint8_t *rand_data)
166-
{
165+
EXP_FUNC int STDCALL get_random(int num_rand_bytes, uint8_t *rand_data)
166+
{
167167
#if !defined(WIN32) && defined(CONFIG_USE_DEV_URANDOM)
168-
/* use the Linux default */
169-
read(rng_fd, rand_data, num_rand_bytes); /* read from /dev/urandom */
168+
/* use the Linux default - read from /dev/urandom */
169+
if (read(rng_fd, rand_data, num_rand_bytes) < 0)
170+
return -1;
170171
#elif defined(WIN32) && defined(CONFIG_WIN32_USE_CRYPTO_LIB)
171172
/* use Microsoft Crypto Libraries */
172173
CryptGenRandom(gCryptProv, num_rand_bytes, rand_data);
@@ -211,22 +212,26 @@ EXP_FUNC void STDCALL get_random(int num_rand_bytes, uint8_t *rand_data)
211212
/* insert the digest at the start of the entropy pool */
212213
memcpy(entropy_pool, digest, MD5_SIZE);
213214
#endif
215+
return 0;
214216
}
215217

216218
/**
217219
* Set a series of bytes with a random number. Individual bytes are not zero.
218220
*/
219-
void get_random_NZ(int num_rand_bytes, uint8_t *rand_data)
221+
int get_random_NZ(int num_rand_bytes, uint8_t *rand_data)
220222
{
221223
int i;
222-
get_random(num_rand_bytes, rand_data);
224+
if (get_random(num_rand_bytes, rand_data))
225+
return -1;
223226

224227
for (i = 0; i < num_rand_bytes; i++)
225228
{
226229
while (rand_data[i] == 0) {
227230
get_random(1, rand_data + i);
228231
}
229232
}
233+
234+
return 0;
230235
}
231236

232237
/**

Diff for: crypto/md2.c

-162
This file was deleted.

Diff for: crypto/os_int.h

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ typedef INT64 int64_t;
5656
#include <inttypes.h>
5757
#else
5858
#include <stdint.h>
59+
#include <endian.h>
5960
#endif /* Not Solaris */
6061

6162
#endif /* Not Win32 */

0 commit comments

Comments
 (0)