]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
cleanup: removed unnecessary/duplicate parameters in functions
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 25 Jul 2017 11:12:19 +0000 (13:12 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Thu, 3 Aug 2017 09:57:52 +0000 (11:57 +0200)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
lib/pubkey.c
lib/x509/common.c
lib/x509/common.h
lib/x509/crq.c
lib/x509/key_encode.c
lib/x509/mpi.c
lib/x509/privkey.c
lib/x509/privkey_pkcs8.c
lib/x509/x509.c
lib/x509/x509_int.h
lib/x509/x509_write.c

index 18872cd227e43b74afd0e97c0469b6d5ebdea1f9..46d45e06904db25ed34cb63156538e0c06b9cccb 100644 (file)
@@ -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();
index bd78b24b3574fbb4c43570dd8316d252fa7160ce..1b35f7cd734b09019af157e6535b96a3cfe84fdc 100644 (file)
@@ -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();
index 34e6d5b5debf781d25296105711fc57e755aee70..eafc7a515b7e811ac7c586b30ae8556459f5c2d3 100644 (file)
@@ -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);
 
index 1bbab4e3eae950071fcd17f5fe94eddb26e12a88..f0f23079503f480a0e7c4ac93ee65f80928197bc 100644 (file)
@@ -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, &params);
        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, &params, output_data, output_data_size, flags);
+           _gnutls_get_key_id(&params, output_data, output_data_size, flags);
 
        gnutls_pk_params_release(&params);
 
index 1c07ae3f216cfb0521493b9f0c278b2b6bcace41..3b0ac7c79c8234cacf52aa8e508fd9c0387f3eee 100644 (file)
@@ -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:
index 9b3ded189eb8120ca7f678049acceb1809f44fc3..4574deead8a9eeb48c6eebf9e144f52cfab1946e 100644 (file)
@@ -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
         */
index 2b0da8d7fdbe283f400fb7769f505490e0d9928a..b152ee55fde3d47b9e9d08e6741ec2d0a08e960a 100644 (file)
@@ -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();
index 2349c4e768271b744678399ece6acdd0765cbc29..afede88324b7308d766e46abdf531104037badcb 100644 (file)
@@ -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;
index a80e29ebe72536416ca6791cbc6d19808e703ce0..8e5a15c2c20778ecf010f41fa4b786b242028087 100644 (file)
@@ -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, &params);
        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, &params, output_data, output_data_size, flags);
+           _gnutls_get_key_id(&params, output_data, output_data_size, flags);
 
        gnutls_pk_params_release(&params);
 
index 2d7e881997081bacf1646d3f62411d3331d5ec35..f672e574a95fb9b2e575ee257a054cacb58047f0 100644 (file)
@@ -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,
index e228d98f235c4dd7cd6cc18f7a46af1b89ad554c..3d05bb1f39d4ec8cff120c8e9edd04487e39c911 100644 (file)
@@ -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) {