Merge illumos-gate
[unleashed.git] / include / sys / sha1_consts.h
blob848d25ef050f59eb39c7f25e4d8a6a387734ba53
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 #ifdef __cplusplus
31 extern "C" {
32 #endif
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.
44 #include <sys/types.h> /* uint32_t */
46 extern const uint32_t sha1_consts[];
48 #if defined(__sparc)
49 #define SHA1_CONST(x) (sha1_consts[x])
50 #else
51 #define SHA1_CONST(x) (SHA1_CONST_ ## x)
52 #endif
54 /* constants, as provided in FIPS 180-1 */
56 #define SHA1_CONST_0 0x5a827999U
57 #define SHA1_CONST_1 0x6ed9eba1U
58 #define SHA1_CONST_2 0x8f1bbcdcU
59 #define SHA1_CONST_3 0xca62c1d6U
61 #ifdef __cplusplus
63 #endif
65 #endif /* _SYS_SHA1_CONSTS_H */