PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 /* 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 {
71  uint64 bitcount;
73 } SHA256_CTX;
74 typedef struct _SHA512_CTX
75 {
76  uint64 state[8];
77  uint64 bitcount[2];
79 } SHA512_CTX;
80 
83 
84 void SHA224_Init(SHA224_CTX *);
85 void SHA224_Update(SHA224_CTX *, const uint8 *, size_t);
87 
88 void SHA256_Init(SHA256_CTX *);
89 void SHA256_Update(SHA256_CTX *, const uint8 *, size_t);
91 
92 void SHA384_Init(SHA384_CTX *);
93 void SHA384_Update(SHA384_CTX *, const uint8 *, size_t);
95 
96 void SHA512_Init(SHA512_CTX *);
97 void SHA512_Update(SHA512_CTX *, const uint8 *, size_t);
99 
100 #endif /* _SHA2_H */
#define SHA384_Final
Definition: sha2.h:47
void SHA224_Update(SHA224_CTX *, const uint8 *, size_t)
Definition: sha2.c:963
void SHA224_Final(uint8[SHA224_DIGEST_LENGTH], SHA224_CTX *)
void SHA224_Init(SHA224_CTX *)
Definition: sha2.c:953
unsigned char uint8
Definition: c.h:263
#define SHA256_BLOCK_LENGTH
Definition: sha2.h:56
#define SHA512_Update
Definition: sha2.h:49
struct _SHA512_CTX SHA512_CTX
#define SHA256_Final
Definition: sha2.h:44
uint8 buffer[SHA512_BLOCK_LENGTH]
Definition: sha2.h:78
struct _SHA256_CTX SHA256_CTX
#define SHA512_Final
Definition: sha2.h:50
uint8 buffer[SHA256_BLOCK_LENGTH]
Definition: sha2.h:72
#define SHA384_Update
Definition: sha2.h:46
SHA256_CTX SHA224_CTX
Definition: sha2.h:81
#define SHA384_DIGEST_LENGTH
Definition: sha2.h:60
unsigned int uint32
Definition: c.h:265
#define SHA256_Init
Definition: sha2.h:42
#define SHA384_Init
Definition: sha2.h:45
SHA512_CTX SHA384_CTX
Definition: sha2.h:82
uint64 bitcount[2]
Definition: sha2.h:77
#define SHA256_DIGEST_LENGTH
Definition: sha2.h:57
Definition: regguts.h:298
#define SHA512_Init
Definition: sha2.h:48
#define SHA256_Update
Definition: sha2.h:43
uint64 bitcount
Definition: sha2.h:71
#define SHA512_DIGEST_LENGTH
Definition: sha2.h:63
#define SHA512_BLOCK_LENGTH
Definition: sha2.h:62
#define SHA224_DIGEST_LENGTH
Definition: sha2.h:54