1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 // Stripped down version of security/nss/lib/freebl/blapi.h 6 // and related headers. 7 8 #ifndef _SHA256_H_ 9 #define _SHA256_H_ 10 11 #define SHA256_LENGTH 32 12 13 #include "prtypes.h" /* for PRUintXX */ 14 #include "prlong.h" 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 struct SHA256Context { 21 union { 22 PRUint32 w[64]; /* message schedule, input buffer, plus 48 words */ 23 PRUint8 b[256]; 24 } u; 25 PRUint32 h[8]; /* 8 state variables */ 26 PRUint32 sizeHi,sizeLo; /* 64-bit count of hashed bytes. */ 27 }; 28 29 typedef struct SHA256Context SHA256Context; 30 31 extern void 32 SHA256_Begin(SHA256Context *ctx); 33 34 extern void 35 SHA256_Update(SHA256Context *ctx, const unsigned char *input, 36 unsigned int inputLen); 37 38 extern void 39 SHA256_End(SHA256Context *ctx, unsigned char *digest, 40 unsigned int *digestLen, unsigned int maxDigestLen); 41 42 #ifdef __cplusplus 43 } /* extern C */ 44 #endif 45 46 #endif /* _SHA256_H_ */ 47