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