1
1
/*
2
- * Copyright (c) 2007, Cameron Rich
2
+ * Copyright (c) 2007-2015 , Cameron Rich
3
3
*
4
4
* All rights reserved.
5
5
*
39
39
extern "C" {
40
40
#endif
41
41
42
- #include "config.h"
43
42
#include "bigint_impl.h"
44
43
#include "bigint.h"
45
44
@@ -124,22 +123,58 @@ void SHA1_Update(SHA1_CTX *, const uint8_t * msg, int len);
124
123
void SHA1_Final (uint8_t * digest , SHA1_CTX * );
125
124
126
125
/**************************************************************************
127
- * MD2 declarations
126
+ * SHA256 declarations
128
127
**************************************************************************/
129
128
130
- #define MD2_SIZE 16
129
+ #define SHA256_SIZE 32
131
130
132
131
typedef struct
133
132
{
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 ;
139
137
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 * );
143
178
144
179
/**************************************************************************
145
180
* MD5 declarations
@@ -203,7 +238,7 @@ void RSA_pub_key_new(RSA_CTX **rsa_ctx,
203
238
const uint8_t * pub_exp , int pub_len );
204
239
void RSA_free (RSA_CTX * ctx );
205
240
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 );
207
242
bigint * RSA_private (const RSA_CTX * c , bigint * bi_msg );
208
243
#if defined(CONFIG_SSL_CERT_VERIFICATION ) || defined(CONFIG_SSL_GENERATE_X509_CERT )
209
244
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);
220
255
EXP_FUNC void STDCALL RNG_initialize (void );
221
256
EXP_FUNC void STDCALL RNG_custom_init (const uint8_t * seed_buf , int size );
222
257
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 );
225
260
226
261
#ifdef __cplusplus
227
262
}
0 commit comments