Raven Core  3.0.0
P2P Digital Currency
sph_sha2.h
Go to the documentation of this file.
1 /* $Id: sph_sha2.h 216 2010-06-08 09:46:57Z tp $ */
40 #ifndef SPH_SHA2_H__
41 #define SPH_SHA2_H__
42 
43 #include <stddef.h>
44 #include "sph_types.h"
45 
46 #ifdef __cplusplus
47 extern "C"{
48 #endif
49 
53 #define SPH_SIZE_sha224 224
54 
58 #define SPH_SIZE_sha256 256
59 
70 typedef struct {
71 #ifndef DOXYGEN_IGNORE
72  unsigned char buf[64]; /* first field, for alignment */
73  sph_u32 val[8];
74 #if SPH_64
75  sph_u64 count;
76 #else
77  sph_u32 count_high, count_low;
78 #endif
79 #endif
81 
89 
96 void sph_sha224_init(void *cc);
97 
106 void sph_sha224(void *cc, const void *data, size_t len);
107 
117 void sph_sha224_close(void *cc, void *dst);
118 
132 void sph_sha224_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst);
133 
145 void sph_sha224_comp(const sph_u32 msg[16], sph_u32 val[8]);
146 
153 void sph_sha256_init(void *cc);
154 
155 #ifdef DOXYGEN_IGNORE
156 
164 void sph_sha256(void *cc, const void *data, size_t len);
165 #endif
166 
167 #ifndef DOXYGEN_IGNORE
168 #define sph_sha256 sph_sha224
169 #endif
170 
180 void sph_sha256_close(void *cc, void *dst);
181 
195 void sph_sha256_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst);
196 
197 #ifdef DOXYGEN_IGNORE
198 
205 void sph_sha256_comp(const sph_u32 msg[16], sph_u32 val[8]);
206 #endif
207 
208 #ifndef DOXYGEN_IGNORE
209 #define sph_sha256_comp sph_sha224_comp
210 #endif
211 
212 #if SPH_64
213 
217 #define SPH_SIZE_sha384 384
218 
222 #define SPH_SIZE_sha512 512
223 
234 typedef struct {
235 #ifndef DOXYGEN_IGNORE
236  unsigned char buf[128]; /* first field, for alignment */
237  sph_u64 val[8];
238  sph_u64 count;
239 #endif
240 } sph_sha384_context;
241 
248 void sph_sha384_init(void *cc);
249 
258 void sph_sha384(void *cc, const void *data, size_t len);
259 
269 void sph_sha384_close(void *cc, void *dst);
270 
284 void sph_sha384_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst);
285 
297 void sph_sha384_comp(const sph_u64 msg[16], sph_u64 val[8]);
298 
305 typedef sph_sha384_context sph_sha512_context;
306 
313 void sph_sha512_init(void *cc);
314 
315 #ifdef DOXYGEN_IGNORE
316 
324 void sph_sha512(void *cc, const void *data, size_t len);
325 #endif
326 
327 #ifndef DOXYGEN_IGNORE
328 #define sph_sha512 sph_sha384
329 #endif
330 
340 void sph_sha512_close(void *cc, void *dst);
341 
355 void sph_sha512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst);
356 
357 #ifdef DOXYGEN_IGNORE
358 
365 void sph_sha512_comp(const sph_u64 msg[16], sph_u64 val[8]);
366 #endif
367 
368 #ifndef DOXYGEN_IGNORE
369 #define sph_sha512_comp sph_sha384_comp
370 #endif
371 
372 #endif
373 
374 #endif
375 #ifdef __cplusplus
376 }
377 #endif
378 
sph_u32 count_low
Definition: sph_sha2.h:77
Basic type definitions.
void sph_sha224_comp(const sph_u32 msg[16], sph_u32 val[8])
Apply the SHA-224 compression function on the provided data.
Definition: sph_sha2.c:692
void sph_sha256_close(void *cc, void *dst)
Terminate the current SHA-256 computation and output the result into the provided buffer...
Definition: sph_sha2.c:676
void sph_sha256_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst)
Add a few additional bits (0 to 7) to the current computation, then terminate it and output the resul...
Definition: sph_sha2.c:684
void sph_sha224(void *cc, const void *data, size_t len)
Process some data bytes.
sph_sha224_context sph_sha256_context
This structure is a context for SHA-256 computations.
Definition: sph_sha2.h:88
#define sph_sha256_comp
Definition: sph_sha2.h:209
#define sph_sha256
Definition: sph_sha2.h:168
This structure is a context for SHA-224 computations: it contains the intermediate values and some da...
Definition: sph_sha2.h:70
void sph_sha224_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst)
Add a few additional bits (0 to 7) to the current computation, then terminate it and output the resul...
Definition: sph_sha2.c:668
void sph_sha224_close(void *cc, void *dst)
Terminate the current SHA-224 computation and output the result into the provided buffer...
Definition: sph_sha2.c:660
unsigned long sph_u32
Definition: sph_types.h:870
void sph_sha224_init(void *cc)
Initialize a SHA-224 context.
Definition: sph_sha2.c:625
void sph_sha256_init(void *cc)
Initialize a SHA-256 context.
Definition: sph_sha2.c:640