libfortuna  1
FortunalibraryfunctionsextractedfromPostgreSQLsource
 All Data Structures Files Functions Variables Typedefs Macros
sha2.h
Go to the documentation of this file.
1 /* contrib/pgcrypto/sha2.h */
2 /* $OpenBSD: sha2.h,v 1.2 2004/04/28 23:11:57 millert Exp $ */
3 
4 /*
5  * FILE: sha2.h
6  * AUTHOR: Aaron D. Gifford <me@aarongifford.com>
7  *
8  * Copyright (c) 2000-2001, Aaron D. Gifford
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in the
18  * documentation and/or other materials provided with the distribution.
19  * 3. Neither the name of the copyright holder nor the names of contributors
20  * may be used to endorse or promote products derived from this software
21  * without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  * $From: sha2.h,v 1.1 2001/11/08 00:02:01 adg Exp adg $
36  */
37 
38 #ifndef _SHA2_H
39 #define _SHA2_H
40 
41 #include "c.h"
42 
43 /* avoid conflict with OpenSSL */
44 #define SHA256_Init pg_SHA256_Init
45 #define SHA256_Update pg_SHA256_Update
46 #define SHA256_Final pg_SHA256_Final
47 #define SHA384_Init pg_SHA384_Init
48 #define SHA384_Update pg_SHA384_Update
49 #define SHA384_Final pg_SHA384_Final
50 #define SHA512_Init pg_SHA512_Init
51 #define SHA512_Update pg_SHA512_Update
52 #define SHA512_Final pg_SHA512_Final
53 
54 /*** SHA-224/256/384/512 Various Length Definitions ***********************/
55 #define SHA224_BLOCK_LENGTH 64
56 #define SHA224_DIGEST_LENGTH 28
57 #define SHA224_DIGEST_STRING_LENGTH (SHA224_DIGEST_LENGTH * 2 + 1)
58 #define SHA256_BLOCK_LENGTH 64
59 #define SHA256_DIGEST_LENGTH 32
60 #define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
61 #define SHA384_BLOCK_LENGTH 128
62 #define SHA384_DIGEST_LENGTH 48
63 #define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
64 #define SHA512_BLOCK_LENGTH 128
65 #define SHA512_DIGEST_LENGTH 64
66 #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
67 
68 
69 /*** SHA-256/384/512 Context Structures *******************************/
70 typedef struct _SHA256_CTX
71 {
75 } SHA256_CTX;
76 typedef struct _SHA512_CTX
77 {
81 } SHA512_CTX;
82 
85 
86 void SHA224_Init(SHA224_CTX *);
87 void SHA224_Update(SHA224_CTX *, const uint8 *, size_t);
89 
90 void SHA256_Init(SHA256_CTX *);
91 void SHA256_Update(SHA256_CTX *, const uint8 *, size_t);
93 
94 void SHA384_Init(SHA384_CTX *);
95 void SHA384_Update(SHA384_CTX *, const uint8 *, size_t);
97 
98 void SHA512_Init(SHA512_CTX *);
99 void SHA512_Update(SHA512_CTX *, const uint8 *, size_t);
101 
102 #endif /* _SHA2_H */