xref: /titanic_51/usr/src/uts/common/sys/sha1_consts.h (revision ee5416c9d7e449233197d5d20bc6b81e4ff091b2)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * as explained in sha1.c, loading 32-bit constants on a sparc is expensive
38  * since it involves both a `sethi' and an `or'.  thus, we instead use `ld'
39  * to load the constants from an array called `sha1_consts'.  however, on
40  * intel (and perhaps other processors), it is cheaper to load the constant
41  * directly.  thus, the c code in SHA1Transform() uses the macro SHA1_CONST()
42  * which either expands to a constant or an array reference, depending on
43  * the architecture the code is being compiled for.
44  */
45 
46 #include <sys/types.h>		/* uint32_t */
47 
48 extern	const uint32_t	sha1_consts[];
49 
50 #if	defined(__sparc)
51 #define	SHA1_CONST(x)		(sha1_consts[x])
52 #else
53 #define	SHA1_CONST(x)		(SHA1_CONST_ ## x)
54 #endif
55 
56 /* constants, as provided in FIPS 180-1 */
57 
58 #define	SHA1_CONST_0		0x5a827999U
59 #define	SHA1_CONST_1		0x6ed9eba1U
60 #define	SHA1_CONST_2		0x8f1bbcdcU
61 #define	SHA1_CONST_3		0xca62c1d6U
62 
63 #ifdef	__cplusplus
64 }
65 #endif
66 
67 #endif /* _SYS_SHA1_CONSTS_H */
68