Deleted Added
full compact
aes_x86core.c (1.1.1.4) aes_x86core.c (1.1.1.5)
1/* crypto/aes/aes_core.c */
1/*
2 * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
2/**
3 * rijndael-alg-fst.c
4 *
5 * @version 3.0 (December 2000)
6 *
7 * Optimised ANSI C code for the Rijndael cipher (now AES)
8 *
9 * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>

--- 20 unchanged lines hidden (view full) ---

30 * byte order and expects CPU to sustain unaligned memory references.
31 * It is used as playground for cache-time attack mitigations and
32 * serves as reference C implementation for x86[_64] assembler.
33 *
34 * <appro@fy.chalmers.se>
35 */
36
37
10/**
11 * rijndael-alg-fst.c
12 *
13 * @version 3.0 (December 2000)
14 *
15 * Optimised ANSI C code for the Rijndael cipher (now AES)
16 *
17 * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>

--- 20 unchanged lines hidden (view full) ---

38 * byte order and expects CPU to sustain unaligned memory references.
39 * It is used as playground for cache-time attack mitigations and
40 * serves as reference C implementation for x86[_64] assembler.
41 *
42 * <appro@fy.chalmers.se>
43 */
44
45
38#ifndef AES_DEBUG
39# ifndef NDEBUG
40# define NDEBUG
41# endif
42#endif
43#include <assert.h>
44
45#include <stdlib.h>
46#include <openssl/aes.h>
47#include "aes_locl.h"
48
49/*
50 * These two parameters control which table, 256-byte or 2KB, is

--- 562 unchanged lines hidden (view full) ---

613 tp9 = tp8 ^ tp1;
614 tpb = tp9 ^ tp2;
615 tpd = tp9 ^ tp4;
616 tpe = tp8 ^ tp4 ^ tp2;
617#if defined(ROTATE)
618 rk[j] = tpe ^ ROTATE(tpd,16) ^
619 ROTATE(tp9,8) ^ ROTATE(tpb,24);
620#else
46#include <assert.h>
47
48#include <stdlib.h>
49#include <openssl/aes.h>
50#include "aes_locl.h"
51
52/*
53 * These two parameters control which table, 256-byte or 2KB, is

--- 562 unchanged lines hidden (view full) ---

616 tp9 = tp8 ^ tp1;
617 tpb = tp9 ^ tp2;
618 tpd = tp9 ^ tp4;
619 tpe = tp8 ^ tp4 ^ tp2;
620#if defined(ROTATE)
621 rk[j] = tpe ^ ROTATE(tpd,16) ^
622 ROTATE(tp9,8) ^ ROTATE(tpb,24);
623#else
621 rk[j] = tpe ^ (tpd >> 16) ^ (tpd << 16) ^
624 rk[j] = tpe ^ (tpd >> 16) ^ (tpd << 16) ^
622 (tp9 >> 24) ^ (tp9 << 8) ^
623 (tpb >> 8) ^ (tpb << 24);
624#endif
625 }
626#else
627 rk[0] =
628 Td0[Te2[(rk[0] ) & 0xff] & 0xff] ^
629 Td1[Te2[(rk[0] >> 8) & 0xff] & 0xff] ^

--- 272 unchanged lines hidden (view full) ---

902 (u32)Td4[(s1 >> 8) & 0xff] << 8 ^
903 (u32)Td4[(s0 >> 16) & 0xff] << 16 ^
904 (u32)Td4[(s3 >> 24) ] << 24;
905 t[3] = (u32)Td4[(s3 ) & 0xff] ^
906 (u32)Td4[(s2 >> 8) & 0xff] << 8 ^
907 (u32)Td4[(s1 >> 16) & 0xff] << 16 ^
908 (u32)Td4[(s0 >> 24) ] << 24;
909
625 (tp9 >> 24) ^ (tp9 << 8) ^
626 (tpb >> 8) ^ (tpb << 24);
627#endif
628 }
629#else
630 rk[0] =
631 Td0[Te2[(rk[0] ) & 0xff] & 0xff] ^
632 Td1[Te2[(rk[0] >> 8) & 0xff] & 0xff] ^

--- 272 unchanged lines hidden (view full) ---

905 (u32)Td4[(s1 >> 8) & 0xff] << 8 ^
906 (u32)Td4[(s0 >> 16) & 0xff] << 16 ^
907 (u32)Td4[(s3 >> 24) ] << 24;
908 t[3] = (u32)Td4[(s3 ) & 0xff] ^
909 (u32)Td4[(s2 >> 8) & 0xff] << 8 ^
910 (u32)Td4[(s1 >> 16) & 0xff] << 16 ^
911 (u32)Td4[(s0 >> 24) ] << 24;
912
910 /* now do the linear transform using words */
913 /* now do the linear transform using words */
911 {
912 int i;
913 u32 tp1, tp2, tp4, tp8, tp9, tpb, tpd, tpe, m;
914
915 for (i = 0; i < 4; i++) {
916 tp1 = t[i];
917 m = tp1 & 0x80808080;
918 tp2 = ((tp1 & 0x7f7f7f7f) << 1) ^

--- 7 unchanged lines hidden (view full) ---

926 tp9 = tp8 ^ tp1;
927 tpb = tp9 ^ tp2;
928 tpd = tp9 ^ tp4;
929 tpe = tp8 ^ tp4 ^ tp2;
930#if defined(ROTATE)
931 t[i] = tpe ^ ROTATE(tpd,16) ^
932 ROTATE(tp9,8) ^ ROTATE(tpb,24);
933#else
914 {
915 int i;
916 u32 tp1, tp2, tp4, tp8, tp9, tpb, tpd, tpe, m;
917
918 for (i = 0; i < 4; i++) {
919 tp1 = t[i];
920 m = tp1 & 0x80808080;
921 tp2 = ((tp1 & 0x7f7f7f7f) << 1) ^

--- 7 unchanged lines hidden (view full) ---

929 tp9 = tp8 ^ tp1;
930 tpb = tp9 ^ tp2;
931 tpd = tp9 ^ tp4;
932 tpe = tp8 ^ tp4 ^ tp2;
933#if defined(ROTATE)
934 t[i] = tpe ^ ROTATE(tpd,16) ^
935 ROTATE(tp9,8) ^ ROTATE(tpb,24);
936#else
934 t[i] = tpe ^ (tpd >> 16) ^ (tpd << 16) ^
937 t[i] = tpe ^ (tpd >> 16) ^ (tpd << 16) ^
935 (tp9 >> 24) ^ (tp9 << 8) ^
936 (tpb >> 8) ^ (tpb << 24);
937#endif
938 t[i] ^= rk[4+i];
939 }
940 }
941#else
942 t[0] = Td0[(s0 ) & 0xff] ^

--- 36 unchanged lines hidden (view full) ---

979 (u32)Td4[(s1 >> 8) & 0xff] << 8 ^
980 (u32)Td4[(s0 >> 16) & 0xff] << 16 ^
981 (u32)Td4[(s3 >> 24) ] << 24;
982 t[3] = (u32)Td4[(s3 ) & 0xff] ^
983 (u32)Td4[(s2 >> 8) & 0xff] << 8 ^
984 (u32)Td4[(s1 >> 16) & 0xff] << 16 ^
985 (u32)Td4[(s0 >> 24) ] << 24;
986
938 (tp9 >> 24) ^ (tp9 << 8) ^
939 (tpb >> 8) ^ (tpb << 24);
940#endif
941 t[i] ^= rk[4+i];
942 }
943 }
944#else
945 t[0] = Td0[(s0 ) & 0xff] ^

--- 36 unchanged lines hidden (view full) ---

982 (u32)Td4[(s1 >> 8) & 0xff] << 8 ^
983 (u32)Td4[(s0 >> 16) & 0xff] << 16 ^
984 (u32)Td4[(s3 >> 24) ] << 24;
985 t[3] = (u32)Td4[(s3 ) & 0xff] ^
986 (u32)Td4[(s2 >> 8) & 0xff] << 8 ^
987 (u32)Td4[(s1 >> 16) & 0xff] << 16 ^
988 (u32)Td4[(s0 >> 24) ] << 24;
989
987 /* now do the linear transform using words */
990 /* now do the linear transform using words */
988 {
989 int i;
990 u32 tp1, tp2, tp4, tp8, tp9, tpb, tpd, tpe, m;
991
992 for (i = 0; i < 4; i++) {
993 tp1 = t[i];
994 m = tp1 & 0x80808080;
995 tp2 = ((tp1 & 0x7f7f7f7f) << 1) ^

--- 7 unchanged lines hidden (view full) ---

1003 tp9 = tp8 ^ tp1;
1004 tpb = tp9 ^ tp2;
1005 tpd = tp9 ^ tp4;
1006 tpe = tp8 ^ tp4 ^ tp2;
1007#if defined(ROTATE)
1008 t[i] = tpe ^ ROTATE(tpd,16) ^
1009 ROTATE(tp9,8) ^ ROTATE(tpb,24);
1010#else
991 {
992 int i;
993 u32 tp1, tp2, tp4, tp8, tp9, tpb, tpd, tpe, m;
994
995 for (i = 0; i < 4; i++) {
996 tp1 = t[i];
997 m = tp1 & 0x80808080;
998 tp2 = ((tp1 & 0x7f7f7f7f) << 1) ^

--- 7 unchanged lines hidden (view full) ---

1006 tp9 = tp8 ^ tp1;
1007 tpb = tp9 ^ tp2;
1008 tpd = tp9 ^ tp4;
1009 tpe = tp8 ^ tp4 ^ tp2;
1010#if defined(ROTATE)
1011 t[i] = tpe ^ ROTATE(tpd,16) ^
1012 ROTATE(tp9,8) ^ ROTATE(tpb,24);
1013#else
1011 t[i] = tpe ^ (tpd >> 16) ^ (tpd << 16) ^
1014 t[i] = tpe ^ (tpd >> 16) ^ (tpd << 16) ^
1012 (tp9 >> 24) ^ (tp9 << 8) ^
1013 (tpb >> 8) ^ (tpb << 24);
1014#endif
1015 t[i] ^= rk[i];
1016 }
1017 }
1018#else
1019 t[0] = Td0[(s0 ) & 0xff] ^

--- 53 unchanged lines hidden ---
1015 (tp9 >> 24) ^ (tp9 << 8) ^
1016 (tpb >> 8) ^ (tpb << 24);
1017#endif
1018 t[i] ^= rk[i];
1019 }
1020 }
1021#else
1022 t[0] = Td0[(s0 ) & 0xff] ^

--- 53 unchanged lines hidden ---