~ubuntu-branches/debian/squeeze/libgcrypt11/squeeze

« back to all changes in this revision

Viewing changes to debian/patches/36_Mitigate-flush-reload-cache-attack-on-RSA.patch

  • Committer: Package Import Robot
  • Author(s): Andreas Metzler
  • Date: 2013-07-27 13:42:31 UTC
  • Revision ID: package-import@ubuntu.com-20130727134231-xfbqpxp8srj62trm
Tags: 1.4.5-2+squeeze1
* Pull and unfuzzz code changes from 1.5.3 security fix release from
  upstream GIT:
  + [35_bug-in-mpi_powm-for-e-0.patch] mpi/mpi-pow.c (gcry_mpi_powm) - For
    a zero exponent, make sure that the result has been allocated.
  + [36_Mitigate-flush-reload-cache-attack-on-RSA.patch] Mitigate a
    flush+reload cache attack on RSA secret exponents.
    <http://eprint.iacr.org/2013/448>
  This fixes CVE-2013-4242.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From e2202ff2b704623efc6277fb5256e4e15bac5676 Mon Sep 17 00:00:00 2001
 
2
From: Werner Koch <wk@gnupg.org>
 
3
Date: Thu, 25 Jul 2013 11:17:52 +0200
 
4
Subject: [PATCH 2/2] Mitigate a flush+reload cache attack on RSA secret
 
5
 exponents.
 
6
 
 
7
* mpi/mpi-pow.c (gcry_mpi_powm): Always perfrom the mpi_mul for
 
8
exponents in secure memory.
 
9
--
 
10
 
 
11
The attack is published as http://eprint.iacr.org/2013/448 :
 
12
 
 
13
Flush+Reload: a High Resolution, Low Noise, L3 Cache Side-Channel
 
14
Attack by Yuval Yarom and Katrina Falkner. 18 July 2013.
 
15
 
 
16
  Flush+Reload is a cache side-channel attack that monitors access to
 
17
  data in shared pages. In this paper we demonstrate how to use the
 
18
  attack to extract private encryption keys from GnuPG.  The high
 
19
  resolution and low noise of the Flush+Reload attack enables a spy
 
20
  program to recover over 98% of the bits of the private key in a
 
21
  single decryption or signing round. Unlike previous attacks, the
 
22
  attack targets the last level L3 cache. Consequently, the spy
 
23
  program and the victim do not need to share the execution core of
 
24
  the CPU. The attack is not limited to a traditional OS and can be
 
25
  used in a virtualised environment, where it can attack programs
 
26
  executing in a different VM.
 
27
---
 
28
 
 
29
--- libgcrypt11-1.4.5.orig/mpi/mpi-pow.c
 
30
+++ libgcrypt11-1.4.5/mpi/mpi-pow.c
 
31
@@ -1,6 +1,7 @@
 
32
 /* mpi-pow.c  -  MPI functions for exponentiation
 
33
  * Copyright (C) 1994, 1996, 1998, 2000, 2002
 
34
  *               2003  Free Software Foundation, Inc.
 
35
+ *               2013  g10 Code GmbH
 
36
  *
 
37
  * This file is part of Libgcrypt.
 
38
  *
 
39
@@ -236,7 +237,13 @@ gcry_mpi_powm (gcry_mpi_t res,
 
40
             tp = rp; rp = xp; xp = tp;
 
41
             rsize = xsize;
 
42
 
 
43
-            if ( (mpi_limb_signed_t)e < 0 )
 
44
+            /* To mitigate the Yarom/Falkner flush+reload cache
 
45
+             * side-channel attack on the RSA secret exponent, we do
 
46
+             * the multiplication regardless of the value of the
 
47
+             * high-bit of E.  But to avoid this performance penalty
 
48
+             * we do it only if the exponent has been stored in secure
 
49
+             * memory and we can thus assume it is a secret exponent.  */
 
50
+            if (esec || (mpi_limb_signed_t)e < 0)
 
51
               {
 
52
                 /*mpih_mul( xp, rp, rsize, bp, bsize );*/
 
53
                 if( bsize < KARATSUBA_THRESHOLD ) 
 
54
@@ -251,6 +258,9 @@ gcry_mpi_powm (gcry_mpi_t res,
 
55
                     _gcry_mpih_divrem(xp + msize, 0, xp, xsize, mp, msize);
 
56
                     xsize = msize;
 
57
                   }
 
58
+             }
 
59
+            if ( (mpi_limb_signed_t)e < 0 )
 
60
+              {
 
61
                 
 
62
                 tp = rp; rp = xp; xp = tp;
 
63
                 rsize = xsize;