From f9ab9f828b9de106072cfc7130ff75498091f578 Mon Sep 17 00:00:00 2001 From: Saleem Rashid Date: Mon, 31 Jul 2017 20:58:31 +0100 Subject: [PATCH] aes: Fix sequence point warning --- CMakeLists.txt | 4 ---- Makefile | 1 - aes/aeskey.c | 20 ++++++++++++++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6133c903ab..177863d039 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,10 +7,6 @@ add_library(TrezorCrypto STATIC ${SOURCES}) target_include_directories(TrezorCrypto PUBLIC .) target_include_directories(TrezorCrypto PUBLIC ed25519-donna) -# disable sequence point warnings where they are expected -set_source_files_properties(aeskey.c PROPERTIES - COMPILE_FLAGS -Wno-sequence-point) - target_compile_options(TrezorCrypto PRIVATE "-std=c99") if(MSVC) diff --git a/Makefile b/Makefile index f2598d7374..f79de905ee 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,6 @@ CFLAGS += $(OPTFLAGS) \ -Werror # disable sequence point warning because of AES code -CFLAGS += -Wno-sequence-point CFLAGS += -I. CFLAGS += -Iaes CFLAGS += -Ichacha20poly1305 diff --git a/aes/aeskey.c b/aes/aeskey.c index 16e9607ff1..94119185a8 100644 --- a/aes/aeskey.c +++ b/aes/aeskey.c @@ -393,8 +393,11 @@ AES_RETURN aes_xi(decrypt_key192)(const unsigned char *key, aes_decrypt_ctx cx[1 cx->ks[v(48,(3))] = ss[3] = word_in(key, 3); #ifdef DEC_KS_UNROLL - cx->ks[v(48,(4))] = ff(ss[4] = word_in(key, 4)); - cx->ks[v(48,(5))] = ff(ss[5] = word_in(key, 5)); + ss[4] = word_in(key, 4); + ss[5] = word_in(key, 5); + + cx->ks[v(48,(4))] = ff(ss[4]); + cx->ks[v(48,(5))] = ff(ss[5]); kdf6(cx->ks, 0); kd6(cx->ks, 1); kd6(cx->ks, 2); kd6(cx->ks, 3); kd6(cx->ks, 4); kd6(cx->ks, 5); @@ -485,10 +488,15 @@ AES_RETURN aes_xi(decrypt_key256)(const unsigned char *key, aes_decrypt_ctx cx[1 cx->ks[v(56,(3))] = ss[3] = word_in(key, 3); #ifdef DEC_KS_UNROLL - cx->ks[v(56,(4))] = ff(ss[4] = word_in(key, 4)); - cx->ks[v(56,(5))] = ff(ss[5] = word_in(key, 5)); - cx->ks[v(56,(6))] = ff(ss[6] = word_in(key, 6)); - cx->ks[v(56,(7))] = ff(ss[7] = word_in(key, 7)); + ss[4] = word_in(key, 4); + ss[5] = word_in(key, 5); + ss[6] = word_in(key, 6); + ss[7] = word_in(key, 7); + + cx->ks[v(56,(4))] = ff(ss[4]); + cx->ks[v(56,(5))] = ff(ss[5]); + cx->ks[v(56,(6))] = ff(ss[6]); + cx->ks[v(56,(7))] = ff(ss[7]); kdf8(cx->ks, 0); kd8(cx->ks, 1); kd8(cx->ks, 2); kd8(cx->ks, 3); kd8(cx->ks, 4); kd8(cx->ks, 5);