]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
No need to keep Z in parameters since the pubkey can always be converted to an affine...
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 22 May 2011 14:09:14 +0000 (16:09 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 22 May 2011 14:11:16 +0000 (16:11 +0200)
lib/includes/gnutls/crypto.h
lib/nettle/pk.c
lib/x509/key_encode.c
lib/x509/x509_int.h

index 80fbf825d958146693e1b06e85d44550f51c4126..d781c07a7917e37e6eb663fea598fd278b8ebcbf 100644 (file)
@@ -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)
  */
 
 /**
index 971e6f0f0e80e6a5a2b0338e8063899f4a62f6e4..c9acf64ac5022d4dc0767337fb7ed2e68df9880c 100644 (file)
@@ -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);
index 8b44d080013f12b92cc64321cdde59aaff889532..c04480be2d749de1ab3c836463514fd6fa565650 100644 (file)
@@ -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 ();
index 95132ff67c5674641d1647dc938257389daffaa7..4df028befe781f6cae8a345a350ef52f10eeaac5 100644 (file)
@@ -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