From: Nikos Mavrogiannopoulos Date: Tue, 25 Jul 2017 11:12:19 +0000 (+0200) Subject: cleanup: removed unnecessary/duplicate parameters in functions X-Git-Tag: gnutls_3_6_0~207 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a789ad07e1de01dec16d10c56bec8ca8be855e24;p=thirdparty%2Fgnutls.git cleanup: removed unnecessary/duplicate parameters in functions Signed-off-by: Nikos Mavrogiannopoulos --- diff --git a/lib/pubkey.c b/lib/pubkey.c index 18872cd227..46d45e0690 100644 --- a/lib/pubkey.c +++ b/lib/pubkey.c @@ -455,7 +455,6 @@ gnutls_pubkey_export(gnutls_pubkey_t key, result = _gnutls_x509_encode_and_copy_PKI_params(spk, "", - key->pk_algorithm, &key->params); if (result < 0) { gnutls_assert(); @@ -520,7 +519,6 @@ gnutls_pubkey_export2(gnutls_pubkey_t key, result = _gnutls_x509_encode_and_copy_PKI_params(spk, "", - key->pk_algorithm, &key->params); if (result < 0) { gnutls_assert(); @@ -578,7 +576,7 @@ gnutls_pubkey_get_key_id(gnutls_pubkey_t key, unsigned int flags, } ret = - _gnutls_get_key_id(key->pk_algorithm, &key->params, + _gnutls_get_key_id(&key->params, output_data, output_data_size, flags); if (ret < 0) { gnutls_assert(); @@ -1050,7 +1048,6 @@ int gnutls_x509_crt_set_pubkey(gnutls_x509_crt_t crt, gnutls_pubkey_t key) result = _gnutls_x509_encode_and_copy_PKI_params(crt->cert, "tbsCertificate.subjectPublicKeyInfo", - key->pk_algorithm, &key->params); if (result < 0) { @@ -1089,7 +1086,7 @@ int gnutls_x509_crq_set_pubkey(gnutls_x509_crq_t crq, gnutls_pubkey_t key) result = _gnutls_x509_encode_and_copy_PKI_params (crq->crq, "certificationRequestInfo.subjectPKInfo", - key->pk_algorithm, &key->params); + &key->params); if (result < 0) { gnutls_assert(); diff --git a/lib/x509/common.c b/lib/x509/common.c index bd78b24b35..1b35f7cd73 100644 --- a/lib/x509/common.c +++ b/lib/x509/common.c @@ -1032,8 +1032,6 @@ _asnstr_append_name(char *name, size_t name_size, const char *part1, int _gnutls_x509_encode_and_copy_PKI_params(ASN1_TYPE dst, const char *dst_name, - gnutls_pk_algorithm_t - pk_algorithm, gnutls_pk_params_st * params) { const char *oid; @@ -1041,7 +1039,7 @@ _gnutls_x509_encode_and_copy_PKI_params(ASN1_TYPE dst, int result; char name[128]; - oid = gnutls_pk_get_oid(pk_algorithm); + oid = gnutls_pk_get_oid(params->algo); if (oid == NULL) { gnutls_assert(); return GNUTLS_E_UNKNOWN_PK_ALGORITHM; @@ -1059,7 +1057,7 @@ _gnutls_x509_encode_and_copy_PKI_params(ASN1_TYPE dst, } result = - _gnutls_x509_write_pubkey_params(pk_algorithm, params, &der); + _gnutls_x509_write_pubkey_params(params, &der); if (result < 0) { gnutls_assert(); return result; @@ -1076,7 +1074,7 @@ _gnutls_x509_encode_and_copy_PKI_params(ASN1_TYPE dst, return _gnutls_asn2err(result); } - result = _gnutls_x509_write_pubkey(pk_algorithm, params, &der); + result = _gnutls_x509_write_pubkey(params, &der); if (result < 0) { gnutls_assert(); return result; @@ -1102,8 +1100,7 @@ _gnutls_x509_encode_and_copy_PKI_params(ASN1_TYPE dst, */ int _gnutls_x509_encode_PKI_params(gnutls_datum_t * der, - gnutls_pk_algorithm_t - pk_algorithm, gnutls_pk_params_st * params) + gnutls_pk_params_st * params) { int ret; ASN1_TYPE tmp; @@ -1117,7 +1114,6 @@ _gnutls_x509_encode_PKI_params(gnutls_datum_t * der, ret = _gnutls_x509_encode_and_copy_PKI_params(tmp, "tbsCertificate.subjectPublicKeyInfo", - pk_algorithm, params); if (ret != ASN1_SUCCESS) { gnutls_assert(); diff --git a/lib/x509/common.h b/lib/x509/common.h index 34e6d5b5de..eafc7a515b 100644 --- a/lib/x509/common.h +++ b/lib/x509/common.h @@ -175,11 +175,8 @@ _gnutls_x509_get_signature_algorithm(ASN1_TYPE src, const char *src_name); int _gnutls_x509_encode_and_copy_PKI_params(ASN1_TYPE dst, const char *dst_name, - gnutls_pk_algorithm_t - pk_algorithm, gnutls_pk_params_st * params); int _gnutls_x509_encode_PKI_params(gnutls_datum_t * der, - gnutls_pk_algorithm_t, gnutls_pk_params_st * params); int _gnutls_asn1_copy_node(ASN1_TYPE * dst, const char *dst_name, ASN1_TYPE src, const char *src_name); @@ -194,7 +191,7 @@ int _gnutls_x509_get_signature(ASN1_TYPE src, const char *src_name, int _gnutls_get_asn_mpis(ASN1_TYPE asn, const char *root, gnutls_pk_params_st * params); -int _gnutls_get_key_id(gnutls_pk_algorithm_t pk, gnutls_pk_params_st *, +int _gnutls_get_key_id(gnutls_pk_params_st *, unsigned char *output_data, size_t * output_data_size, unsigned flags); diff --git a/lib/x509/crq.c b/lib/x509/crq.c index 1bbab4e3ea..f0f2307950 100644 --- a/lib/x509/crq.c +++ b/lib/x509/crq.c @@ -921,7 +921,7 @@ gnutls_x509_crq_set_key(gnutls_x509_crq_t crq, gnutls_x509_privkey_t key) result = _gnutls_x509_encode_and_copy_PKI_params (crq->crq, "certificationRequestInfo.subjectPKInfo", - key->pk_algorithm, &key->params); + &key->params); if (result < 0) { gnutls_assert(); @@ -1039,11 +1039,12 @@ gnutls_x509_crq_set_key_rsa_raw(gnutls_x509_crq_t crq, } temp_params.params_nr = RSA_PUBLIC_PARAMS; + temp_params.algo = GNUTLS_PK_RSA; result = _gnutls_x509_encode_and_copy_PKI_params (crq->crq, "certificationRequestInfo.subjectPKInfo", - GNUTLS_PK_RSA, &temp_params); + &temp_params); if (result < 0) { gnutls_assert(); @@ -2759,7 +2760,7 @@ gnutls_x509_crq_get_key_id(gnutls_x509_crq_t crq, unsigned int flags, unsigned char *output_data, size_t * output_data_size) { - int pk, ret = 0; + int ret = 0; gnutls_pk_params_st params; if (crq == NULL) { @@ -2767,12 +2768,6 @@ gnutls_x509_crq_get_key_id(gnutls_x509_crq_t crq, unsigned int flags, return GNUTLS_E_INVALID_REQUEST; } - pk = gnutls_x509_crq_get_pk_algorithm(crq, NULL); - if (pk < 0) { - gnutls_assert(); - return pk; - } - ret = _gnutls_x509_crq_get_mpis(crq, ¶ms); if (ret < 0) { gnutls_assert(); @@ -2780,7 +2775,7 @@ gnutls_x509_crq_get_key_id(gnutls_x509_crq_t crq, unsigned int flags, } ret = - _gnutls_get_key_id(pk, ¶ms, output_data, output_data_size, flags); + _gnutls_get_key_id(¶ms, output_data, output_data_size, flags); gnutls_pk_params_release(¶ms); diff --git a/lib/x509/key_encode.c b/lib/x509/key_encode.c index 1c07ae3f21..3b0ac7c79c 100644 --- a/lib/x509/key_encode.c +++ b/lib/x509/key_encode.c @@ -157,11 +157,10 @@ _gnutls_x509_write_eddsa_pubkey(gnutls_pk_params_st * params, } int -_gnutls_x509_write_pubkey_params(gnutls_pk_algorithm_t algo, - gnutls_pk_params_st * params, +_gnutls_x509_write_pubkey_params(gnutls_pk_params_st * params, gnutls_datum_t * der) { - switch (algo) { + switch (params->algo) { case GNUTLS_PK_DSA: return _gnutls_x509_write_dsa_params(params, der); case GNUTLS_PK_RSA: @@ -187,11 +186,10 @@ _gnutls_x509_write_pubkey_params(gnutls_pk_algorithm_t algo, } int -_gnutls_x509_write_pubkey(gnutls_pk_algorithm_t algo, - gnutls_pk_params_st * params, +_gnutls_x509_write_pubkey(gnutls_pk_params_st * params, gnutls_datum_t * der) { - switch (algo) { + switch (params->algo) { case GNUTLS_PK_DSA: return _gnutls_x509_write_dsa_pubkey(params, der); case GNUTLS_PK_RSA: diff --git a/lib/x509/mpi.c b/lib/x509/mpi.c index 9b3ded189e..4574deead8 100644 --- a/lib/x509/mpi.c +++ b/lib/x509/mpi.c @@ -127,6 +127,7 @@ _gnutls_get_asn_mpis(ASN1_TYPE asn, const char *root, pk_algorithm = result; params->flags = curve; + params->algo = pk_algorithm; /* Read the algorithm's parameters */ diff --git a/lib/x509/privkey.c b/lib/x509/privkey.c index 2b0da8d7fd..b152ee55fd 100644 --- a/lib/x509/privkey.c +++ b/lib/x509/privkey.c @@ -1979,7 +1979,7 @@ gnutls_x509_privkey_get_key_id(gnutls_x509_privkey_t key, } ret = - _gnutls_get_key_id(key->pk_algorithm, &key->params, + _gnutls_get_key_id(&key->params, output_data, output_data_size, flags); if (ret < 0) { gnutls_assert(); diff --git a/lib/x509/privkey_pkcs8.c b/lib/x509/privkey_pkcs8.c index 2349c4e768..afede88324 100644 --- a/lib/x509/privkey_pkcs8.c +++ b/lib/x509/privkey_pkcs8.c @@ -150,8 +150,7 @@ encode_to_private_key_info(gnutls_x509_privkey_t pkey, } result = - _gnutls_x509_write_pubkey_params(pkey->pk_algorithm, - &pkey->params, &algo_params); + _gnutls_x509_write_pubkey_params(&pkey->params, &algo_params); if (result < 0) { gnutls_assert(); return result; diff --git a/lib/x509/x509.c b/lib/x509/x509.c index a80e29ebe7..8e5a15c2c2 100644 --- a/lib/x509/x509.c +++ b/lib/x509/x509.c @@ -2931,7 +2931,7 @@ gnutls_x509_crt_export2(gnutls_x509_crt_t cert, } int -_gnutls_get_key_id(gnutls_pk_algorithm_t pk, gnutls_pk_params_st * params, +_gnutls_get_key_id(gnutls_pk_params_st * params, unsigned char *output_data, size_t * output_data_size, unsigned flags) { @@ -2952,7 +2952,7 @@ _gnutls_get_key_id(gnutls_pk_algorithm_t pk, gnutls_pk_params_st * params, return GNUTLS_E_SHORT_MEMORY_BUFFER; } - ret = _gnutls_x509_encode_PKI_params(&der, pk, params); + ret = _gnutls_x509_encode_PKI_params(&der, params); if (ret < 0) return gnutls_assert_val(ret); @@ -2996,7 +2996,7 @@ gnutls_x509_crt_get_key_id(gnutls_x509_crt_t crt, unsigned int flags, unsigned char *output_data, size_t * output_data_size) { - int pk, ret = 0; + int ret = 0; gnutls_pk_params_st params; if (crt == NULL) { @@ -3004,12 +3004,6 @@ gnutls_x509_crt_get_key_id(gnutls_x509_crt_t crt, unsigned int flags, return GNUTLS_E_INVALID_REQUEST; } - pk = gnutls_x509_crt_get_pk_algorithm(crt, NULL); - if (pk < 0) { - gnutls_assert(); - return pk; - } - /* initializes params */ ret = _gnutls_x509_crt_get_mpis(crt, ¶ms); if (ret < 0) { @@ -3018,7 +3012,7 @@ gnutls_x509_crt_get_key_id(gnutls_x509_crt_t crt, unsigned int flags, } ret = - _gnutls_get_key_id(pk, ¶ms, output_data, output_data_size, flags); + _gnutls_get_key_id(¶ms, output_data, output_data_size, flags); gnutls_pk_params_release(¶ms); diff --git a/lib/x509/x509_int.h b/lib/x509/x509_int.h index 2d7e881997..f672e574a9 100644 --- a/lib/x509/x509_int.h +++ b/lib/x509/x509_int.h @@ -347,11 +347,9 @@ int _gnutls_x509_write_eddsa_pubkey(gnutls_pk_params_st * params, gnutls_datum_t * der); int -_gnutls_x509_write_pubkey_params(gnutls_pk_algorithm_t algo, - gnutls_pk_params_st * params, +_gnutls_x509_write_pubkey_params(gnutls_pk_params_st * params, gnutls_datum_t * der); -int _gnutls_x509_write_pubkey(gnutls_pk_algorithm_t, - gnutls_pk_params_st * params, +int _gnutls_x509_write_pubkey(gnutls_pk_params_st * params, gnutls_datum_t * der); int _gnutls_x509_read_uint(ASN1_TYPE node, const char *value, diff --git a/lib/x509/x509_write.c b/lib/x509/x509_write.c index e228d98f23..3d05bb1f39 100644 --- a/lib/x509/x509_write.c +++ b/lib/x509/x509_write.c @@ -239,7 +239,6 @@ gnutls_x509_crt_set_key(gnutls_x509_crt_t crt, gnutls_x509_privkey_t key) result = _gnutls_x509_encode_and_copy_PKI_params(crt->cert, "tbsCertificate.subjectPublicKeyInfo", - key->pk_algorithm, &key->params); if (result < 0) {