OSDN Git Service

Add missing file to GETTEXT_FILES
[pg-rex/syncrep.git] / contrib / pgcrypto / sha2.h
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 /* avoid conflict with OpenSSL */
42 #define SHA256_Init pg_SHA256_Init
43 #define SHA256_Update pg_SHA256_Update
44 #define SHA256_Final pg_SHA256_Final
45 #define SHA384_Init pg_SHA384_Init
46 #define SHA384_Update pg_SHA384_Update
47 #define SHA384_Final pg_SHA384_Final
48 #define SHA512_Init pg_SHA512_Init
49 #define SHA512_Update pg_SHA512_Update
50 #define SHA512_Final pg_SHA512_Final
51
52 /*** SHA-224/256/384/512 Various Length Definitions ***********************/
53 #define SHA224_BLOCK_LENGTH             64
54 #define SHA224_DIGEST_LENGTH            28
55 #define SHA224_DIGEST_STRING_LENGTH (SHA224_DIGEST_LENGTH * 2 + 1)
56 #define SHA256_BLOCK_LENGTH             64
57 #define SHA256_DIGEST_LENGTH            32
58 #define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
59 #define SHA384_BLOCK_LENGTH             128
60 #define SHA384_DIGEST_LENGTH            48
61 #define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
62 #define SHA512_BLOCK_LENGTH             128
63 #define SHA512_DIGEST_LENGTH            64
64 #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
65
66
67 /*** SHA-256/384/512 Context Structures *******************************/
68 typedef struct _SHA256_CTX
69 {
70         uint32          state[8];
71         uint64          bitcount;
72         uint8           buffer[SHA256_BLOCK_LENGTH];
73 } SHA256_CTX;
74 typedef struct _SHA512_CTX
75 {
76         uint64          state[8];
77         uint64          bitcount[2];
78         uint8           buffer[SHA512_BLOCK_LENGTH];
79 } SHA512_CTX;
80
81 typedef SHA256_CTX SHA224_CTX;
82 typedef SHA512_CTX SHA384_CTX;
83
84 void            SHA224_Init(SHA224_CTX *);
85 void            SHA224_Update(SHA224_CTX *, const uint8 *, size_t);
86 void            SHA224_Final(uint8[SHA224_DIGEST_LENGTH], SHA224_CTX *);
87
88 void            SHA256_Init(SHA256_CTX *);
89 void            SHA256_Update(SHA256_CTX *, const uint8 *, size_t);
90 void            SHA256_Final(uint8[SHA256_DIGEST_LENGTH], SHA256_CTX *);
91
92 void            SHA384_Init(SHA384_CTX *);
93 void            SHA384_Update(SHA384_CTX *, const uint8 *, size_t);
94 void            SHA384_Final(uint8[SHA384_DIGEST_LENGTH], SHA384_CTX *);
95
96 void            SHA512_Init(SHA512_CTX *);
97 void            SHA512_Update(SHA512_CTX *, const uint8 *, size_t);
98 void            SHA512_Final(uint8[SHA512_DIGEST_LENGTH], SHA512_CTX *);
99
100 #endif   /* _SHA2_H */