1 /* SPDX-License-Identifier: GPL-2.0-or-later * 2 /* 3 * 4K AES tables for PPC AES implementation 4 * 5 * Copyright (c) 2015 Markus Stockhausen <stock 6 */ 7 8 /* 9 * These big endian AES encryption/decryption 10 * crypto/aes_generic.c and are designed to be 11 * of rlwimi/lwz instructions with a minimum o 12 * one required). Thus they are aligned to 4K. 13 * is derived from the reduced offsets that ar 14 * instructions. E.g. evldw, evlwwsplat, ... 15 * 16 * For the safety-conscious it has to be noted 17 * to cache timing attacks because of their si 18 * the generic tables they have been reduced f 19 * This is a quite good tradeoff for low power 20 * dedicated encryption hardware where we usua 21 * environment. 22 * 23 */ 24 25 #define R(a, b, c, d) \ 26 0x##a##b##c##d, 0x##d##a##b##c, 0x##c# 27 28 .data 29 .align 12 30 .globl PPC_AES_4K_ENCTAB 31 PPC_AES_4K_ENCTAB: 32 /* encryption table, same as crypto_ft_tab in 33 .long R(c6, 63, 63, a5), R(f8, 7c, 7c, 34 .long R(ee, 77, 77, 99), R(f6, 7b, 7b, 35 .long R(ff, f2, f2, 0d), R(d6, 6b, 6b, 36 .long R(de, 6f, 6f, b1), R(91, c5, c5, 37 .long R(60, 30, 30, 50), R(02, 01, 01, 38 .long R(ce, 67, 67, a9), R(56, 2b, 2b, 39 .long R(e7, fe, fe, 19), R(b5, d7, d7, 40 .long R(4d, ab, ab, e6), R(ec, 76, 76, 41 .long R(8f, ca, ca, 45), R(1f, 82, 82, 42 .long R(89, c9, c9, 40), R(fa, 7d, 7d, 43 .long R(ef, fa, fa, 15), R(b2, 59, 59, 44 .long R(8e, 47, 47, c9), R(fb, f0, f0, 45 .long R(41, ad, ad, ec), R(b3, d4, d4, 46 .long R(5f, a2, a2, fd), R(45, af, af, 47 .long R(23, 9c, 9c, bf), R(53, a4, a4, 48 .long R(e4, 72, 72, 96), R(9b, c0, c0, 49 .long R(75, b7, b7, c2), R(e1, fd, fd, 50 .long R(3d, 93, 93, ae), R(4c, 26, 26, 51 .long R(6c, 36, 36, 5a), R(7e, 3f, 3f, 52 .long R(f5, f7, f7, 02), R(83, cc, cc, 53 .long R(68, 34, 34, 5c), R(51, a5, a5, 54 .long R(d1, e5, e5, 34), R(f9, f1, f1, 55 .long R(e2, 71, 71, 93), R(ab, d8, d8, 56 .long R(62, 31, 31, 53), R(2a, 15, 15, 57 .long R(08, 04, 04, 0c), R(95, c7, c7, 58 .long R(46, 23, 23, 65), R(9d, c3, c3, 59 .long R(30, 18, 18, 28), R(37, 96, 96, 60 .long R(0a, 05, 05, 0f), R(2f, 9a, 9a, 61 .long R(0e, 07, 07, 09), R(24, 12, 12, 62 .long R(1b, 80, 80, 9b), R(df, e2, e2, 63 .long R(cd, eb, eb, 26), R(4e, 27, 27, 64 .long R(7f, b2, b2, cd), R(ea, 75, 75, 65 .long R(12, 09, 09, 1b), R(1d, 83, 83, 66 .long R(58, 2c, 2c, 74), R(34, 1a, 1a, 67 .long R(36, 1b, 1b, 2d), R(dc, 6e, 6e, 68 .long R(b4, 5a, 5a, ee), R(5b, a0, a0, 69 .long R(a4, 52, 52, f6), R(76, 3b, 3b, 70 .long R(b7, d6, d6, 61), R(7d, b3, b3, 71 .long R(52, 29, 29, 7b), R(dd, e3, e3, 72 .long R(5e, 2f, 2f, 71), R(13, 84, 84, 73 .long R(a6, 53, 53, f5), R(b9, d1, d1, 74 .long R(00, 00, 00, 00), R(c1, ed, ed, 75 .long R(40, 20, 20, 60), R(e3, fc, fc, 76 .long R(79, b1, b1, c8), R(b6, 5b, 5b, 77 .long R(d4, 6a, 6a, be), R(8d, cb, cb, 78 .long R(67, be, be, d9), R(72, 39, 39, 79 .long R(94, 4a, 4a, de), R(98, 4c, 4c, 80 .long R(b0, 58, 58, e8), R(85, cf, cf, 81 .long R(bb, d0, d0, 6b), R(c5, ef, ef, 82 .long R(4f, aa, aa, e5), R(ed, fb, fb, 83 .long R(86, 43, 43, c5), R(9a, 4d, 4d, 84 .long R(66, 33, 33, 55), R(11, 85, 85, 85 .long R(8a, 45, 45, cf), R(e9, f9, f9, 86 .long R(04, 02, 02, 06), R(fe, 7f, 7f, 87 .long R(a0, 50, 50, f0), R(78, 3c, 3c, 88 .long R(25, 9f, 9f, ba), R(4b, a8, a8, 89 .long R(a2, 51, 51, f3), R(5d, a3, a3, 90 .long R(80, 40, 40, c0), R(05, 8f, 8f, 91 .long R(3f, 92, 92, ad), R(21, 9d, 9d, 92 .long R(70, 38, 38, 48), R(f1, f5, f5, 93 .long R(63, bc, bc, df), R(77, b6, b6, 94 .long R(af, da, da, 75), R(42, 21, 21, 95 .long R(20, 10, 10, 30), R(e5, ff, ff, 96 .long R(fd, f3, f3, 0e), R(bf, d2, d2, 97 .long R(81, cd, cd, 4c), R(18, 0c, 0c, 98 .long R(26, 13, 13, 35), R(c3, ec, ec, 99 .long R(be, 5f, 5f, e1), R(35, 97, 97, 100 .long R(88, 44, 44, cc), R(2e, 17, 17, 101 .long R(93, c4, c4, 57), R(55, a7, a7, 102 .long R(fc, 7e, 7e, 82), R(7a, 3d, 3d, 103 .long R(c8, 64, 64, ac), R(ba, 5d, 5d, 104 .long R(32, 19, 19, 2b), R(e6, 73, 73, 105 .long R(c0, 60, 60, a0), R(19, 81, 81, 106 .long R(9e, 4f, 4f, d1), R(a3, dc, dc, 107 .long R(44, 22, 22, 66), R(54, 2a, 2a, 108 .long R(3b, 90, 90, ab), R(0b, 88, 88, 109 .long R(8c, 46, 46, ca), R(c7, ee, ee, 110 .long R(6b, b8, b8, d3), R(28, 14, 14, 111 .long R(a7, de, de, 79), R(bc, 5e, 5e, 112 .long R(16, 0b, 0b, 1d), R(ad, db, db, 113 .long R(db, e0, e0, 3b), R(64, 32, 32, 114 .long R(74, 3a, 3a, 4e), R(14, 0a, 0a, 115 .long R(92, 49, 49, db), R(0c, 06, 06, 116 .long R(48, 24, 24, 6c), R(b8, 5c, 5c, 117 .long R(9f, c2, c2, 5d), R(bd, d3, d3, 118 .long R(43, ac, ac, ef), R(c4, 62, 62, 119 .long R(39, 91, 91, a8), R(31, 95, 95, 120 .long R(d3, e4, e4, 37), R(f2, 79, 79, 121 .long R(d5, e7, e7, 32), R(8b, c8, c8, 122 .long R(6e, 37, 37, 59), R(da, 6d, 6d, 123 .long R(01, 8d, 8d, 8c), R(b1, d5, d5, 124 .long R(9c, 4e, 4e, d2), R(49, a9, a9, 125 .long R(d8, 6c, 6c, b4), R(ac, 56, 56, 126 .long R(f3, f4, f4, 07), R(cf, ea, ea, 127 .long R(ca, 65, 65, af), R(f4, 7a, 7a, 128 .long R(47, ae, ae, e9), R(10, 08, 08, 129 .long R(6f, ba, ba, d5), R(f0, 78, 78, 130 .long R(4a, 25, 25, 6f), R(5c, 2e, 2e, 131 .long R(38, 1c, 1c, 24), R(57, a6, a6, 132 .long R(73, b4, b4, c7), R(97, c6, c6, 133 .long R(cb, e8, e8, 23), R(a1, dd, dd, 134 .long R(e8, 74, 74, 9c), R(3e, 1f, 1f, 135 .long R(96, 4b, 4b, dd), R(61, bd, bd, 136 .long R(0d, 8b, 8b, 86), R(0f, 8a, 8a, 137 .long R(e0, 70, 70, 90), R(7c, 3e, 3e, 138 .long R(71, b5, b5, c4), R(cc, 66, 66, 139 .long R(90, 48, 48, d8), R(06, 03, 03, 140 .long R(f7, f6, f6, 01), R(1c, 0e, 0e, 141 .long R(c2, 61, 61, a3), R(6a, 35, 35, 142 .long R(ae, 57, 57, f9), R(69, b9, b9, 143 .long R(17, 86, 86, 91), R(99, c1, c1, 144 .long R(3a, 1d, 1d, 27), R(27, 9e, 9e, 145 .long R(d9, e1, e1, 38), R(eb, f8, f8, 146 .long R(2b, 98, 98, b3), R(22, 11, 11, 147 .long R(d2, 69, 69, bb), R(a9, d9, d9, 148 .long R(07, 8e, 8e, 89), R(33, 94, 94, 149 .long R(2d, 9b, 9b, b6), R(3c, 1e, 1e, 150 .long R(15, 87, 87, 92), R(c9, e9, e9, 151 .long R(87, ce, ce, 49), R(aa, 55, 55, 152 .long R(50, 28, 28, 78), R(a5, df, df, 153 .long R(03, 8c, 8c, 8f), R(59, a1, a1, 154 .long R(09, 89, 89, 80), R(1a, 0d, 0d, 155 .long R(65, bf, bf, da), R(d7, e6, e6, 156 .long R(84, 42, 42, c6), R(d0, 68, 68, 157 .long R(82, 41, 41, c3), R(29, 99, 99, 158 .long R(5a, 2d, 2d, 77), R(1e, 0f, 0f, 159 .long R(7b, b0, b0, cb), R(a8, 54, 54, 160 .long R(6d, bb, bb, d6), R(2c, 16, 16, 161 .globl PPC_AES_4K_DECTAB 162 PPC_AES_4K_DECTAB: 163 /* decryption table, same as crypto_it_tab in 164 .long R(51, f4, a7, 50), R(7e, 41, 65, 165 .long R(1a, 17, a4, c3), R(3a, 27, 5e, 166 .long R(3b, ab, 6b, cb), R(1f, 9d, 45, 167 .long R(ac, fa, 58, ab), R(4b, e3, 03, 168 .long R(20, 30, fa, 55), R(ad, 76, 6d, 169 .long R(88, cc, 76, 91), R(f5, 02, 4c, 170 .long R(4f, e5, d7, fc), R(c5, 2a, cb, 171 .long R(26, 35, 44, 80), R(b5, 62, a3, 172 .long R(de, b1, 5a, 49), R(25, ba, 1b, 173 .long R(45, ea, 0e, 98), R(5d, fe, c0, 174 .long R(c3, 2f, 75, 02), R(81, 4c, f0, 175 .long R(8d, 46, 97, a3), R(6b, d3, f9, 176 .long R(03, 8f, 5f, e7), R(15, 92, 9c, 177 .long R(bf, 6d, 7a, eb), R(95, 52, 59, 178 .long R(d4, be, 83, 2d), R(58, 74, 21, 179 .long R(49, e0, 69, 29), R(8e, c9, c8, 180 .long R(75, c2, 89, 6a), R(f4, 8e, 79, 181 .long R(99, 58, 3e, 6b), R(27, b9, 71, 182 .long R(be, e1, 4f, b6), R(f0, 88, ad, 183 .long R(c9, 20, ac, 66), R(7d, ce, 3a, 184 .long R(63, df, 4a, 18), R(e5, 1a, 31, 185 .long R(97, 51, 33, 60), R(62, 53, 7f, 186 .long R(b1, 64, 77, e0), R(bb, 6b, ae, 187 .long R(fe, 81, a0, 1c), R(f9, 08, 2b, 188 .long R(70, 48, 68, 58), R(8f, 45, fd, 189 .long R(94, de, 6c, 87), R(52, 7b, f8, 190 .long R(ab, 73, d3, 23), R(72, 4b, 02, 191 .long R(e3, 1f, 8f, 57), R(66, 55, ab, 192 .long R(b2, eb, 28, 07), R(2f, b5, c2, 193 .long R(86, c5, 7b, 9a), R(d3, 37, 08, 194 .long R(30, 28, 87, f2), R(23, bf, a5, 195 .long R(02, 03, 6a, ba), R(ed, 16, 82, 196 .long R(8a, cf, 1c, 2b), R(a7, 79, b4, 197 .long R(f3, 07, f2, f0), R(4e, 69, e2, 198 .long R(65, da, f4, cd), R(06, 05, be, 199 .long R(d1, 34, 62, 1f), R(c4, a6, fe, 200 .long R(34, 2e, 53, 9d), R(a2, f3, 55, 201 .long R(05, 8a, e1, 32), R(a4, f6, eb, 202 .long R(0b, 83, ec, 39), R(40, 60, ef, 203 .long R(5e, 71, 9f, 06), R(bd, 6e, 10, 204 .long R(3e, 21, 8a, f9), R(96, dd, 06, 205 .long R(dd, 3e, 05, ae), R(4d, e6, bd, 206 .long R(91, 54, 8d, b5), R(71, c4, 5d, 207 .long R(04, 06, d4, 6f), R(60, 50, 15, 208 .long R(19, 98, fb, 24), R(d6, bd, e9, 209 .long R(89, 40, 43, cc), R(67, d9, 9e, 210 .long R(b0, e8, 42, bd), R(07, 89, 8b, 211 .long R(e7, 19, 5b, 38), R(79, c8, ee, 212 .long R(a1, 7c, 0a, 47), R(7c, 42, 0f, 213 .long R(f8, 84, 1e, c9), R(00, 00, 00, 214 .long R(09, 80, 86, 83), R(32, 2b, ed, 215 .long R(1e, 11, 70, ac), R(6c, 5a, 72, 216 .long R(fd, 0e, ff, fb), R(0f, 85, 38, 217 .long R(3d, ae, d5, 1e), R(36, 2d, 39, 218 .long R(0a, 0f, d9, 64), R(68, 5c, a6, 219 .long R(9b, 5b, 54, d1), R(24, 36, 2e, 220 .long R(0c, 0a, 67, b1), R(93, 57, e7, 221 .long R(b4, ee, 96, d2), R(1b, 9b, 91, 222 .long R(80, c0, c5, 4f), R(61, dc, 20, 223 .long R(5a, 77, 4b, 69), R(1c, 12, 1a, 224 .long R(e2, 93, ba, 0a), R(c0, a0, 2a, 225 .long R(3c, 22, e0, 43), R(12, 1b, 17, 226 .long R(0e, 09, 0d, 0b), R(f2, 8b, c7, 227 .long R(2d, b6, a8, b9), R(14, 1e, a9, 228 .long R(57, f1, 19, 85), R(af, 75, 07, 229 .long R(ee, 99, dd, bb), R(a3, 7f, 60, 230 .long R(f7, 01, 26, 9f), R(5c, 72, f5, 231 .long R(44, 66, 3b, c5), R(5b, fb, 7e, 232 .long R(8b, 43, 29, 76), R(cb, 23, c6, 233 .long R(b6, ed, fc, 68), R(b8, e4, f1, 234 .long R(d7, 31, dc, ca), R(42, 63, 85, 235 .long R(13, 97, 22, 40), R(84, c6, 11, 236 .long R(85, 4a, 24, 7d), R(d2, bb, 3d, 237 .long R(ae, f9, 32, 11), R(c7, 29, a1, 238 .long R(1d, 9e, 2f, 4b), R(dc, b2, 30, 239 .long R(0d, 86, 52, ec), R(77, c1, e3, 240 .long R(2b, b3, 16, 6c), R(a9, 70, b9, 241 .long R(11, 94, 48, fa), R(47, e9, 64, 242 .long R(a8, fc, 8c, c4), R(a0, f0, 3f, 243 .long R(56, 7d, 2c, d8), R(22, 33, 90, 244 .long R(87, 49, 4e, c7), R(d9, 38, d1, 245 .long R(8c, ca, a2, fe), R(98, d4, 0b, 246 .long R(a6, f5, 81, cf), R(a5, 7a, de, 247 .long R(da, b7, 8e, 26), R(3f, ad, bf, 248 .long R(2c, 3a, 9d, e4), R(50, 78, 92, 249 .long R(6a, 5f, cc, 9b), R(54, 7e, 46, 250 .long R(f6, 8d, 13, c2), R(90, d8, b8, 251 .long R(2e, 39, f7, 5e), R(82, c3, af, 252 .long R(9f, 5d, 80, be), R(69, d0, 93, 253 .long R(6f, d5, 2d, a9), R(cf, 25, 12, 254 .long R(c8, ac, 99, 3b), R(10, 18, 7d, 255 .long R(e8, 9c, 63, 6e), R(db, 3b, bb, 256 .long R(cd, 26, 78, 09), R(6e, 59, 18, 257 .long R(ec, 9a, b7, 01), R(83, 4f, 9a, 258 .long R(e6, 95, 6e, 65), R(aa, ff, e6, 259 .long R(21, bc, cf, 08), R(ef, 15, e8, 260 .long R(ba, e7, 9b, d9), R(4a, 6f, 36, 261 .long R(ea, 9f, 09, d4), R(29, b0, 7c, 262 .long R(31, a4, b2, af), R(2a, 3f, 23, 263 .long R(c6, a5, 94, 30), R(35, a2, 66, 264 .long R(74, 4e, bc, 37), R(fc, 82, ca, 265 .long R(e0, 90, d0, b0), R(33, a7, d8, 266 .long R(f1, 04, 98, 4a), R(41, ec, da, 267 .long R(7f, cd, 50, 0e), R(17, 91, f6, 268 .long R(76, 4d, d6, 8d), R(43, ef, b0, 269 .long R(cc, aa, 4d, 54), R(e4, 96, 04, 270 .long R(9e, d1, b5, e3), R(4c, 6a, 88, 271 .long R(c1, 2c, 1f, b8), R(46, 65, 51, 272 .long R(9d, 5e, ea, 04), R(01, 8c, 35, 273 .long R(fa, 87, 74, 73), R(fb, 0b, 41, 274 .long R(b3, 67, 1d, 5a), R(92, db, d2, 275 .long R(e9, 10, 56, 33), R(6d, d6, 47, 276 .long R(9a, d7, 61, 8c), R(37, a1, 0c, 277 .long R(59, f8, 14, 8e), R(eb, 13, 3c, 278 .long R(ce, a9, 27, ee), R(b7, 61, c9, 279 .long R(e1, 1c, e5, ed), R(7a, 47, b1, 280 .long R(9c, d2, df, 59), R(55, f2, 73, 281 .long R(18, 14, ce, 79), R(73, c7, 37, 282 .long R(53, f7, cd, ea), R(5f, fd, aa, 283 .long R(df, 3d, 6f, 14), R(78, 44, db, 284 .long R(ca, af, f3, 81), R(b9, 68, c4, 285 .long R(38, 24, 34, 2c), R(c2, a3, 40, 286 .long R(16, 1d, c3, 72), R(bc, e2, 25, 287 .long R(28, 3c, 49, 8b), R(ff, 0d, 95, 288 .long R(39, a8, 01, 71), R(08, 0c, b3, 289 .long R(d8, b4, e4, 9c), R(64, 56, c1, 290 .long R(7b, cb, 84, 61), R(d5, 32, b6, 291 .long R(48, 6c, 5c, 74), R(d0, b8, 57, 292 .globl PPC_AES_4K_DECTAB2 293 PPC_AES_4K_DECTAB2: 294 /* decryption table, same as crypto_il_tab in 295 .byte 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x 296 .byte 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0x 297 .byte 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x 298 .byte 0x34, 0x8e, 0x43, 0x44, 0xc4, 0x 299 .byte 0x54, 0x7b, 0x94, 0x32, 0xa6, 0x 300 .byte 0xee, 0x4c, 0x95, 0x0b, 0x42, 0x 301 .byte 0x08, 0x2e, 0xa1, 0x66, 0x28, 0x 302 .byte 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x 303 .byte 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x 304 .byte 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x 305 .byte 0x6c, 0x70, 0x48, 0x50, 0xfd, 0x 306 .byte 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x 307 .byte 0x90, 0xd8, 0xab, 0x00, 0x8c, 0x 308 .byte 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0x 309 .byte 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x 310 .byte 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x 311 .byte 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x 312 .byte 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0x 313 .byte 0x96, 0xac, 0x74, 0x22, 0xe7, 0x 314 .byte 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x 315 .byte 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x 316 .byte 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x 317 .byte 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0x 318 .byte 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0x 319 .byte 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x 320 .byte 0xb1, 0x12, 0x10, 0x59, 0x27, 0x 321 .byte 0x60, 0x51, 0x7f, 0xa9, 0x19, 0x 322 .byte 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0x 323 .byte 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x 324 .byte 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x 325 .byte 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x 326 .byte 0xe1, 0x69, 0x14, 0x63, 0x55, 0x
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.