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