[git] GnuPG - branch, STABLE-BRANCH-1-4, updated. gnupg-1.4.19-4-g04667ca
by NIIBE Yutaka
cvs at cvs.gnupg.org
Thu Apr 30 10:24:39 CEST 2015
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".
The branch, STABLE-BRANCH-1-4 has been updated
via 04667cabef2d6aaa214b288482bb902c891893a5 (commit)
from 506eb6fec67f170827777f2f44ced6f50745a0ad (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 04667cabef2d6aaa214b288482bb902c891893a5
Author: NIIBE Yutaka <gniibe at fsij.org>
Date: Thu Apr 30 17:20:08 2015 +0900
g10: fix cmp_public_key and cmp_secret_keys.
* g10/free-packet.c (cmp_public_keys, cmp_secret_keys): Compare opaque
data at the first entry of the array when it's unknown algo.
* mpi/mpi-cmp.c (mpi_cmp): Backport libgcrypt 1.5.0's semantics.
--
(backported from 2.0 commit 43429c7869152f301157e4b24790b3801dce0f0a)
GnuPG-bug-id: 1962
diff --git a/g10/free-packet.c b/g10/free-packet.c
index 0f8e0e8..e772c08 100644
--- a/g10/free-packet.c
+++ b/g10/free-packet.c
@@ -452,11 +452,14 @@ cmp_public_keys( PKT_public_key *a, PKT_public_key *b )
return -1;
n = pubkey_get_npkey( b->pubkey_algo );
- if( !n )
- return -1; /* can't compare due to unknown algorithm */
- for(i=0; i < n; i++ ) {
- if( mpi_cmp( a->pkey[i], b->pkey[i] ) )
+ if( !n ) { /* unknown algorithm, rest is in opaque MPI */
+ if( mpi_cmp( a->pkey[0], b->pkey[0] ) )
return -1;
+ } else {
+ for(i=0; i < n; i++ ) {
+ if( mpi_cmp( a->pkey[i], b->pkey[i] ) )
+ return -1;
+ }
}
return 0;
@@ -479,11 +482,14 @@ cmp_secret_keys( PKT_secret_key *a, PKT_secret_key *b )
return -1;
n = pubkey_get_npkey( b->pubkey_algo );
- if( !n )
- return -1; /* can't compare due to unknown algorithm */
- for(i=0; i < n; i++ ) {
- if( mpi_cmp( a->skey[i], b->skey[i] ) )
+ if( !n ) { /* unknown algorithm, rest is in opaque MPI */
+ if( mpi_cmp( a->skey[0], b->skey[0] ) )
return -1;
+ } else {
+ for(i=0; i < n; i++ ) {
+ if( mpi_cmp( a->skey[i], b->skey[i] ) )
+ return -1;
+ }
}
return 0;
diff --git a/mpi/mpi-cmp.c b/mpi/mpi-cmp.c
index e119fad..3c1322a 100644
--- a/mpi/mpi-cmp.c
+++ b/mpi/mpi-cmp.c
@@ -20,6 +20,7 @@
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "mpi-internal.h"
int
@@ -49,6 +50,21 @@ mpi_cmp( MPI u, MPI v )
mpi_size_t usize, vsize;
int cmp;
+ if (mpi_is_opaque (u) || mpi_is_opaque (v))
+ {
+ if (mpi_is_opaque (u) && !mpi_is_opaque (v))
+ return -1;
+ if (!mpi_is_opaque (u) && mpi_is_opaque (v))
+ return 1;
+ if (!u->nbits && !v->nbits)
+ return 0; /* Empty buffers are identical. */
+ if (u->nbits < v->nbits)
+ return -1;
+ if (u->nbits > v->nbits)
+ return 1;
+ return memcmp (u->d, v->d, u->nbits);
+ }
+
mpi_normalize( u );
mpi_normalize( v );
usize = u->nlimbs;
-----------------------------------------------------------------------
Summary of changes:
g10/free-packet.c | 22 ++++++++++++++--------
mpi/mpi-cmp.c | 16 ++++++++++++++++
2 files changed, 30 insertions(+), 8 deletions(-)
hooks/post-receive
--
The GNU Privacy Guard
http://git.gnupg.org
More information about the Gnupg-commits
mailing list