]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9054 Add support for multiple EECDH curves
authorHoward Chu <hyc@openldap.org>
Thu, 20 Aug 2020 14:07:55 +0000 (15:07 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Fri, 21 Aug 2020 22:21:43 +0000 (22:21 +0000)
Requires OpenSSL 1.0.2 or newer

doc/man/man3/ldap_get_option.3
doc/man/man5/ldap.conf.5
doc/man/man5/slapd-config.5
doc/man/man5/slapd.conf.5
libraries/libldap/init.c
libraries/libldap/tls2.c
libraries/libldap/tls_o.c

index 47bddde84b27666f1d813df30253389bafc461cf..253fe57c7652332a3383db82132f2359d34b8651 100644 (file)
@@ -711,7 +711,7 @@ and its contents need to be freed by the caller using
 Ignored by GnuTLS and Mozilla NSS.
 .TP
 .B LDAP_OPT_X_TLS_ECNAME
-Gets/sets the name of the curve used for
+Gets/sets the name of the curve(s) used for
 elliptic curve key exchanges.
 .BR invalue
 must be
index 52e7df8dee407d480c8e0f0be982634651efe59f..1cf78cd4caab5f6b033c41ff0cc300eaf0cf8b75 100644 (file)
@@ -345,6 +345,12 @@ Use certutil \-L to list the certificates by name:
        certutil \-d /path/to/certdbdir \-L
 .fi
 .TP
+.B TLS_ECNAME <name>
+Specify the name of the curve(s) to use for Elliptic curve Diffie-Hellman
+ephemeral key exchange.  This option is only used for OpenSSL.
+This option is not used with GnuTLS; the curves may be
+chosen in the GnuTLS ciphersuite specification.
+.TP
 .B TLS_KEY <filename>
 Specifies the file that contains the private key that matches the certificate
 stored in the
index 96f79466922aefdc6bf9bd5bfab43c40d868a7c9..3a621b35cbadc942e9925a1346bd54f8b7fc67b3 100644 (file)
@@ -923,9 +923,9 @@ When using Mozilla NSS these parameters are always generated randomly
 so this directive is ignored.
 .TP
 .B olcTLSECName: <name>
-Specify the name of a curve to use for Elliptic curve Diffie-Hellman
-ephemeral key exchange.  This is required to enable ECDHE algorithms in
-OpenSSL.  This option is not used with GnuTLS; the curves may be
+Specify the name of the curve(s) to use for Elliptic curve Diffie-Hellman
+ephemeral key exchange.  This option is only used for OpenSSL.
+This option is not used with GnuTLS; the curves may be
 chosen in the GnuTLS ciphersuite specification. This option is also
 ignored for Mozilla NSS.
 .TP
index ca89c4d77861a827a92db8f4649cf8d6ae2ef162..585cd2cb7661b5b41747eee65bf27c0a016fe3ea 100644 (file)
@@ -1154,9 +1154,9 @@ When using Mozilla NSS these parameters are always generated randomly
 so this directive is ignored.
 .TP
 .B TLSECName <name>
-Specify the name of a curve to use for Elliptic curve Diffie-Hellman
-ephemeral key exchange.  This is required to enable ECDHE algorithms in
-OpenSSL.  This option is not used with GnuTLS; the curves may be
+Specify the name of the curve(s) to use for Elliptic curve Diffie-Hellman
+ephemeral key exchange.  This option is only used for OpenSSL.
+This option is not used with GnuTLS; the curves may be
 chosen in the GnuTLS ciphersuite specification. This option is also
 ignored for Mozilla NSS.
 .TP
index 8067fd1c923461663688d500d0773a2123aece39..0ebfff5e024cb96967615fa4b2a1d5f1e46508f5 100644 (file)
@@ -130,6 +130,7 @@ static const struct ol_attribute {
        {0, ATTR_TLS,   "TLS_RANDFILE",         NULL,   LDAP_OPT_X_TLS_RANDOM_FILE},
        {0, ATTR_TLS,   "TLS_CIPHER_SUITE",     NULL,   LDAP_OPT_X_TLS_CIPHER_SUITE},
        {0, ATTR_TLS,   "TLS_PROTOCOL_MIN",     NULL,   LDAP_OPT_X_TLS_PROTOCOL_MIN},
+       {0, ATTR_TLS,   "TLS_ECNAME",           NULL,   LDAP_OPT_X_TLS_ECNAME},
 
 #ifdef HAVE_OPENSSL_CRL
        {0, ATTR_TLS,   "TLS_CRLCHECK",         NULL,   LDAP_OPT_X_TLS_CRLCHECK},
index ebe5bf125debcada6ed66c662f5797ee1e587808..dc5c7f124aee23a30d1a4308dc83c1421d5d52f2 100644 (file)
@@ -532,6 +532,7 @@ ldap_int_tls_config( LDAP *ld, int option, const char *arg )
        case LDAP_OPT_X_TLS_RANDOM_FILE:
        case LDAP_OPT_X_TLS_CIPHER_SUITE:
        case LDAP_OPT_X_TLS_DHFILE:
+       case LDAP_OPT_X_TLS_ECNAME:
        case LDAP_OPT_X_TLS_CRLFILE:    /* GnuTLS only */
                return ldap_pvt_tls_set_option( ld, option, (void *) arg );
 
index 4152cd9fd7e26078995620aeceb051713f3a6173..3295ebf5cfbfb7b7be3abed9eeea7d84c8d184f2 100644 (file)
@@ -407,34 +407,30 @@ tlso_ctx_init( struct ldapoptions *lo, struct ldaptls *lt, int is_server )
                DH_free( dh );
        }
 
-       if ( is_server && lo->ldo_tls_ecname ) {
+       if ( lo->ldo_tls_ecname ) {
 #ifdef OPENSSL_NO_EC
                Debug( LDAP_DEBUG_ANY,
                        "TLS: Elliptic Curves not supported.\n", 0,0,0 );
                return -1;
 #else
-               EC_KEY *ecdh;
-
-               int nid = OBJ_sn2nid( lt->lt_ecname );
-               if ( nid == NID_undef ) {
+               if ( SSL_CTX_set1_curves_list( ctx, lt->lt_ecname )) {
                        Debug( LDAP_DEBUG_ANY,
-                               "TLS: could not use EC name `%s'.\n",
+                               "TLS: could not set EC name `%s'.\n",
                                lo->ldo_tls_ecname,0,0);
                        tlso_report_error();
                        return -1;
                }
-               ecdh = EC_KEY_new_by_curve_name( nid );
-               if ( ecdh == NULL ) {
+       /*
+        * This is a NOP in OpenSSL 1.1.0 and later, where curves are always
+        * auto-negotiated.
+        */
+#if OPENSSL_VERSION_NUMBER < 0x10100000UL
+               if ( SSL_CTX_set_ecdh_auto( ctx, 1 ) <= 0 ) {
                        Debug( LDAP_DEBUG_ANY,
-                               "TLS: could not generate key for EC name `%s'.\n",
-                               lo->ldo_tls_ecname,0,0);
-                       tlso_report_error();
-                       return -1;
+                               "TLS: could not enable automatic EC negotiation.\n", 0, 0, 0 );
                }
-               SSL_CTX_set_tmp_ecdh( ctx, ecdh );
-               SSL_CTX_set_options( ctx, SSL_OP_SINGLE_ECDH_USE );
-               EC_KEY_free( ecdh );
 #endif
+#endif /* OPENSSL_NO_EC */
        }
 
        if ( tlso_opt_trace ) {