From 4efb3f8dd1bc70d1d9cb7c59faf0e1c64794c57b Mon Sep 17 00:00:00 2001 From: Russell O'Connor Date: Fri, 6 Jul 2018 07:26:57 -0400 Subject: [PATCH] Add check that restrict pointers don't alias with all parameters. --- src/field_10x26_impl.h | 1 + src/field_5x52_impl.h | 1 + src/field_5x52_int128_impl.h | 1 + 3 files changed, 3 insertions(+) diff --git a/src/field_10x26_impl.h b/src/field_10x26_impl.h index 94f8132fc8e62..57613576d89de 100644 --- a/src/field_10x26_impl.h +++ b/src/field_10x26_impl.h @@ -1069,6 +1069,7 @@ static void secp256k1_fe_mul(secp256k1_fe *r, const secp256k1_fe *a, const secp2 secp256k1_fe_verify(a); secp256k1_fe_verify(b); VERIFY_CHECK(r != b); + VERIFY_CHECK(a != b); #endif secp256k1_fe_mul_inner(r->n, a->n, b->n); #ifdef VERIFY diff --git a/src/field_5x52_impl.h b/src/field_5x52_impl.h index 957c61b01451a..60112b7e09f26 100644 --- a/src/field_5x52_impl.h +++ b/src/field_5x52_impl.h @@ -422,6 +422,7 @@ static void secp256k1_fe_mul(secp256k1_fe *r, const secp256k1_fe *a, const secp2 secp256k1_fe_verify(a); secp256k1_fe_verify(b); VERIFY_CHECK(r != b); + VERIFY_CHECK(a != b); #endif secp256k1_fe_mul_inner(r->n, a->n, b->n); #ifdef VERIFY diff --git a/src/field_5x52_int128_impl.h b/src/field_5x52_int128_impl.h index 95a0d1791c055..16f2caca7dead 100644 --- a/src/field_5x52_int128_impl.h +++ b/src/field_5x52_int128_impl.h @@ -32,6 +32,7 @@ SECP256K1_INLINE static void secp256k1_fe_mul_inner(uint64_t *r, const uint64_t VERIFY_BITS(b[3], 56); VERIFY_BITS(b[4], 52); VERIFY_CHECK(r != b); + VERIFY_CHECK(a != b); /* [... a b c] is a shorthand for ... + a<<104 + b<<52 + c<<0 mod n. * px is a shorthand for sum(a[i]*b[x-i], i=0..x).