sphlib

sph_sha2.h

Go to the documentation of this file.
00001 /* $Id: sph_sha2.h 216 2010-06-08 09:46:57Z tp $ */
00040 #ifndef SPH_SHA2_H__
00041 #define SPH_SHA2_H__
00042 
00043 #include <stddef.h>
00044 #include "sph_types.h"
00045 
00049 #define SPH_SIZE_sha224   224
00050 
00054 #define SPH_SIZE_sha256   256
00055 
00066 typedef struct {
00067 #ifndef DOXYGEN_IGNORE
00068         unsigned char buf[64];    /* first field, for alignment */
00069         sph_u32 val[8];
00070 #if SPH_64
00071         sph_u64 count;
00072 #else
00073         sph_u32 count_high, count_low;
00074 #endif
00075 #endif
00076 } sph_sha224_context;
00077 
00084 typedef sph_sha224_context sph_sha256_context;
00085 
00092 void sph_sha224_init(void *cc);
00093 
00102 void sph_sha224(void *cc, const void *data, size_t len);
00103 
00113 void sph_sha224_close(void *cc, void *dst);
00114 
00128 void sph_sha224_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst);
00129 
00141 void sph_sha224_comp(const sph_u32 msg[16], sph_u32 val[8]);
00142 
00149 void sph_sha256_init(void *cc);
00150 
00151 #ifdef DOXYGEN_IGNORE
00152 
00160 void sph_sha256(void *cc, const void *data, size_t len);
00161 #endif
00162 
00163 #ifndef DOXYGEN_IGNORE
00164 #define sph_sha256   sph_sha224
00165 #endif
00166 
00176 void sph_sha256_close(void *cc, void *dst);
00177 
00191 void sph_sha256_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst);
00192 
00193 #ifdef DOXYGEN_IGNORE
00194 
00201 void sph_sha256_comp(const sph_u32 msg[16], sph_u32 val[8]);
00202 #endif
00203 
00204 #ifndef DOXYGEN_IGNORE
00205 #define sph_sha256_comp   sph_sha224_comp
00206 #endif
00207 
00208 #if SPH_64
00209 
00213 #define SPH_SIZE_sha384   384
00214 
00218 #define SPH_SIZE_sha512   512
00219 
00230 typedef struct {
00231 #ifndef DOXYGEN_IGNORE
00232         unsigned char buf[128];    /* first field, for alignment */
00233         sph_u64 val[8];
00234         sph_u64 count;
00235 #endif
00236 } sph_sha384_context;
00237 
00244 void sph_sha384_init(void *cc);
00245 
00254 void sph_sha384(void *cc, const void *data, size_t len);
00255 
00265 void sph_sha384_close(void *cc, void *dst);
00266 
00280 void sph_sha384_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst);
00281 
00293 void sph_sha384_comp(const sph_u64 msg[16], sph_u64 val[8]);
00294 
00301 typedef sph_sha384_context sph_sha512_context;
00302 
00309 void sph_sha512_init(void *cc);
00310 
00311 #ifdef DOXYGEN_IGNORE
00312 
00320 void sph_sha512(void *cc, const void *data, size_t len);
00321 #endif
00322 
00323 #ifndef DOXYGEN_IGNORE
00324 #define sph_sha512   sph_sha384
00325 #endif
00326 
00336 void sph_sha512_close(void *cc, void *dst);
00337 
00351 void sph_sha512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst);
00352 
00353 #ifdef DOXYGEN_IGNORE
00354 
00361 void sph_sha512_comp(const sph_u64 msg[16], sph_u64 val[8]);
00362 #endif
00363 
00364 #ifndef DOXYGEN_IGNORE
00365 #define sph_sha512_comp   sph_sha384_comp
00366 #endif
00367 
00368 #endif
00369 
00370 #endif