(no commit message)
[strongswan.git] / src / libcrypto / libsha2 / sha2.h
1 #ifndef _SHA2_H
2 #define _SHA2_H
3 /*
4 * sha512.h
5 *
6 * Written by Jari Ruusu, April 16 2001
7 *
8 * Copyright 2001 by Jari Ruusu.
9 * Redistribution of this file is permitted under the GNU Public License.
10 */
11
12 #ifdef __KERNEL__
13 #include <linux/types.h>
14 #else
15 #include <sys/types.h>
16 #endif
17
18 typedef struct {
19 unsigned char sha_out[64]; /* results are here, bytes 0...31 */
20 u_int32_t sha_H[8];
21 u_int64_t sha_blocks;
22 int sha_bufCnt;
23 } sha256_context;
24
25 typedef struct {
26 unsigned char sha_out[128]; /* results are here, bytes 0...63 */
27 u_int64_t sha_H[8];
28 u_int64_t sha_blocks;
29 u_int64_t sha_blocksMSB;
30 int sha_bufCnt;
31 } sha512_context;
32
33 /* no sha384_context, use sha512_context */
34
35 /* 256 bit hash, provides 128 bits of security against collision attacks */
36 extern void sha256_init(sha256_context *);
37 extern void sha256_write(sha256_context *, const unsigned char *, int);
38 extern void sha256_final(sha256_context *);
39 extern void sha256_hash_buffer(unsigned char *, int, unsigned char *, int);
40
41 /* 512 bit hash, provides 256 bits of security against collision attacks */
42 extern void sha512_init(sha512_context *);
43 extern void sha512_write(sha512_context *, const unsigned char *, int);
44 extern void sha512_final(sha512_context *);
45 extern void sha512_hash_buffer(unsigned char *, int, unsigned char *, int);
46
47 /* 384 bit hash, provides 192 bits of security against collision attacks */
48 extern void sha384_init(sha512_context *);
49 /* no sha384_write(), use sha512_write() */
50 /* no sha384_final(), use sha512_final(), result in ctx->sha_out[0...47] */
51 extern void sha384_hash_buffer(unsigned char *, int, unsigned char *, int);
52 #endif /* _SHA2_H */