sphlib

sha3nist.h

Go to the documentation of this file.
00001 /* $Id: sha3nist.h 170 2010-05-07 13:27:24Z tp $ */
00040 #ifndef SPH_SHA3NIST_H__
00041 #define SPH_SHA3NIST_H__
00042 
00043 #ifndef DOXYGEN_IGNORE
00044 
00045 /*
00046  * Here, define SPH_NIST to the base of the internal names for the
00047  * hash function. If SPH_NIST evaluates to the identifier "foo", then
00048  * the functions foo224, foo256, foo384 and foo512 will be used.
00049  */
00050 #define SPH_NIST   sha
00051 
00052 #include "sph_sha3.h"
00053 #include <limits.h>
00054 
00055 typedef unsigned char BitSequence;
00056 
00057 #ifdef ULLONG_MAX
00058 typedef unsigned long long DataLength;
00059 #else
00060 typedef unsigned long DataLength;
00061 #endif
00062 
00063 typedef enum {
00064         SUCCESS = 0,
00065         FAIL = 1,
00066         BAD_HASHBITLEN = 2
00067 } HashReturn;
00068 
00069 #define SPH_CAT(x, y)    SPH_CAT_(x, y)
00070 #define SPH_CAT_(x, y)   x ## y
00071 
00072 typedef struct {
00073         union {
00074                 SPH_CAT(SPH_CAT(sph_, SPH_NIST), 224_context) ctx224;
00075                 SPH_CAT(SPH_CAT(sph_, SPH_NIST), 256_context) ctx256;
00076                 SPH_CAT(SPH_CAT(sph_, SPH_NIST), 384_context) ctx384;
00077                 SPH_CAT(SPH_CAT(sph_, SPH_NIST), 512_context) ctx512;
00078         } u;
00079         int hashbitlen;
00080         BitSequence output[64];
00081         int output_computed;
00082 } hashState;
00083 
00084 HashReturn Init(hashState *state, int hashbitlen);
00085 
00086 HashReturn Update(hashState *state,
00087         const BitSequence *data, DataLength databitlen);
00088 
00089 HashReturn Final(hashState *state, BitSequence *hashval);
00090 
00091 HashReturn Hash(int hashbitlen, const BitSequence *data,
00092         DataLength databitlen, BitSequence *hashval);
00093 
00094 #endif
00095 
00096 #endif