From 96f3a4e1b308bb9a44f997effeae9d6f2967a88e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 11 Jul 2013 15:55:14 +0200 Subject: [PATCH] Rm ecp_keypair.alg Avoid duplicating information already present in pk_context. --- include/polarssl/ecp.h | 12 ------------ library/ecp.c | 2 -- library/x509parse.c | 6 ------ 3 files changed, 20 deletions(-) diff --git a/include/polarssl/ecp.h b/include/polarssl/ecp.h index e6f28e652..7bd9bd587 100644 --- a/include/polarssl/ecp.h +++ b/include/polarssl/ecp.h @@ -95,18 +95,12 @@ ecp_group; * \brief ECP key pair structure * * A generic key pair that could be used for ECDSA, fixed ECDH, etc. - * Usage can be restricted to a particular algorithm by the 'alg' field, - * see POLARSSL_ECP_KEY_ALG_* constants (default: unrestricted). - * - * \sa ecdh_context - * \sa ecdsa_context */ typedef struct { ecp_group grp; /*!< Elliptic curve and base point */ mpi d; /*!< our secret value */ ecp_point Q; /*!< our public value */ - int alg; /*!< algorithm to use this key with */ } ecp_keypair; @@ -160,12 +154,6 @@ ecp_keypair; */ #define POLARSSL_ECP_TLS_NAMED_CURVE 3 /**< ECCurveType's named_curve */ -/* - * Algorithm identifiers from RFC 5480 for use with EC keys - */ -#define POLARSSL_ECP_KEY_ALG_UNRESTRICTED 0 /**< RFC 5480 2.1.1 */ -#define POLARSSL_ECP_KEY_ALG_ECDH 1 /**< RFC 5480 2.1.2 */ - #ifdef __cplusplus extern "C" { #endif diff --git a/library/ecp.c b/library/ecp.c index 9e7a96785..14683120a 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -101,7 +101,6 @@ void ecp_keypair_init( ecp_keypair *key ) ecp_group_init( &key->grp ); mpi_init( &key->d ); ecp_point_init( &key->Q ); - key->alg = POLARSSL_ECP_KEY_ALG_UNRESTRICTED; } /* @@ -142,7 +141,6 @@ void ecp_keypair_free( ecp_keypair *key ) ecp_group_free( &key->grp ); mpi_free( &key->d ); ecp_point_free( &key->Q ); - key->alg = POLARSSL_ECP_KEY_ALG_UNRESTRICTED; } /* diff --git a/library/x509parse.c b/library/x509parse.c index 1dca19d42..4fba038d5 100644 --- a/library/x509parse.c +++ b/library/x509parse.c @@ -590,9 +590,6 @@ static int x509_get_pubkey( unsigned char **p, break; case POLARSSL_PK_ECKEY_DH: - ((ecp_keypair *) pk->data)->alg = POLARSSL_ECP_KEY_ALG_ECDH; - /* FALLTHROUGH */ - case POLARSSL_PK_ECKEY: ret = x509_use_ecparams( &alg_params, &pk_ec( *pk )->grp ) || x509_get_ecpubkey( p, end, pk->data ); @@ -2385,9 +2382,6 @@ static int x509parse_key_pkcs8_unencrypted_der( if( pk_alg == POLARSSL_PK_ECKEY || pk_alg == POLARSSL_PK_ECKEY_DH ) { - if( pk_alg == POLARSSL_PK_ECKEY_DH ) - pk_ec( *pk )->alg = POLARSSL_ECP_KEY_ALG_ECDH; - if( ( ret = x509_use_ecparams( ¶ms, &pk_ec( *pk )->grp ) ) != 0 || ( ret = x509parse_key_sec1_der( pk_ec( *pk ), p, len ) ) != 0 ) {