1 // Copyright 2007 Google Inc. All Rights Reserved. 2 // Author: mschilder (at) google.com (Marius Schilder) 3 4 #ifndef SECURITY_UTIL_LITE_HASH_INTERNAL_H__ 5 #define SECURITY_UTIL_LITE_HASH_INTERNAL_H__ 6 7 #include <stdint.h> 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif // __cplusplus 12 13 struct HASH_CTX; // forward decl 14 15 typedef struct HASH_VTAB { 16 void (* const init)(struct HASH_CTX*); 17 void (* const update)(struct HASH_CTX*, const void*, int); 18 const uint8_t* (* const final)(struct HASH_CTX*); 19 const uint8_t* (* const hash)(const void*, int, uint8_t*); 20 int size; 21 } HASH_VTAB; 22 23 typedef struct HASH_CTX { 24 const HASH_VTAB * f; 25 uint64_t count; 26 uint8_t buf[64]; 27 uint32_t state[8]; // upto SHA2 28 } HASH_CTX; 29 30 #define HASH_init(ctx) (ctx)->f->init(ctx) 31 #define HASH_update(ctx, data, len) (ctx)->f->update(ctx, data, len) 32 #define HASH_final(ctx) (ctx)->f->final(ctx) 33 #define HASH_hash(data, len, digest) (ctx)->f->hash(data, len, digest) 34 #define HASH_size(ctx) (ctx)->f->size 35 36 #ifdef __cplusplus 37 } 38 #endif // __cplusplus 39 40 #endif // SECURITY_UTIL_LITE_HASH_INTERNAL_H__ 41