Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalware-1.9.git;a=commitdiff;h=55c3f02ff3154f2a0f1c5ca3cd5c12bd4ad10e8d
commit 55c3f02ff3154f2a0f1c5ca3cd5c12bd4ad10e8d Author: kikadf <[email protected]> Date: Sat Jan 18 08:29:53 2014 +0100 gnupg-1.4.14-2arcturus1-x86_64 * Fix CVE-2013-4351 CVE-2013-4402 CVE-2013-4576 diff --git a/source/apps/gnupg/CVE-2013-4351.patch b/source/apps/gnupg/CVE-2013-4351.patch new file mode 100644 index 0000000..1f6b7e9 --- /dev/null +++ b/source/apps/gnupg/CVE-2013-4351.patch @@ -0,0 +1,49 @@ +From: Werner Koch <[email protected]> + + gpg: Distinguish between missing and cleared key flags. + + * include/cipher.h (PUBKEY_USAGE_NONE): New. + * g10/getkey.c (parse_key_usage): Set new flag. + -- + + We do not want to use the default capabilities (derived from the + algorithm) if any key flags are given in a signature. Thus if key + flags are used in any way, the default key capabilities are never + used. + + This allows to create a key with key flags set to all zero so it can't + be used. This better reflects common sense. + +--- a/g10/getkey.c ++++ b/g10/getkey.c +@@ -1494,13 +1494,19 @@ + + if(flags) + key_usage |= PUBKEY_USAGE_UNKNOWN; ++ ++ if (!key_usage) ++ key_usage |= PUBKEY_USAGE_NONE; + } ++ else if (p) /* Key flags of length zero. */ ++ key_usage |= PUBKEY_USAGE_NONE; + + /* We set PUBKEY_USAGE_UNKNOWN to indicate that this key has a + capability that we do not handle. This serves to distinguish + between a zero key usage which we handle as the default + capabilities for that algorithm, and a usage that we do not +- handle. */ ++ handle. Likewise we use PUBKEY_USAGE_NONE to indicate that ++ key_flags have been given but they do not specify any usage. */ + + return key_usage; + } +--- a/include/cipher.h ++++ b/include/cipher.h +@@ -57,6 +57,7 @@ + #define PUBKEY_USAGE_CERT 4 /* key is also good to certify other keys*/ + #define PUBKEY_USAGE_AUTH 8 /* key is good for authentication */ + #define PUBKEY_USAGE_UNKNOWN 128 /* key has an unknown usage bit */ ++#define PUBKEY_USAGE_NONE 256 /* No usage given. */ + + #define DIGEST_ALGO_MD5 1 + #define DIGEST_ALGO_SHA1 2 diff --git a/source/apps/gnupg/CVE-2013-4402.patch b/source/apps/gnupg/CVE-2013-4402.patch new file mode 100644 index 0000000..ab53153 --- /dev/null +++ b/source/apps/gnupg/CVE-2013-4402.patch @@ -0,0 +1,420 @@ +From d90a1d23404f482cc4a5a2b2ee0f296d67ff2227 Mon Sep 17 00:00:00 2001 +From: Werner Koch <[email protected]> +Date: Wed, 2 Oct 2013 09:11:43 +0200 +Subject: [PATCH 1/2] gpg: Fix bug with deeply nested compressed packets. + +* g10/mainproc.c (MAX_NESTING_DEPTH): New. +(proc_compressed): Return an error code. +(check_nesting): New. +(do_proc_packets): Check packet nesting depth. Handle errors from +check_compressed. + +Signed-off-by: Werner Koch <[email protected]> +--- + NEWS | 3 +++ + g10/mainproc.c | 52 +++++++++++++++++++++++++++++++++++++++++++--------- + 2 files changed, 46 insertions(+), 9 deletions(-) + +--- a/g10/mainproc.c ++++ b/g10/mainproc.c +@@ -1,6 +1,7 @@ + /* mainproc.c - handle packets + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + * 2008 Free Software Foundation, Inc. ++ * Copyright (C) 2013 Werner Koch + * + * This file is part of GnuPG. + * +@@ -41,6 +42,11 @@ + #include "photoid.h" + + ++/* Put an upper limit on nested packets. The 32 is an arbitrary ++ value, a much lower should actually be sufficient. */ ++#define MAX_NESTING_DEPTH 32 ++ ++ + struct kidlist_item { + struct kidlist_item *next; + u32 kid[2]; +@@ -784,7 +790,7 @@ + return proc_encryption_packets( info, a ); + } + +-static void ++static int + proc_compressed( CTX c, PACKET *pkt ) + { + PKT_compressed *zd = pkt->pkt.compressed; +@@ -803,6 +809,7 @@ + log_error("uncompressing failed: %s\n", g10_errstr(rc)); + free_packet(pkt); + c->last_was_session_key = 0; ++ return rc; + } + + /**************** +@@ -1233,14 +1240,37 @@ + } + + +-int ++static int ++check_nesting (CTX c) ++{ ++ int level; ++ ++ for (level = 0; c; c = c->anchor) ++ level++; ++ ++ if (level > MAX_NESTING_DEPTH) ++ { ++ log_error ("input data with too deeply nested packets\n"); ++ write_status_text (STATUS_UNEXPECTED, "1"); ++ return G10ERR_UNEXPECTED; ++ } ++ return 0; ++} ++ ++ ++static int + do_proc_packets( CTX c, IOBUF a ) + { +- PACKET *pkt = xmalloc( sizeof *pkt ); +- int rc=0; +- int any_data=0; ++ PACKET *pkt; ++ int rc = 0; ++ int any_data = 0; + int newpkt; + ++ rc = check_nesting (c); ++ if (rc) ++ return rc; ++ ++ pkt = xmalloc( sizeof *pkt ); + c->iobuf = a; + init_packet(pkt); + while( (rc=parse_packet(a, pkt)) != -1 ) { +@@ -1260,7 +1290,7 @@ + case PKT_SYMKEY_ENC: proc_symkey_enc( c, pkt ); break; + case PKT_ENCRYPTED: + case PKT_ENCRYPTED_MDC: proc_encrypted( c, pkt ); break; +- case PKT_COMPRESSED: proc_compressed( c, pkt ); break; ++ case PKT_COMPRESSED: rc = proc_compressed( c, pkt ); break; + default: newpkt = 0; break; + } + } +@@ -1278,7 +1308,7 @@ + goto leave; + case PKT_SIGNATURE: newpkt = add_signature( c, pkt ); break; + case PKT_PLAINTEXT: proc_plaintext( c, pkt ); break; +- case PKT_COMPRESSED: proc_compressed( c, pkt ); break; ++ case PKT_COMPRESSED: rc = proc_compressed( c, pkt ); break; + case PKT_ONEPASS_SIG: newpkt = add_onepass_sig( c, pkt ); break; + case PKT_GPG_CONTROL: newpkt = add_gpg_control(c, pkt); break; + default: newpkt = 0; break; +@@ -1298,7 +1328,7 @@ + case PKT_ENCRYPTED: + case PKT_ENCRYPTED_MDC: proc_encrypted( c, pkt ); break; + case PKT_PLAINTEXT: proc_plaintext( c, pkt ); break; +- case PKT_COMPRESSED: proc_compressed( c, pkt ); break; ++ case PKT_COMPRESSED: rc = proc_compressed( c, pkt ); break; + case PKT_ONEPASS_SIG: newpkt = add_onepass_sig( c, pkt ); break; + case PKT_GPG_CONTROL: newpkt = add_gpg_control(c, pkt); break; + default: newpkt = 0; break; +@@ -1323,13 +1353,17 @@ + case PKT_ENCRYPTED: + case PKT_ENCRYPTED_MDC: proc_encrypted( c, pkt ); break; + case PKT_PLAINTEXT: proc_plaintext( c, pkt ); break; +- case PKT_COMPRESSED: proc_compressed( c, pkt ); break; ++ case PKT_COMPRESSED: rc = proc_compressed( c, pkt ); break; + case PKT_ONEPASS_SIG: newpkt = add_onepass_sig( c, pkt ); break; + case PKT_GPG_CONTROL: newpkt = add_gpg_control(c, pkt); break; + case PKT_RING_TRUST: newpkt = add_ring_trust( c, pkt ); break; + default: newpkt = 0; break; + } + } ++ ++ if (rc) ++ goto leave; ++ + /* This is a very ugly construct and frankly, I don't remember why + * I used it. Adding the MDC check here is a hack. + * The right solution is to initiate another context for encrypted +--- a/util/iobuf.c ++++ b/util/iobuf.c +@@ -27,7 +27,7 @@ + #include <assert.h> + #include <sys/types.h> + #include <sys/stat.h> +-#include <fcntl.h> ++#include <fcntl.h> + #include <unistd.h> + #ifdef HAVE_DOSISH_SYSTEM + #include <windows.h> +@@ -41,13 +41,13 @@ + #include "util.h" + #include "dynload.h" + #include "iobuf.h" +- ++ + #ifdef __VMS + # include "vms.h" + # define open open_vms + #endif /* def __VMS */ + +-/* The size of the internal buffers. ++/* The size of the internal buffers. + NOTE: If you change this value you MUST also adjust the regression + test "armored_key_8192" and "nopad_armored_msg" in armor.test! */ + #define IOBUF_BUFFER_SIZE 8192 +@@ -55,6 +55,11 @@ + + #undef FILE_FILTER_USES_STDIO + ++/* To avoid a potential DoS with compression packets we better limit ++ the number of filters in a chain. */ ++#define MAX_NESTING_FILTER 64 ++ ++ + #ifdef HAVE_DOSISH_SYSTEM + #define USE_SETMODE 1 + #endif +@@ -76,8 +81,8 @@ + } file_filter_ctx_t ; + #else + #define my_fileno(a) (a) +-#define my_fopen_ro(a,b) fd_cache_open ((a),(b)) +-#define my_fopen(a,b) direct_open ((a),(b)) ++#define my_fopen_ro(a,b) fd_cache_open ((a),(b)) ++#define my_fopen(a,b) direct_open ((a),(b)) + #ifdef HAVE_DOSISH_SYSTEM + typedef HANDLE FILEP_OR_FD; + #define INVALID_FP ((HANDLE)-1) +@@ -99,7 +104,7 @@ + char fname[1]; /* name of the file */ + } file_filter_ctx_t ; + +- struct close_cache_s { ++ struct close_cache_s { + struct close_cache_s *next; + FILEP_OR_FD fp; + char fname[1]; +@@ -153,7 +158,7 @@ + #ifdef HAVE_DOSISH_SYSTEM + for (; *a && *b; a++, b++) + { +- if (*a != *b && !((*a == '/' && *b == '\\') ++ if (*a != *b && !((*a == '/' && *b == '\\') + || (*a == '\\' && *b == '/')) ) + break; + } +@@ -295,7 +300,7 @@ + { + struct stat buf; + int rc = stat( fname, &buf ); +- ++ + /* Don't allow iobufs on directories */ + if( !rc && S_ISDIR(buf.st_mode) && !S_ISREG(buf.st_mode) ) + return __set_errno( EISDIR ); +@@ -308,7 +313,7 @@ + + + /* +- * Instead of closing an FD we keep it open and cache it for later reuse ++ * Instead of closing an FD we keep it open and cache it for later reuse + * Note that this caching strategy only works if the process does not chdir. + */ + static void +@@ -471,8 +476,8 @@ + if( control == IOBUFCTRL_UNDERFLOW ) { + assert( size ); /* need a buffer */ + if ( a->eof_seen) { +- rc = -1; +- *ret_len = 0; ++ rc = -1; ++ *ret_len = 0; + } + else { + #ifdef HAVE_DOSISH_SYSTEM +@@ -606,8 +611,8 @@ + if( control == IOBUFCTRL_UNDERFLOW ) { + assert( size ); /* need a buffer */ + if ( a->eof_seen) { +- rc = -1; +- *ret_len = 0; ++ rc = -1; ++ *ret_len = 0; + } + else { + int nread; +@@ -1076,7 +1081,7 @@ + fname += 2; + for (i=0; digitp (fname+i); i++ ) + ; +- if ( !fname[i] ) ++ if ( !fname[i] ) + return atoi (fname); + } + return -1; +@@ -1189,7 +1194,7 @@ + sock_filter( scx, IOBUFCTRL_INIT, NULL, NULL, &len ); + if( DBG_IOBUF ) + log_debug("iobuf-%d.%d: sockopen `%s'\n", a->no, a->subno, scx->fname); +- iobuf_ioctl (a,3,1,NULL); /* disable fd caching */ ++ iobuf_ioctl (a,3,1,NULL); /* disable fd caching */ + #else + a = iobuf_fdopen (fd, mode); + #endif +@@ -1233,7 +1238,7 @@ + file_filter( fcx, IOBUFCTRL_DESC, NULL, (byte*)&a->desc, &len ); + file_filter( fcx, IOBUFCTRL_INIT, NULL, NULL, &len ); + if( DBG_IOBUF ) +- log_debug("iobuf-%d.%d: create `%s'\n", a->no, a->subno, ++ log_debug("iobuf-%d.%d: create `%s'\n", a->no, a->subno, + a->desc?a->desc:"?" ); + + return a; +@@ -1267,7 +1272,7 @@ + file_filter( fcx, IOBUFCTRL_DESC, NULL, (byte*)&a->desc, &len ); + file_filter( fcx, IOBUFCTRL_INIT, NULL, NULL, &len ); + if( DBG_IOBUF ) +- log_debug("iobuf-%d.%d: append `%s'\n", a->no, a->subno, ++ log_debug("iobuf-%d.%d: append `%s'\n", a->no, a->subno, + a->desc?a->desc:"?" ); + + return a; +@@ -1296,7 +1301,7 @@ + file_filter( fcx, IOBUFCTRL_DESC, NULL, (byte*)&a->desc, &len ); + file_filter( fcx, IOBUFCTRL_INIT, NULL, NULL, &len ); + if( DBG_IOBUF ) +- log_debug("iobuf-%d.%d: openrw `%s'\n", a->no, a->subno, ++ log_debug("iobuf-%d.%d: openrw `%s'\n", a->no, a->subno, + a->desc?a->desc:"?"); + + return a; +@@ -1309,7 +1314,7 @@ + if ( cmd == 1 ) { /* keep system filepointer/descriptor open */ + if( DBG_IOBUF ) + log_debug("iobuf-%d.%d: ioctl `%s' keep=%d\n", +- a? a->no:-1, a?a->subno:-1, ++ a? a->no:-1, a?a->subno:-1, + a&&a->desc?a->desc:"?", intval ); + for( ; a; a = a->chain ) + if( !a->chain && a->filter == file_filter ) { +@@ -1339,7 +1344,7 @@ + else if ( cmd == 3 ) { /* disallow/allow caching */ + if( DBG_IOBUF ) + log_debug("iobuf-%d.%d: ioctl `%s' no_cache=%d\n", +- a? a->no:-1, a?a->subno:-1, ++ a? a->no:-1, a?a->subno:-1, + a&&a->desc?a->desc:"?", intval ); + for( ; a; a = a->chain ) + if( !a->chain && a->filter == file_filter ) { +@@ -1403,6 +1408,12 @@ + + if( a->use == 2 && (rc=iobuf_flush(a)) ) + return rc; ++ ++ if (a->subno >= MAX_NESTING_FILTER) { ++ log_error ("i/o filter too deeply nested - corrupted data?\n"); ++ return G10ERR_UNEXPECTED; ++ } ++ + /* make a copy of the current stream, so that + * A is the new stream and B the original one. + * The contents of the buffers are transferred to the +@@ -1449,7 +1460,7 @@ + f( ov, IOBUFCTRL_DESC, NULL, (byte*)&a->desc, &dummy_len ); + + if( DBG_IOBUF ) { +- log_debug("iobuf-%d.%d: push `%s'\n", a->no, a->subno, ++ log_debug("iobuf-%d.%d: push `%s'\n", a->no, a->subno, + a->desc?a->desc:"?" ); + print_chain( a ); + } +@@ -1921,7 +1932,7 @@ + if (overflow) + *overflow = 0; + +- if (a->directfp) ++ if (a->directfp) + { + FILE *fp = a->directfp; + +@@ -1949,14 +1960,14 @@ + + #if defined(HAVE_DOSISH_SYSTEM) && !defined(FILE_FILTER_USES_STDIO) + ulong size; +- static int (* __stdcall get_file_size_ex) ++ static int (* __stdcall get_file_size_ex) + (void *handle, LARGE_INTEGER *size); + static int get_file_size_ex_initialized; + + if (!get_file_size_ex_initialized) + { + void *handle; +- ++ + handle = dlopen ("kernel32.dll", RTLD_LAZY); + if (handle) + { +@@ -1974,14 +1985,14 @@ + return a proper error in case a file is larger than + 4GB. */ + LARGE_INTEGER size; +- ++ + if (get_file_size_ex (fp, &size)) + { + if (!size.u.HighPart) + return size.u.LowPart; + if (overflow) + *overflow = 1; +- return 0; ++ return 0; + } + } + else +@@ -2007,7 +2018,7 @@ + + /* Return the file descriptor of the underlying file or -1 if it is + not available. */ +-int ++int + iobuf_get_fd (IOBUF a) + { + if (a->directfp) +@@ -2260,7 +2271,7 @@ + #ifdef _WIN32 + { + int x; +- ++ + if ( fd <= 2 ) + return fd; /* do not do this for error, stdin, stdout, stderr */ + +@@ -2281,17 +2292,17 @@ + translate_file_handle ( int fd, int for_write ) + { + #ifdef _WIN32 +-#ifdef FILE_FILTER_USES_STDIO ++#ifdef FILE_FILTER_USES_STDIO + fd = iobuf_translate_file_handle (fd, for_write); + #else + { + int x; + +- if ( fd == 0 ) ++ if ( fd == 0 ) + x = (int)GetStdHandle (STD_INPUT_HANDLE); +- else if (fd == 1) ++ else if (fd == 1) + x = (int)GetStdHandle (STD_OUTPUT_HANDLE); +- else if (fd == 2) ++ else if (fd == 2) + x = (int)GetStdHandle (STD_ERROR_HANDLE); + else + x = fd; diff --git a/source/apps/gnupg/CVE-2013-4576.patch b/source/apps/gnupg/CVE-2013-4576.patch new file mode 100644 index 0000000..586ef71 --- /dev/null +++ b/source/apps/gnupg/CVE-2013-4576.patch @@ -0,0 +1,246 @@ +diff -Naur gnupg-1.4.14/cipher/dsa.c gnupg-1.4.14.new/cipher/dsa.c +--- gnupg-1.4.14/cipher/dsa.c 2013-07-19 11:37:59.000000000 +0200 ++++ gnupg-1.4.14.new/cipher/dsa.c 2014-01-18 08:14:11.473560713 +0100 +@@ -274,7 +274,7 @@ + /**************** + * Make a DSA signature from HASH and put it into r and s. + * +- * Without generating the k this function runs in ++ * Without generating the k this function runs in + * about 26ms on a 300 Mhz Mobile Pentium + */ + +@@ -285,6 +285,8 @@ + MPI kinv; + MPI tmp; + ++ mpi_normalize (hash); ++ + /* select a random k with 0 < k < q */ + k = gen_k( skey->q ); + +@@ -311,7 +313,7 @@ + /**************** + * Returns true if the signature composed from R and S is valid. + * +- * Without the checks this function runs in ++ * Without the checks this function runs in + * about 31ms on a 300 Mhz Mobile Pentium + */ + static int +diff -Naur gnupg-1.4.14/cipher/elgamal.c gnupg-1.4.14.new/cipher/elgamal.c +--- gnupg-1.4.14/cipher/elgamal.c 2013-07-19 11:37:59.000000000 +0200 ++++ gnupg-1.4.14.new/cipher/elgamal.c 2014-01-18 08:14:11.474560713 +0100 +@@ -374,6 +374,9 @@ + { + MPI t1 = mpi_alloc_secure( mpi_get_nlimbs( skey->p ) ); + ++ mpi_normalize (a); ++ mpi_normalize (b); ++ + /* output = b/(a^x) mod p */ + mpi_powm( t1, a, skey->x, skey->p ); + mpi_invm( t1, t1, skey->p ); +diff -Naur gnupg-1.4.14/cipher/random.c gnupg-1.4.14.new/cipher/random.c +--- gnupg-1.4.14/cipher/random.c 2013-07-19 11:37:59.000000000 +0200 ++++ gnupg-1.4.14.new/cipher/random.c 2014-01-18 08:14:11.471560713 +0100 +@@ -284,6 +284,18 @@ + } + + ++/* Randomize the MPI by setting it to NBITS of random of quality LEVEL. */ ++void ++randomize_mpi (MPI mpi, size_t nbits, int level) ++{ ++ unsigned char *buffer; ++ ++ buffer = get_random_bits (nbits, level, mpi_is_secure (mpi)); ++ mpi_set_buffer (mpi, buffer, (nbits+7)/8, 0); ++ xfree (buffer); ++} ++ ++ + int + random_is_faked() + { +diff -Naur gnupg-1.4.14/cipher/random.h gnupg-1.4.14.new/cipher/random.h +--- gnupg-1.4.14/cipher/random.h 2013-07-19 11:37:59.000000000 +0200 ++++ gnupg-1.4.14.new/cipher/random.h 2014-01-18 08:14:11.471560713 +0100 +@@ -30,6 +30,7 @@ + int random_is_faked(void); + void random_disable_locking (void); + void randomize_buffer( byte *buffer, size_t length, int level ); ++void randomize_mpi (MPI mpi, size_t nbits, int level); + byte *get_random_bits( size_t nbits, int level, int secure ); + void fast_random_poll( void ); + +diff -Naur gnupg-1.4.14/cipher/rsa.c gnupg-1.4.14.new/cipher/rsa.c +--- gnupg-1.4.14/cipher/rsa.c 2013-07-19 11:37:59.000000000 +0200 ++++ gnupg-1.4.14.new/cipher/rsa.c 2014-01-18 08:14:11.475560713 +0100 +@@ -1,5 +1,5 @@ + /* rsa.c - RSA function +- * Copyright (C) 1997, 1998, 1999 by Werner Koch (dd9jn) ++ * Copyright (C) 1997, 1998, 1999, 2013 by Werner Koch (dd9jn) + * Copyright (C) 2000, 2001 Free Software Foundation, Inc. + * + * This file is part of GnuPG. +@@ -22,7 +22,7 @@ + which expires on September 20, 2000. The patent holder placed that + patent into the public domain on Sep 6th, 2000. + */ +- ++ + #include <config.h> + #include <stdio.h> + #include <stdlib.h> +@@ -32,6 +32,10 @@ + #include "cipher.h" + #include "rsa.h" + ++/* Blinding is used to mitigate side-channel attacks. You may undef ++ this to speed up the operation in case the system is secured ++ against physical and network mounted side-channel attacks. */ ++#define USE_BLINDING 1 + + typedef struct { + MPI n; /* modulus */ +@@ -103,7 +107,7 @@ + + /* make sure that nbits is even so that we generate p, q of equal size */ + if ( (nbits&1) ) +- nbits++; ++ nbits++; + + n = mpi_alloc ( mpi_nlimb_hint_from_nbits (nbits) ); + +@@ -146,7 +150,7 @@ + 65537 as the new best practice. See FIPS-186-3. + */ + e = mpi_alloc ( mpi_nlimb_hint_from_nbits (32) ); +- mpi_set_ui( e, 65537); ++ mpi_set_ui( e, 65537); + while( !mpi_gcd(t1, e, phi) ) /* (while gcd is not 1) */ + mpi_add_ui( e, e, 2); + +@@ -268,7 +272,7 @@ + mpi_invm(t, skey->p, skey->q ); + if ( mpi_cmp(t, skey->u ) ) + log_info ( "RSA Oops: u is wrong\n"); +- ++ + log_info ( "RSA secret key check finished\n"); + + mpi_free (t); +@@ -286,9 +290,9 @@ + * + * Or faster: + * +- * m1 = c ^ (d mod (p-1)) mod p +- * m2 = c ^ (d mod (q-1)) mod q +- * h = u * (m2 - m1) mod q ++ * m1 = c ^ (d mod (p-1)) mod p ++ * m2 = c ^ (d mod (q-1)) mod q ++ * h = u * (m2 - m1) mod q + * m = m1 + h * p + * + * Where m is OUTPUT, c is INPUT and d,n,p,q,u are elements of SKEY. +@@ -299,13 +303,31 @@ + #if 0 + mpi_powm( output, input, skey->d, skey->n ); + #else +- MPI m1 = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 ); +- MPI m2 = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 ); +- MPI h = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 ); ++ int nlimbs = mpi_get_nlimbs (skey->n)+1; ++ MPI m1 = mpi_alloc_secure (nlimbs); ++ MPI m2 = mpi_alloc_secure (nlimbs); ++ MPI h = mpi_alloc_secure (nlimbs); ++# ifdef USE_BLINDING ++ MPI bdata= mpi_alloc_secure (nlimbs); ++ MPI r = mpi_alloc_secure (nlimbs); ++# endif /* USE_BLINDING */ ++ ++ /* Remove superfluous leading zeroes from INPUT. */ ++ mpi_normalize (input); ++ ++# ifdef USE_BLINDING ++ /* Blind: bdata = (data * r^e) mod n */ ++ randomize_mpi (r, mpi_get_nbits (skey->n), 0); ++ mpi_fdiv_r (r, r, skey->n); ++ mpi_powm (bdata, r, skey->e, skey->n); ++ mpi_mulm (bdata, bdata, input, skey->n); ++ input = bdata; ++# endif /* USE_BLINDING */ + ++ /* RSA secret operation: */ + /* m1 = c ^ (d mod (p-1)) mod p */ + mpi_sub_ui( h, skey->p, 1 ); +- mpi_fdiv_r( h, skey->d, h ); ++ mpi_fdiv_r( h, skey->d, h ); + mpi_powm( m1, input, h, skey->p ); + /* m2 = c ^ (d mod (q-1)) mod q */ + mpi_sub_ui( h, skey->q, 1 ); +@@ -313,14 +335,21 @@ + mpi_powm( m2, input, h, skey->q ); + /* h = u * ( m2 - m1 ) mod q */ + mpi_sub( h, m2, m1 ); +- if ( mpi_is_neg( h ) ) ++ if ( mpi_is_neg( h ) ) + mpi_add ( h, h, skey->q ); +- mpi_mulm( h, skey->u, h, skey->q ); ++ mpi_mulm( h, skey->u, h, skey->q ); + /* m = m2 + h * p */ + mpi_mul ( h, h, skey->p ); + mpi_add ( output, m1, h ); +- /* ready */ +- ++ ++# ifdef USE_BLINDING ++ mpi_free (bdata); ++ /* Unblind: output = (output * r^(-1)) mod n */ ++ mpi_invm (r, r, skey->n); ++ mpi_mulm (output, output, r, skey->n); ++ mpi_free (r); ++# endif /* USE_BLINDING */ ++ + mpi_free ( h ); + mpi_free ( m1 ); + mpi_free ( m2 ); +@@ -395,6 +424,7 @@ + rsa_decrypt( int algo, MPI *result, MPI *data, MPI *skey ) + { + RSA_secret_key sk; ++ MPI input; + + if( algo != 1 && algo != 2 ) + return G10ERR_PUBKEY_ALGO; +@@ -405,8 +435,16 @@ + sk.p = skey[3]; + sk.q = skey[4]; + sk.u = skey[5]; +- *result = mpi_alloc_secure( mpi_get_nlimbs( sk.n ) ); +- secret( *result, data[0], &sk ); ++ ++ /* Better make sure that there are no superfluous leading zeroes ++ in the input and it has not been padded using multiples of N. ++ This mitigates side-channel attacks (CVE-2013-4576). */ ++ input = mpi_alloc (0); ++ mpi_normalize (data[0]); ++ mpi_fdiv_r (input, data[0], sk.n); ++ *result = mpi_alloc_secure (mpi_get_nlimbs (sk.n)); ++ secret (*result, input, &sk); ++ mpi_free (input); + return 0; + } + +diff -Naur gnupg-1.4.14/g10/gpgv.c gnupg-1.4.14.new/g10/gpgv.c +--- gnupg-1.4.14/g10/gpgv.c 2013-07-25 10:37:39.000000000 +0200 ++++ gnupg-1.4.14.new/g10/gpgv.c 2014-01-18 08:14:11.473560713 +0100 +@@ -389,6 +389,7 @@ + void random_dump_stats(void) {} + int quick_random_gen( int onoff ) { return -1;} + void randomize_buffer( byte *buffer, size_t length, int level ) {} ++void randomize_mpi (MPI mpi, size_t nbits, int level) {} + int random_is_faked() { return -1;} + byte *get_random_bits( size_t nbits, int level, int secure ) { return NULL;} + void set_random_seed_file( const char *name ) {} diff --git a/source/apps/gnupg/FrugalBuild b/source/apps/gnupg/FrugalBuild index fc5a028..31d0647 100644 --- a/source/apps/gnupg/FrugalBuild +++ b/source/apps/gnupg/FrugalBuild @@ -1,9 +1,11 @@ # Compiling Time: 0.41 SBU # Maintainer: Miklos Vajna <[email protected]> +options+=('asneeded') + pkgname=gnupg pkgver=1.4.14 -pkgrel=1 +pkgrel=2arcturus1 pkgdesc="GnuPG is a complete and free replacement for PGP" url="http://www.gnupg.org/" rodepends=('gpgv') @@ -24,6 +26,12 @@ subgroups=('base chroot-core') subarchs=('i686 x86_64 arm') subrodepends=('zlib bzip2') +# FSA fix *** +source=(${source[@]} CVE-2013-4351.patch CVE-2013-4402.patch CVE-2013-4576.patch) +signatures=(${signatures[@]} '' '' '') +# *********** + + build() { Fbuild _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
