xref: /freebsd/sys/crypto/openssl/ossl_sha.h (revision a90b9d0159070121c221b966469c3e36d912bf82)
1 /*
2  * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL license (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9 
10 #ifndef __OSSL_SHA_H__
11 #define	__OSSL_SHA_H__
12 
13 /*
14  * This is always included last which permits the namespace hacks below
15  * to work.
16  */
17 #define	SHA256_CTX	OSSL_SHA256_CTX
18 #define	SHA512_CTX	OSSL_SHA512_CTX
19 
20 /* From include/openssl/sha.h */
21 # define SHA_LONG unsigned int
22 
23 # define SHA_LBLOCK      16
24 # define SHA_CBLOCK      (SHA_LBLOCK*4)/* SHA treats input data as a
25                                         * contiguous array of 32 bit wide
26                                         * big-endian values. */
27 
28 typedef struct SHAstate_st {
29     SHA_LONG h0, h1, h2, h3, h4;
30     SHA_LONG Nl, Nh;
31     SHA_LONG data[SHA_LBLOCK];
32     unsigned int num;
33 } SHA_CTX;
34 
35 # define SHA256_CBLOCK   (SHA_LBLOCK*4)/* SHA-256 treats input data as a
36                                         * contiguous array of 32 bit wide
37                                         * big-endian values. */
38 
39 typedef struct SHA256state_st {
40     SHA_LONG h[8];
41     SHA_LONG Nl, Nh;
42     SHA_LONG data[SHA_LBLOCK];
43     unsigned int num, md_len;
44 } SHA256_CTX;
45 
46 /*
47  * SHA-512 treats input data as a
48  * contiguous array of 64 bit
49  * wide big-endian values.
50  */
51 # define SHA512_CBLOCK   (SHA_LBLOCK*8)
52 
53 #  define SHA_LONG64 unsigned long long
54 #  define U64(C)     C##ULL
55 
56 typedef struct SHA512state_st {
57     SHA_LONG64 h[8];
58     SHA_LONG64 Nl, Nh;
59     union {
60         SHA_LONG64 d[SHA_LBLOCK];
61         unsigned char p[SHA512_CBLOCK];
62     } u;
63     unsigned int num, md_len;
64 } SHA512_CTX;
65 
66 #endif /* !__OSSL_SHA_H__ */
67