From: Nikos Mavrogiannopoulos Date: Sun, 22 May 2011 14:09:14 +0000 (+0200) Subject: No need to keep Z in parameters since the pubkey can always be converted to an affine... X-Git-Tag: gnutls_2_99_2~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98aefa42a4f5ba83d4cb925debf3b3536c4060e7;p=thirdparty%2Fgnutls.git No need to keep Z in parameters since the pubkey can always be converted to an affine point. --- diff --git a/lib/includes/gnutls/crypto.h b/lib/includes/gnutls/crypto.h index 80fbf825d9..d781c07a79 100644 --- a/lib/includes/gnutls/crypto.h +++ b/lib/includes/gnutls/crypto.h @@ -287,8 +287,7 @@ extern "C" * [4] is Gy * [5] is x * [6] is y - * [7] is z - * [8] is k (private key) + * [7] is k (private key) */ /** diff --git a/lib/nettle/pk.c b/lib/nettle/pk.c index 971e6f0f0e..c9acf64ac5 100644 --- a/lib/nettle/pk.c +++ b/lib/nettle/pk.c @@ -109,7 +109,7 @@ static int _wrap_nettle_pk_derive(gnutls_pk_algorithm_t algo, gnutls_datum_t * o memcpy(&ecc_pub.Gy, pub->params[4], sizeof(mpz_t)); memcpy(&ecc_pub.pubkey.x, pub->params[5], sizeof(mpz_t)); memcpy(&ecc_pub.pubkey.y, pub->params[6], sizeof(mpz_t)); - memcpy(&ecc_pub.pubkey.z, pub->params[7], sizeof(mpz_t)); + mpz_init_set_ui(ecc_pub.pubkey.z, 1); ecc_priv.type = PK_PRIVATE; memcpy(&ecc_priv.prime, priv->params[0], sizeof(mpz_t)); @@ -119,8 +119,8 @@ static int _wrap_nettle_pk_derive(gnutls_pk_algorithm_t algo, gnutls_datum_t * o memcpy(&ecc_priv.Gy, priv->params[4], sizeof(mpz_t)); memcpy(&ecc_priv.pubkey.x, priv->params[5], sizeof(mpz_t)); memcpy(&ecc_priv.pubkey.y, priv->params[6], sizeof(mpz_t)); - memcpy(&ecc_priv.pubkey.z, priv->params[7], sizeof(mpz_t)); - memcpy(&ecc_priv.k, priv->params[8], sizeof(mpz_t)); + memcpy(&ecc_priv.k, priv->params[7], sizeof(mpz_t)); + mpz_init_set_ui(ecc_pub.pubkey.z, 1); sz = ECC_BUF_SIZE; out->data = gnutls_malloc(sz); @@ -722,8 +722,7 @@ rsa_fail: mpz_set(TOMPZ(params->params[4]), key.Gy); mpz_set(TOMPZ(params->params[5]), key.pubkey.x); mpz_set(TOMPZ(params->params[6]), key.pubkey.y); - mpz_set(TOMPZ(params->params[7]), key.pubkey.z); - mpz_set(TOMPZ(params->params[8]), key.k); + mpz_set(TOMPZ(params->params[7]), key.k); ecc_fail: ecc_free(&key); diff --git a/lib/x509/key_encode.c b/lib/x509/key_encode.c index 8b44d08001..c04480be2d 100644 --- a/lib/x509/key_encode.c +++ b/lib/x509/key_encode.c @@ -656,7 +656,7 @@ _gnutls_asn1_encode_ecc (ASN1_TYPE * c2, gnutls_pk_params_st * params) goto cleanup; } - ret = _gnutls_x509_write_int (*c2, "privateKey", params->params[8], 1); + ret = _gnutls_x509_write_int (*c2, "privateKey", params->params[7], 1); if (ret < 0) { gnutls_assert (); diff --git a/lib/x509/x509_int.h b/lib/x509/x509_int.h index 95132ff67c..4df028befe 100644 --- a/lib/x509/x509_int.h +++ b/lib/x509/x509_int.h @@ -78,7 +78,7 @@ typedef struct gnutls_pkcs7_int /* parameters should not be larger than this limit */ #define DSA_PUBLIC_PARAMS 4 #define RSA_PUBLIC_PARAMS 2 -#define ECC_PUBLIC_PARAMS 8 +#define ECC_PUBLIC_PARAMS 7 #define MAX_PRIV_PARAMS_SIZE GNUTLS_MAX_PK_PARAMS /* ok for RSA and DSA */ @@ -86,7 +86,7 @@ typedef struct gnutls_pkcs7_int /* parameters should not be larger than this limit */ #define DSA_PRIVATE_PARAMS 5 #define RSA_PRIVATE_PARAMS 8 -#define ECC_PRIVATE_PARAMS 9 +#define ECC_PRIVATE_PARAMS 8 #if MAX_PRIV_PARAMS_SIZE - RSA_PRIVATE_PARAMS < 0 #error INCREASE MAX_PRIV_PARAMS