From 29e9ce00cbc2ae779a2674c2a4bcf4bfad0c7c92 Mon Sep 17 00:00:00 2001 From: Kris Kwiatkowski Date: Fri, 19 Apr 2019 12:58:50 +0100 Subject: [PATCH] WIP Change-Id: Ib4714d94fbda9f604683ad4c64dcb222714f4a85 --- third_party/sike/fpx.c | 10 +++++----- third_party/sike/fpx.h | 2 +- third_party/sike/sike_test.cc | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/third_party/sike/fpx.c b/third_party/sike/fpx.c index cd12496b..92cb539d 100644 --- a/third_party/sike/fpx.c +++ b/third_party/sike/fpx.c @@ -163,9 +163,9 @@ inline static void mp_addfast(const felm_t a, const felm_t b, felm_t c) // Multiprecision subtraction, c = a-b, where lng(a) = lng(b) = 2*NWORDS_FIELD. // If c < 0 then returns mask = 0xFF..F, else mask = 0x00..0 -inline static crypto_word_t mp_subfast(const felm_t a, const felm_t b, felm_t c) { +inline static crypto_word_t mp_subfast(const dfelm_t a, const dfelm_t b, dfelm_t c) { #if defined(OPENSSL_NO_ASM) - return (0 - (crypto_word_t)mp_sub(a, b, c, 2*NWORDS_FIELD)); + return (0 - (crypto_word_t)mp_sub((felm_t)a, (felm_t)b, (felm_t)c, 2*NWORDS_FIELD)); #else return sike_mpsubx2_asm(a, b, c); #endif @@ -173,10 +173,10 @@ inline static crypto_word_t mp_subfast(const felm_t a, const felm_t b, felm_t c) // Multiprecision subtraction, c = c-a-b, where lng(a) = lng(b) = 2*NWORDS_FIELD. // Inputs should be s.t. c > a and c > b -inline static void mp_dblsubfast(const felm_t a, const felm_t b, felm_t c) { +inline static void mp_dblsubfast(const dfelm_t a, const dfelm_t b, dfelm_t c) { #if defined(OPENSSL_NO_ASM) - mp_sub(c, a, c, 2*NWORDS_FIELD); - mp_sub(c, b, c, 2*NWORDS_FIELD); + mp_sub((felm_t)c, (felm_t)a, (felm_t)c, 2*NWORDS_FIELD); + mp_sub((felm_t)c, (felm_t)b, (felm_t)c, 2*NWORDS_FIELD); #else sike_mpdblsubx2_asm(a, b, c); #endif diff --git a/third_party/sike/fpx.h b/third_party/sike/fpx.h index e89cee1f..ed677682 100644 --- a/third_party/sike/fpx.h +++ b/third_party/sike/fpx.h @@ -22,7 +22,7 @@ void sike_fprdc(const dfelm_t a, felm_t c); // Double 2x503-bit multiprecision subtraction, c = c-a-b void sike_mpdblsubx2_asm(const felm_t a, const felm_t b, felm_t c); // Multiprecision subtraction, c = a-b -crypto_word_t sike_mpsubx2_asm(const felm_t a, const felm_t b, felm_t c); +crypto_word_t sike_mpsubx2_asm(const dfelm_t a, const dfelm_t b, dfelm_t c); // 503-bit multiprecision addition, c = a+b void sike_mpadd_asm(const felm_t a, const felm_t b, felm_t c); // Modular negation, a = -a mod p503. diff --git a/third_party/sike/sike_test.cc b/third_party/sike/sike_test.cc index 44b2e922..0b905578 100644 --- a/third_party/sike/sike_test.cc +++ b/third_party/sike/sike_test.cc @@ -196,12 +196,13 @@ TEST(SIKE, Negative) { #if defined(SUPPORTS_ABI_TEST) && defined(OPENSSL_X86_64) TEST(SIKE, ABI) { felm_t a, b, c; - dfelm_t d; + dfelm_t d, e, f; CHECK_ABI(sike_fpadd, a, b, c); CHECK_ABI(sike_fpsub, a, b, c); CHECK_ABI(sike_mpmul, a, b, d); CHECK_ABI(sike_fprdc, d, a); CHECK_ABI(sike_mpadd_asm, a, b, c); - CHECK_ABI(sike_mpsubx2_asm, a, b, c); + CHECK_ABI(sike_mpsubx2_asm, d, e, f); + CHECK_ABI(sike_mpdblsubx2_asm, d, e, f); } #endif // SUPPORTS_ABI_TEST && X86_64