Merge commit '7e3488dc6cdcb0c04e1ce167a1a3bfef83b5f2e0'
[unleashed.git] / include / sys / sha1_consts.h
blob3a1491b86f8b8405fe05d1380da57ef3a2ca1c2b
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright (c) 1998, by Sun Microsystems, Inc.
24 * All rights reserved.
27 #ifndef _SYS_SHA1_CONSTS_H
28 #define _SYS_SHA1_CONSTS_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
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.
46 #include <sys/types.h> /* uint32_t */
48 extern const uint32_t sha1_consts[];
50 #if defined(__sparc)
51 #define SHA1_CONST(x) (sha1_consts[x])
52 #else
53 #define SHA1_CONST(x) (SHA1_CONST_ ## x)
54 #endif
56 /* constants, as provided in FIPS 180-1 */
58 #define SHA1_CONST_0 0x5a827999U
59 #define SHA1_CONST_1 0x6ed9eba1U
60 #define SHA1_CONST_2 0x8f1bbcdcU
61 #define SHA1_CONST_3 0xca62c1d6U
63 #ifdef __cplusplus
65 #endif
67 #endif /* _SYS_SHA1_CONSTS_H */