Skip to content

Commit 0418b3c

Browse files
committed
Added a CMake option for EXPERIMENTAL_SRP, defaulting to OFF.
SRP support was always a bit experimental, referencing files relative to the point of invocation. This did not help stability. This is now off by default, but can simply be toggled on in the CMake Cache.
1 parent 5260a22 commit 0418b3c

File tree

2 files changed

+42
-14
lines changed

2 files changed

+42
-14
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ endif()
5858
feature_summary(WHAT ALL VAR _features)
5959
message(STATUS ${_features})
6060

61+
option(EXPERIMENTAL_SRP_SUPPORT "Enable support for SRP based on relative file names" OFF)
62+
if (EXPERIMENTAL_SRP_SUPPORT)
63+
add_definitions(-DEXPERIMENTAL_SRP)
64+
endif()
65+
6166
# These are compile flags, not definitions, but it happens to work.
6267
add_definitions(-fPIC -pthread)
6368
# Pretend we looked for pthread libraries, so that we can write

src/starttls.c

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,13 @@ struct credinfo {
127127
void *cred;
128128
};
129129

130-
#define EXPECTED_SRV_CREDCOUNT 3
131-
#define EXPECTED_CLI_CREDCOUNT 3
130+
#ifdef EXPERIMENTAL_SRP
131+
# define EXPECTED_SRV_CREDCOUNT 3
132+
# define EXPECTED_CLI_CREDCOUNT 3
133+
#else
134+
# define EXPECTED_SRV_CREDCOUNT 2
135+
# define EXPECTED_CLI_CREDCOUNT 2
136+
#endif
132137
static struct credinfo srv_creds [EXPECTED_SRV_CREDCOUNT];
133138
static struct credinfo cli_creds [EXPECTED_CLI_CREDCOUNT];
134139
static int srv_credcount = 0;
@@ -819,9 +824,11 @@ void setup_starttls (void) {
819824
"+ECDHE-KRB:" // +ECDHE-KRB-RSA:+ECDHE-KRB-ECDSA:"
820825
"+ECDHE-RSA:+DHE-RSA:+ECDHE-ECDSA:+DHE-DSS:+RSA:"
821826
"+CTYPE-SRV-KRB:+CTYPE-SRV-X.509:+CTYPE-SRV-OPENPGP:"
822-
"+CTYPE-CLI-KRB:+CTYPE-CLI-X.509:+CTYPE-CLI-OPENPGP:"
823-
"+SRP:+SRP-RSA:+SRP-DSS",
824-
NULL));
827+
"+CTYPE-CLI-KRB:+CTYPE-CLI-X.509:+CTYPE-CLI-OPENPGP"
828+
#ifdef EXPERIMENTAL_SRP
829+
":+SRP:+SRP-RSA:+SRP-DSS"
830+
#endif
831+
,NULL));
825832
#else
826833
E_g2e ("Failed to setup NORMAL priority cache",
827834
gnutls_priority_init (&priority_normal,
@@ -830,9 +837,11 @@ void setup_starttls (void) {
830837
"+COMP-NULL:+CIPHER-ALL:+CURVE-ALL:+SIGN-ALL:+MAC-ALL:"
831838
"+ANON-ECDH:"
832839
"+ECDHE-RSA:+DHE-RSA:+ECDHE-ECDSA:+DHE-DSS:+RSA:"
833-
"+CTYPE-X.509:+CTYPE-OPENPGP:"
834-
"+SRP:+SRP-RSA:+SRP-DSS",
835-
NULL));
840+
"+CTYPE-X.509:+CTYPE-OPENPGP"
841+
#ifdef EXPERIMENTAL_SRP
842+
":+SRP:+SRP-RSA:+SRP-DSS"
843+
#endif
844+
,NULL));
836845
#endif
837846
//
838847
// Try to setup on-the-fly signing key / certificate and gen a certkey
@@ -3860,9 +3869,11 @@ static int configure_session (struct command *cmd,
38603869
"+CTYPE-SRV-KRB:+CTYPE-SRV-X.509:+CTYPE-SRV-OPENPGP:"
38613870
"%cCTYPE-CLI-KRB:"
38623871
"%cCTYPE-CLI-X.509:"
3863-
"%cCTYPE-CLI-OPENPGP:"
3864-
"%cSRP:%cSRP-RSA:%cSRP-DSS",
3865-
anonpre_ok ?'+':'-',
3872+
"%cCTYPE-CLI-OPENPGP"
3873+
#ifdef EXPERIMENTAL_SRP
3874+
":%cSRP:%cSRP-RSA:%cSRP-DSS"
3875+
#endif
3876+
,anonpre_ok ?'+':'-',
38663877
1 /* lidtpsup (cmd, LID_TYPE_KRB5)*/ ?'+':'-',
38673878
1 /*lidtpsup (cmd, LID_TYPE_X509)*/ ?'+':'-',
38683879
1 /*lidtpsup (cmd, LID_TYPE_PGP)*/ ?'+':'-',
@@ -3883,9 +3894,11 @@ static int configure_session (struct command *cmd,
38833894
"%cANON-ECDH:"
38843895
"+ECDHE-RSA:+DHE-RSA:+ECDHE-ECDSA:+DHE-DSS:+RSA:" //TODO//
38853896
"%cCTYPE-X.509:"
3886-
"%cCTYPE-OPENPGP:"
3887-
"%cSRP:%cSRP-RSA:%cSRP-DSS",
3888-
anonpre_ok ?'+':'-',
3897+
"%cCTYPE-OPENPGP"
3898+
#ifdef EXPERIMENTAL_SRP
3899+
":%cSRP:%cSRP-RSA:%cSRP-DSS"
3900+
#endif
3901+
,anonpre_ok ?'+':'-',
38893902
1 ?'+':'-',
38903903
1 ?'+':'-',
38913904
//TODO// Temporarily patched out SRP
@@ -4161,6 +4174,7 @@ static int setup_starttls_credentials (void) {
41614174
//
41624175
// Construct server credentials for SRP authentication
41634176
gtls_errno = gtls_errno_stack0; // Don't pop, just forget last failures
4177+
#ifdef EXPERIMENTAL_SRP
41644178
E_g2e ("Failed to allocate SRP server credentials",
41654179
gnutls_srp_allocate_server_credentials (
41664180
&srv_srpcred));
@@ -4178,10 +4192,12 @@ static int setup_starttls_credentials (void) {
41784192
gnutls_srp_free_server_credentials (srv_srpcred);
41794193
srv_srpcred = NULL;
41804194
}
4195+
#endif
41814196

41824197
//
41834198
// Construct client credentials for SRP authentication
41844199
gtls_errno = gtls_errno_stack0; // Don't pop, just forget last failures
4200+
#ifdef EXPERIMENTAL_SRP
41854201
E_g2e ("Failed to allocate SRP client credentials",
41864202
gnutls_srp_allocate_client_credentials (
41874203
&cli_srpcred));
@@ -4197,6 +4213,7 @@ static int setup_starttls_credentials (void) {
41974213
gnutls_srp_free_client_credentials (cli_srpcred);
41984214
cli_srpcred = NULL;
41994215
}
4216+
#endif
42004217

42014218
//
42024219
// Construct server credentials for KDH authentication
@@ -4268,9 +4285,11 @@ static void cleanup_starttls_credentials (void) {
42684285
case GNUTLS_CRD_ANON:
42694286
gnutls_anon_free_server_credentials (crd->cred);
42704287
break;
4288+
#ifdef EXPERIMENTAL_SRP
42714289
case GNUTLS_CRD_SRP:
42724290
gnutls_srp_free_server_credentials (crd->cred);
42734291
break;
4292+
#endif
42744293
case GNUTLS_CRD_PSK:
42754294
case GNUTLS_CRD_IA:
42764295
//TODO: not handled
@@ -4290,9 +4309,11 @@ static void cleanup_starttls_credentials (void) {
42904309
case GNUTLS_CRD_ANON:
42914310
gnutls_anon_free_client_credentials (crd->cred);
42924311
break;
4312+
#ifdef EXPERIMENTAL_SRP
42934313
case GNUTLS_CRD_SRP:
42944314
gnutls_srp_free_client_credentials (crd->cred);
42954315
break;
4316+
#endif
42964317
case GNUTLS_CRD_PSK:
42974318
case GNUTLS_CRD_IA:
42984319
//TODO: not handled
@@ -4919,12 +4940,14 @@ fprintf (stderr, "ctlkey_unregister under ckn=%p at %d\n", (void *)ckn, __LINE__
49194940
got_remoteid = 0;
49204941
cmd->vfystatus = GNUTLS_CERT_SIGNER_NOT_FOUND;
49214942
break;
4943+
#ifdef EXPERIMENTAL_SRP
49224944
case GNUTLS_CRD_SRP:
49234945
// Got a credential, validation follows later on
49244946
//TODO// SRP does not really auth the server
49254947
got_remoteid = 1;
49264948
cmd->vfystatus = GNUTLS_CERT_SIGNER_NOT_FOUND;
49274949
break;
4950+
#endif
49284951
case GNUTLS_CRD_ANON:
49294952
// Did not get a credential, perhaps due to anonpre
49304953
got_remoteid = 0;

0 commit comments

Comments
 (0)