xref: /titanic_51/usr/src/uts/common/sys/sha2_consts.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_SHA2_CONSTS_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_SHA2_CONSTS_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate /*
37*7c478bd9Sstevel@tonic-gate  * Loading 32-bit constants on a sparc is expensive since it involves both
38*7c478bd9Sstevel@tonic-gate  * a `sethi' and an `or'.  thus, we instead use `ld' to load the constants
39*7c478bd9Sstevel@tonic-gate  * from an array called `sha2_consts'.  however, on intel (and perhaps other
40*7c478bd9Sstevel@tonic-gate  * processors), it is cheaper to load the constant directly.  thus, the c
41*7c478bd9Sstevel@tonic-gate  * code in SHA transform functions uses the macro SHA2_CONST() which either
42*7c478bd9Sstevel@tonic-gate  * expands to a constant or an array reference, depending on
43*7c478bd9Sstevel@tonic-gate  * the architecture the code is being compiled for.
44*7c478bd9Sstevel@tonic-gate  *
45*7c478bd9Sstevel@tonic-gate  * SHA512 constants are used for SHA384
46*7c478bd9Sstevel@tonic-gate  */
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate #include <sys/types.h>		/* uint32_t */
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate extern	const uint32_t	sha256_consts[];
51*7c478bd9Sstevel@tonic-gate extern	const uint64_t	sha512_consts[];
52*7c478bd9Sstevel@tonic-gate 
53*7c478bd9Sstevel@tonic-gate #if	defined(__sparc)
54*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST(x)		(sha256_consts[x])
55*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST(x)		(sha512_consts[x])
56*7c478bd9Sstevel@tonic-gate #else
57*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST(x)		(SHA256_CONST_ ## x)
58*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST(x)		(SHA512_CONST_ ## x)
59*7c478bd9Sstevel@tonic-gate #endif
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate /* constants, as provided in FIPS 180-2 */
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_0		0x428a2f98U
64*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_1		0x71374491U
65*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_2		0xb5c0fbcfU
66*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_3		0xe9b5dba5U
67*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_4		0x3956c25bU
68*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_5		0x59f111f1U
69*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_6		0x923f82a4U
70*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_7		0xab1c5ed5U
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_8		0xd807aa98U
73*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_9		0x12835b01U
74*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_10		0x243185beU
75*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_11		0x550c7dc3U
76*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_12		0x72be5d74U
77*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_13		0x80deb1feU
78*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_14		0x9bdc06a7U
79*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_15		0xc19bf174U
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_16		0xe49b69c1U
82*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_17		0xefbe4786U
83*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_18		0x0fc19dc6U
84*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_19		0x240ca1ccU
85*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_20		0x2de92c6fU
86*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_21		0x4a7484aaU
87*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_22		0x5cb0a9dcU
88*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_23		0x76f988daU
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_24		0x983e5152U
91*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_25		0xa831c66dU
92*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_26		0xb00327c8U
93*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_27		0xbf597fc7U
94*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_28		0xc6e00bf3U
95*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_29		0xd5a79147U
96*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_30		0x06ca6351U
97*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_31		0x14292967U
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_32		0x27b70a85U
100*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_33		0x2e1b2138U
101*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_34		0x4d2c6dfcU
102*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_35		0x53380d13U
103*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_36		0x650a7354U
104*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_37		0x766a0abbU
105*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_38		0x81c2c92eU
106*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_39		0x92722c85U
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_40		0xa2bfe8a1U
109*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_41		0xa81a664bU
110*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_42		0xc24b8b70U
111*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_43		0xc76c51a3U
112*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_44		0xd192e819U
113*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_45		0xd6990624U
114*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_46		0xf40e3585U
115*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_47		0x106aa070U
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_48		0x19a4c116U
118*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_49		0x1e376c08U
119*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_50		0x2748774cU
120*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_51		0x34b0bcb5U
121*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_52		0x391c0cb3U
122*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_53		0x4ed8aa4aU
123*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_54		0x5b9cca4fU
124*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_55		0x682e6ff3U
125*7c478bd9Sstevel@tonic-gate 
126*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_56		0x748f82eeU
127*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_57		0x78a5636fU
128*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_58		0x84c87814U
129*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_59		0x8cc70208U
130*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_60		0x90befffaU
131*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_61		0xa4506cebU
132*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_62		0xbef9a3f7U
133*7c478bd9Sstevel@tonic-gate #define	SHA256_CONST_63		0xc67178f2U
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_0		0x428a2f98d728ae22ULL
136*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_1		0x7137449123ef65cdULL
137*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_2		0xb5c0fbcfec4d3b2fULL
138*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_3		0xe9b5dba58189dbbcULL
139*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_4		0x3956c25bf348b538ULL
140*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_5		0x59f111f1b605d019ULL
141*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_6		0x923f82a4af194f9bULL
142*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_7		0xab1c5ed5da6d8118ULL
143*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_8		0xd807aa98a3030242ULL
144*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_9		0x12835b0145706fbeULL
145*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_10		0x243185be4ee4b28cULL
146*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_11		0x550c7dc3d5ffb4e2ULL
147*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_12		0x72be5d74f27b896fULL
148*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_13		0x80deb1fe3b1696b1ULL
149*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_14		0x9bdc06a725c71235ULL
150*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_15		0xc19bf174cf692694ULL
151*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_16		0xe49b69c19ef14ad2ULL
152*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_17		0xefbe4786384f25e3ULL
153*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_18		0x0fc19dc68b8cd5b5ULL
154*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_19		0x240ca1cc77ac9c65ULL
155*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_20		0x2de92c6f592b0275ULL
156*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_21		0x4a7484aa6ea6e483ULL
157*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_22		0x5cb0a9dcbd41fbd4ULL
158*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_23		0x76f988da831153b5ULL
159*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_24		0x983e5152ee66dfabULL
160*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_25		0xa831c66d2db43210ULL
161*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_26		0xb00327c898fb213fULL
162*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_27		0xbf597fc7beef0ee4ULL
163*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_28		0xc6e00bf33da88fc2ULL
164*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_29		0xd5a79147930aa725ULL
165*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_30		0x06ca6351e003826fULL
166*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_31		0x142929670a0e6e70ULL
167*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_32		0x27b70a8546d22ffcULL
168*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_33		0x2e1b21385c26c926ULL
169*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_34		0x4d2c6dfc5ac42aedULL
170*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_35		0x53380d139d95b3dfULL
171*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_36		0x650a73548baf63deULL
172*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_37		0x766a0abb3c77b2a8ULL
173*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_38		0x81c2c92e47edaee6ULL
174*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_39		0x92722c851482353bULL
175*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_40		0xa2bfe8a14cf10364ULL
176*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_41		0xa81a664bbc423001ULL
177*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_42		0xc24b8b70d0f89791ULL
178*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_43		0xc76c51a30654be30ULL
179*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_44		0xd192e819d6ef5218ULL
180*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_45		0xd69906245565a910ULL
181*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_46		0xf40e35855771202aULL
182*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_47		0x106aa07032bbd1b8ULL
183*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_48		0x19a4c116b8d2d0c8ULL
184*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_49		0x1e376c085141ab53ULL
185*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_50		0x2748774cdf8eeb99ULL
186*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_51		0x34b0bcb5e19b48a8ULL
187*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_52		0x391c0cb3c5c95a63ULL
188*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_53		0x4ed8aa4ae3418acbULL
189*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_54		0x5b9cca4f7763e373ULL
190*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_55		0x682e6ff3d6b2b8a3ULL
191*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_56		0x748f82ee5defb2fcULL
192*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_57		0x78a5636f43172f60ULL
193*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_58		0x84c87814a1f0ab72ULL
194*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_59		0x8cc702081a6439ecULL
195*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_60		0x90befffa23631e28ULL
196*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_61		0xa4506cebde82bde9ULL
197*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_62		0xbef9a3f7b2c67915ULL
198*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_63		0xc67178f2e372532bULL
199*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_64		0xca273eceea26619cULL
200*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_65		0xd186b8c721c0c207ULL
201*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_66		0xeada7dd6cde0eb1eULL
202*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_67		0xf57d4f7fee6ed178ULL
203*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_68		0x06f067aa72176fbaULL
204*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_69		0x0a637dc5a2c898a6ULL
205*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_70		0x113f9804bef90daeULL
206*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_71		0x1b710b35131c471bULL
207*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_72		0x28db77f523047d84ULL
208*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_73		0x32caab7b40c72493ULL
209*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_74		0x3c9ebe0a15c9bebcULL
210*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_75		0x431d67c49c100d4cULL
211*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_76		0x4cc5d4becb3e42b6ULL
212*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_77		0x597f299cfc657e2aULL
213*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_78		0x5fcb6fab3ad6faecULL
214*7c478bd9Sstevel@tonic-gate #define	SHA512_CONST_79		0x6c44198c4a475817ULL
215*7c478bd9Sstevel@tonic-gate 
216*7c478bd9Sstevel@tonic-gate 
217*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
218*7c478bd9Sstevel@tonic-gate }
219*7c478bd9Sstevel@tonic-gate #endif
220*7c478bd9Sstevel@tonic-gate 
221*7c478bd9Sstevel@tonic-gate #endif /* _SYS_SHA2_CONSTS_H */
222