Browse Source

Better patch for the bug Samuel Neves described

master
Michael Hamburg 10 years ago
parent
commit
94c51dd2c4
2 changed files with 19 additions and 12 deletions
  1. +13
    -3
      src/arch_x86_64/p448.h
  2. +6
    -9
      src/scalarmul.c

+ 13
- 3
src/arch_x86_64/p448.h View File

@@ -88,12 +88,22 @@ mask_t
p448_is_zero (
const p448_t *in
);
static __inline__ void
static
#ifndef GCC_HAS_A_BUG_SO_DONT_INLINE_FIELD_BIAS
__inline__
#endif
void
p448_bias (
p448_t *inout,
int amount
) __attribute__((unused,always_inline));
)
#ifdef GCC_HAS_A_BUG_SO_DONT_INLINE_FIELD_BIAS
__attribute__((unused,noinline,optimize("O1")))
#else
__attribute__((unused,always_inline))
#endif
;
void
p448_mul (


+ 6
- 9
src/scalarmul.c View File

@@ -1,6 +1,11 @@
/* Copyright (c) 2014 Cryptography Research, Inc.
* Released under the MIT License. See LICENSE.txt for license information.
*/
#if (defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__))
/* This works around an apparent compiler bug in GCC, thanks Samuel Neves */
#define GCC_HAS_A_BUG_SO_DONT_INLINE_FIELD_BIAS
#endif

#include "word.h"

#include <stdlib.h>
@@ -63,15 +68,7 @@ cond_negate_tw_pniels (
cond_negate_tw_niels(&n->n, doNegate);
}

#if (defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__) && !defined(__AVX2__))
/* This works around an apparent compiler bug in GCC, thanks Samuel Neves */
static void __attribute__((optimize("O1")))
#ifdef __OPTIMIZE_SIZE__
#warning "There's a bug in here somewhere with GCC -Os on non-AVX2 platforms"
#endif
#else
static __inline__ void
#endif
static __inline__ void
constant_time_lookup_tw_pniels (
struct tw_pniels_t *out,
const struct tw_pniels_t *in,


Loading…
Cancel
Save