1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1998, by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_SYS_SHA1_CONSTS_H
28 #define	_SYS_SHA1_CONSTS_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * as explained in sha1.c, loading 32-bit constants on a sparc is expensive
36  * since it involves both a `sethi' and an `or'.  thus, we instead use `ld'
37  * to load the constants from an array called `sha1_consts'.  however, on
38  * intel (and perhaps other processors), it is cheaper to load the constant
39  * directly.  thus, the c code in SHA1Transform() uses the macro SHA1_CONST()
40  * which either expands to a constant or an array reference, depending on
41  * the architecture the code is being compiled for.
42  */
43 
44 #include <sys/types.h>		/* uint32_t */
45 
46 extern	const uint32_t	sha1_consts[];
47 
48 #if	defined(__sparc)
49 #define	SHA1_CONST(x)		(sha1_consts[x])
50 #else
51 #define	SHA1_CONST(x)		(SHA1_CONST_ ## x)
52 #endif
53 
54 /* constants, as provided in FIPS 180-1 */
55 
56 #define	SHA1_CONST_0		0x5a827999U
57 #define	SHA1_CONST_1		0x6ed9eba1U
58 #define	SHA1_CONST_2		0x8f1bbcdcU
59 #define	SHA1_CONST_3		0xca62c1d6U
60 
61 #ifdef	__cplusplus
62 }
63 #endif
64 
65 #endif /* _SYS_SHA1_CONSTS_H */
66