InChI
 
Loading...
Searching...
No Matches
sha2.h
Go to the documentation of this file.
1/*
2 *
3 * FIPS-180-2 compliant SHA-256 implementation
4 * Copyright (C) 2010 Paul Bakker.
5 * Originally written (2003-2006) by Christophe Devine.
6 *
7 * This code is free software; you can redistribute it and/or
8 * modify it, as a part of the International Chemical Identifier (InChI)
9 * software, under the terms of the MIT license
10 * https://opensource.org/license/mit
11 *
12 * Note that this licensing is only valid in combination with the InChI
13 * software package, for all other cases contact Paul Bakker.
14 */
15
16/*
17 * The SHA-256 standard was published by NIST in 2002.
18 *
19 * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf
20 */
21
22
23#ifndef _SHA2_H_
24#define _SHA2_H_
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
33 typedef struct
34 {
35 unsigned long total[2];
36 unsigned long state[8];
37 unsigned char buffer[64];
38 }
40
46 void sha2_starts( sha2_context *ctx );
47
55 void sha2_update( sha2_context *ctx, unsigned char *input, int ilen );
56
63 void sha2_finish( sha2_context *ctx, unsigned char output[32] );
64
72 void sha2_csum( unsigned char *input, int ilen,
73 unsigned char output[32] );
74
82 int sha2_file( char *path, unsigned char output[32] );
83
93 void sha2_hmac( unsigned char *key, int keylen,
94 unsigned char *input, int ilen,
95 unsigned char output[32] );
96
102 int sha2_self_test( void );
103
104#ifdef __cplusplus
105}
106#endif
107
108
109#endif /* _SHA2_H_ */
110
void sha2_finish(sha2_context *ctx, unsigned char output[32])
SHA-256 final digest.
Definition sha2.c:257
void sha2_hmac(unsigned char *key, int keylen, unsigned char *input, int ilen, unsigned char output[32])
Output = HMAC-SHA-256( input buffer, hmac key )
Definition sha2.c:325
int sha2_file(char *path, unsigned char output[32])
Output = SHA-256( file contents )
Definition sha2.c:288
int sha2_self_test(void)
Checkup routine.
Definition sha2.c:429
void sha2_starts(sha2_context *ctx)
SHA-256 context setup.
Definition sha2.c:57
void sha2_update(sha2_context *ctx, unsigned char *input, int ilen)
SHA-256 process buffer.
Definition sha2.c:206
void sha2_csum(unsigned char *input, int ilen, unsigned char output[32])
Output = SHA-256( input buffer )
Definition sha2.c:312
SHA-256 context structure.
Definition sha2.h:34