Doxygen Generated Documentation of Ben-Jose Trainable SAT Solver Library
sha2.h
Go to the documentation of this file.
1 
2 /*************************************************************
3 
4 ben-jose
5 
6 sha2.h
7 
8 sha2 hash func spec.
9 
10 --------------------------------------------------------------*/
11 
12 /*
13  * FIPS-180-2 compliant SHA-256 implementation
14  *
15  * Copyright (C) 2006-2007 Christophe Devine
16  *
17  * This library is free software; you can redistribute it and/or
18  * modify it under the terms of the GNU Lesser General Public
19  * License, version 2.1 as published by the Free Software Foundation.
20  *
21  * This library is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24  * Lesser General Public License for more details.
25  *
26  * You should have received a copy of the GNU Lesser General Public
27  * License along with this library; if not, write to the Free Software
28  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
29  * MA 02110-1301 USA
30  */
31 /*
32  * The SHA-256 Secure Hash Standard was published by NIST in 2002.
33  *
34  * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf
35  */
36 
40 #ifndef _SHA2_H
41 #define _SHA2_H
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 #define NUM_BYTES_SHA2 32 /* 256 bits */
48 
52 typedef struct
53 {
54  unsigned long total[2];
55  unsigned long state[8];
56  unsigned char buffer[64];
57  unsigned char ipad[64];
58  unsigned char opad[64];
59  int is224;
60 }
62 
69 void sha2_starts( sha2_context *ctx, int is224 );
70 
78 void sha2_update( sha2_context *ctx, unsigned char *input, int ilen );
79 
86 void sha2_finish( sha2_context *ctx, unsigned char *output );
87 
96 void sha2( unsigned char *input, int ilen,
97  unsigned char *output, int is224 );
98 
110 /*int sha2_file( char *path, unsigned char *output, int is224 );
111  */
112 
121 void sha2_hmac_starts( sha2_context *ctx, int is224,
122  unsigned char *key, int keylen );
123 
131 void sha2_hmac_update( sha2_context *ctx,
132  unsigned char *input, int ilen );
133 
140 void sha2_hmac_finish( sha2_context *ctx, unsigned char *output );
141 
152 void sha2_hmac( unsigned char *key, int keylen,
153  unsigned char *input, int ilen,
154  unsigned char *output, int is224 );
155 
161 int sha2_self_test( int verbose );
162 
163 #ifdef __cplusplus
164 }
165 #endif
166 
167 #endif /* sha2.h */
168 
169 
170 
void sha2(unsigned char *input, int ilen, unsigned char *output, int is224)
Output = SHA-256( input buffer )
Definition: sha2.cpp:323
SHA-256 context structure.
Definition: sha2.h:52
void sha2_update(sha2_context *ctx, unsigned char *input, int ilen)
SHA-256 process buffer.
Definition: sha2.cpp:237
void sha2_finish(sha2_context *ctx, unsigned char *output)
SHA-256 final digest.
Definition: sha2.cpp:289
void sha2_hmac_update(sha2_context *ctx, unsigned char *input, int ilen)
SHA-256 HMAC process buffer.
Definition: sha2.cpp:396
void sha2_hmac_starts(sha2_context *ctx, int is224, unsigned char *key, int keylen)
Output = SHA-256( file contents )
Definition: sha2.cpp:373
int sha2_self_test(int verbose)
Checkup routine.
Definition: sha2.cpp:538
void sha2_hmac(unsigned char *key, int keylen, unsigned char *input, int ilen, unsigned char *output, int is224)
Output = HMAC-SHA-256( hmac key, input buffer )
Definition: sha2.cpp:425
int is224
Definition: sha2.h:59
void sha2_hmac_finish(sha2_context *ctx, unsigned char *output)
SHA-256 HMAC final digest.
Definition: sha2.cpp:405
void sha2_starts(sha2_context *ctx, int is224)
SHA-256 context setup.
Definition: sha2.cpp:70