xref: /freebsd/sys/crypto/openssl/ossl_sha.h (revision 7ef62cebc2f965b0f640263e179276928885e33d)
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  * $FreeBSD$
10  */
11 
12 #ifndef __OSSL_SHA_H__
13 #define	__OSSL_SHA_H__
14 
15 /*
16  * This is always included last which permits the namespace hacks below
17  * to work.
18  */
19 #define	SHA256_CTX	OSSL_SHA256_CTX
20 #define	SHA512_CTX	OSSL_SHA512_CTX
21 
22 /* From include/openssl/sha.h */
23 # define SHA_LONG unsigned int
24 
25 # define SHA_LBLOCK      16
26 # define SHA_CBLOCK      (SHA_LBLOCK*4)/* SHA treats input data as a
27                                         * contiguous array of 32 bit wide
28                                         * big-endian values. */
29 
30 typedef struct SHAstate_st {
31     SHA_LONG h0, h1, h2, h3, h4;
32     SHA_LONG Nl, Nh;
33     SHA_LONG data[SHA_LBLOCK];
34     unsigned int num;
35 } SHA_CTX;
36 
37 # define SHA256_CBLOCK   (SHA_LBLOCK*4)/* SHA-256 treats input data as a
38                                         * contiguous array of 32 bit wide
39                                         * big-endian values. */
40 
41 typedef struct SHA256state_st {
42     SHA_LONG h[8];
43     SHA_LONG Nl, Nh;
44     SHA_LONG data[SHA_LBLOCK];
45     unsigned int num, md_len;
46 } SHA256_CTX;
47 
48 /*
49  * SHA-512 treats input data as a
50  * contiguous array of 64 bit
51  * wide big-endian values.
52  */
53 # define SHA512_CBLOCK   (SHA_LBLOCK*8)
54 
55 #  define SHA_LONG64 unsigned long long
56 #  define U64(C)     C##ULL
57 
58 typedef struct SHA512state_st {
59     SHA_LONG64 h[8];
60     SHA_LONG64 Nl, Nh;
61     union {
62         SHA_LONG64 d[SHA_LBLOCK];
63         unsigned char p[SHA512_CBLOCK];
64     } u;
65     unsigned int num, md_len;
66 } SHA512_CTX;
67 
68 #endif /* !__OSSL_SHA_H__ */
69