]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Define MODP_CUSTOM constructors as variadic functions
authorTobias Brunner <tobias@strongswan.org>
Thu, 14 Sep 2017 12:03:08 +0000 (14:03 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 18 Sep 2017 10:07:26 +0000 (12:07 +0200)
They now match the dh_constructor_t signature.  This is a follow up for
the changes merged with b668bf3f9ec1 and should fix use of MODP_CUSTOM on
Apple's ARM64 platform.

src/libstrongswan/plugins/gcrypt/gcrypt_dh.c
src/libstrongswan/plugins/gcrypt/gcrypt_dh.h
src/libstrongswan/plugins/gmp/gmp_diffie_hellman.c
src/libstrongswan/plugins/gmp/gmp_diffie_hellman.h
src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c
src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h
src/libstrongswan/plugins/pkcs11/pkcs11_dh.c
src/libstrongswan/plugins/pkcs11/pkcs11_dh.h

index cee25ea74b79926539b911649991225f90a93c23..5519125ba579c4b8ff8d1a60627d5ff6c2e648a7 100644 (file)
@@ -289,11 +289,13 @@ gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group)
 /*
  * Described in header.
  */
-gcrypt_dh_t *gcrypt_dh_create_custom(diffie_hellman_group_t group,
-                                                                        chunk_t g, chunk_t p)
+gcrypt_dh_t *gcrypt_dh_create_custom(diffie_hellman_group_t group, ...)
 {
        if (group == MODP_CUSTOM)
        {
+               chunk_t g, p;
+
+               VA_ARGS_GET(group, g, p);
                return create_generic(group, p.len, g, p);
        }
        return NULL;
index a70958dc41ad9d3aec027d542b75ecc2ec4fc392..c6259f7acbf0cd15bc22c7f71cd5ddc9089afe86 100644 (file)
@@ -48,12 +48,10 @@ gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group);
  * Creates a new gcrypt_dh_t object for MODP_CUSTOM.
  *
  * @param group                        MODP_CUSTOM
- * @param g                            generator
- * @param p                            prime
+ * @param ...                  expects generator and prime as chunk_t
  * @return                             gcrypt_dh_t object, NULL if not supported
  */
-gcrypt_dh_t *gcrypt_dh_create_custom(diffie_hellman_group_t group,
-                                                                        chunk_t g, chunk_t p);
+gcrypt_dh_t *gcrypt_dh_create_custom(diffie_hellman_group_t group, ...);
 
 #endif /** GCRYPT_DH_H_ @}*/
 
index b7ee94ee0b24f4f51fc490829a472f0d8f6afde6..b01adfe01e19d664d64b21849af52831d28cd79f 100644 (file)
@@ -272,7 +272,7 @@ static gmp_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
 }
 
 /*
- * Described in header.
+ * Described in header
  */
 gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group)
 {
@@ -287,12 +287,17 @@ gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group)
                                                  params->generator, params->prime);
 }
 
-
+/*
+ * Described in header
+ */
 gmp_diffie_hellman_t *gmp_diffie_hellman_create_custom(
-                                                       diffie_hellman_group_t group, chunk_t g, chunk_t p)
+                                                                                       diffie_hellman_group_t group, ...)
 {
        if (group == MODP_CUSTOM)
        {
+               chunk_t g, p;
+
+               VA_ARGS_GET(group, g, p);
                return create_generic(MODP_CUSTOM, p.len, g, p);
        }
        return NULL;
index 6d73c08638427003653bf54114a76bb86ba03cfb..a8cde7bca0b498d107a333cc1035b7a9200fdc77 100644 (file)
@@ -49,12 +49,11 @@ gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group);
  * Creates a new gmp_diffie_hellman_t object for MODP_CUSTOM.
  *
  * @param group                        MODP_CUSTOM
- * @param g                            generator
- * @param p                            prime
+ * @param ...                  expects generator and prime as chunk_t
  * @return                             gmp_diffie_hellman_t object, NULL if not supported
  */
 gmp_diffie_hellman_t *gmp_diffie_hellman_create_custom(
-                                                       diffie_hellman_group_t group, chunk_t g, chunk_t p);
+                                                       diffie_hellman_group_t group, ...);
 
 #endif /** GMP_DIFFIE_HELLMAN_H_ @}*/
 
index f08dfff7e8f117facd55a0c1de25e6c80c43786c..8e9c1183fe98cb93c52c0637ac2f0fa4016fdff8 100644 (file)
@@ -193,7 +193,7 @@ METHOD(diffie_hellman_t, destroy, void,
  * Described in header.
  */
 openssl_diffie_hellman_t *openssl_diffie_hellman_create(
-                                                       diffie_hellman_group_t group, chunk_t g, chunk_t p)
+                                                                                       diffie_hellman_group_t group, ...)
 {
        private_openssl_diffie_hellman_t *this;
        const BIGNUM *privkey;
@@ -225,6 +225,9 @@ openssl_diffie_hellman_t *openssl_diffie_hellman_create(
 
        if (group == MODP_CUSTOM)
        {
+               chunk_t g, p;
+
+               VA_ARGS_GET(group, g, p);
                if (!DH_set0_pqg(this->dh, BN_bin2bn(p.ptr, p.len, NULL), NULL,
                                                 BN_bin2bn(g.ptr, g.len, NULL)))
                {
index 53dc59c78b9d947926c7765c52610e21064aabf6..5de5520b5a992f83269a201dbfedcc0283f20699 100644 (file)
@@ -40,12 +40,11 @@ struct openssl_diffie_hellman_t {
  * Creates a new openssl_diffie_hellman_t object.
  *
  * @param group                        Diffie Hellman group number to use
- * @param g                            custom generator, if MODP_CUSTOM
- * @param p                            custom prime, if MODP_CUSTOM
+ * @param ...                  expects generator and prime as chunk_t if MODP_CUSTOM
  * @return                             openssl_diffie_hellman_t object, NULL if not supported
  */
 openssl_diffie_hellman_t *openssl_diffie_hellman_create(
-                                                       diffie_hellman_group_t group, chunk_t g, chunk_t p);
+                                                                                       diffie_hellman_group_t group, ...);
 
 #endif /** OPENSSL_DIFFIE_HELLMAN_H_ @}*/
 
index c0033bd8e34087837043edf1bcc8022dd3ef64c8..b0fa41b6a31cf96136f7d90dd8afb7ef26324fce 100644 (file)
@@ -415,13 +415,15 @@ static chunk_t ecparams_lookup(diffie_hellman_group_t group)
 /**
  * Described in header.
  */
-pkcs11_dh_t *pkcs11_dh_create(diffie_hellman_group_t group,
-                                                         chunk_t g, chunk_t p)
+pkcs11_dh_t *pkcs11_dh_create(diffie_hellman_group_t group, ...)
 {
        switch (group)
        {
                case MODP_CUSTOM:
                {
+                       chunk_t g, p;
+
+                       VA_ARGS_GET(group, g, p);
                        return create_modp(group, p.len, g, p);
                }
                case ECP_192_BIT:
index 2654130c0755795f21ca14881fc604463ec18893..1ad58e7a12dbccf9569b3fd3a40fa526654724c2 100644 (file)
@@ -40,12 +40,10 @@ struct pkcs11_dh_t {
  * Creates a new pkcs11_dh_t object.
  *
  * @param group                        Diffie Hellman group number to use
- * @param g                            generator in case group is MODP_CUSTOM
- * @param p                            prime in case group is MODP_CUSTOM
+ * @param ...                  expects generator and prime as chunk_t if MODP_CUSTOM
  * @return                             pkcs11_dh_t object, NULL if not supported
  */
-pkcs11_dh_t *pkcs11_dh_create(diffie_hellman_group_t group,
-                                                         chunk_t g, chunk_t p);
+pkcs11_dh_t *pkcs11_dh_create(diffie_hellman_group_t group, ...);
 
 #endif /** PKCS11_DH_H_ @}*/