From 345df93978c41da1ac8047a37f1fed5286883d8d Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Mon, 19 Dec 2016 14:51:42 -0700 Subject: [PATCH] Bug fix for cache attack --- wolfcrypt/src/tfm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/wolfcrypt/src/tfm.c b/wolfcrypt/src/tfm.c index e73135a60..71b5735ea 100644 --- a/wolfcrypt/src/tfm.c +++ b/wolfcrypt/src/tfm.c @@ -446,12 +446,11 @@ INLINE static void fp_mul_comba_mulx(fp_int *A, fp_int *B, fp_int *C) pa = FP_SIZE-1; } - if (A == C || B == C) { + /* Always take branch to use tmp variable. This avoids a cache attack for + * determining if C equals A */ + if (1) { fp_init(&tmp); dst = &tmp; - } else { - fp_zero(C); - dst = C; } TFM_INTEL_MUL_COMBA(A, B, dst) ;