summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2003-04-01 19:13:11 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2003-04-01 19:13:11 +0000
commit47836324df6c7788817468ce4f72bed7dba480e5 (patch)
tree309b9badb729b46be3774a81928df1f36d8cccd5
parent80ba67b530a243e56c8d7e1bac93efe485875880 (diff)
downloadgnutls-47836324df6c7788817468ce4f72bed7dba480e5.tar.gz
Some fixes to allow proper compiling when --disable-srp-authentication and --disable-anon-authentication are specified. Patch by Paul Sheer.
-rw-r--r--libextra/gnutls_extra.c12
-rw-r--r--src/cli.c13
-rw-r--r--src/common.c4
-rw-r--r--src/crypt.c15
-rw-r--r--src/serv.c22
-rw-r--r--src/tests.c7
-rw-r--r--src/tls_test.c14
7 files changed, 78 insertions, 9 deletions
diff --git a/libextra/gnutls_extra.c b/libextra/gnutls_extra.c
index deb91ca344..53c042bd95 100644
--- a/libextra/gnutls_extra.c
+++ b/libextra/gnutls_extra.c
@@ -30,8 +30,12 @@
extern gnutls_extension_entry _gnutls_extensions[];
extern const int _gnutls_extensions_size;
+extern const int _gnutls_kx_algorithms_size;
+extern gnutls_kx_algo_entry _gnutls_kx_algorithms[];
+
#define TOSTR(x) #x
+#ifdef ENABLE_SRP
static int _gnutls_add_srp_extension(void) {
int i;
@@ -54,12 +58,11 @@ int i;
return GNUTLS_E_MEMORY_ERROR;
}
-extern const int _gnutls_kx_algorithms_size;
-extern gnutls_kx_algo_entry _gnutls_kx_algorithms[];
extern MOD_AUTH_STRUCT srp_auth_struct;
extern MOD_AUTH_STRUCT srp_rsa_auth_struct;
extern MOD_AUTH_STRUCT srp_dss_auth_struct;
+
static int _gnutls_add_srp_auth_struct(void) {
int i;
@@ -96,6 +99,9 @@ int i;
return GNUTLS_E_MEMORY_ERROR;
}
+#endif
+
+
/* the number of the compression algorithms available in the compression
* structure.
*/
@@ -201,6 +207,7 @@ int ret;
return ret;
}
+#ifdef ENABLE_SRP
/* Add the SRP authentication to the list of authentication
* methods.
*/
@@ -217,6 +224,7 @@ int ret;
gnutls_assert();
return ret;
}
+#endif
/* Register the openpgp functions. This is because some
* of them are defined to be NULL in the main library.
diff --git a/src/cli.c b/src/cli.c
index 7865c5b30d..ab9ef8f7e7 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -391,9 +391,15 @@ int main(int argc, char **argv)
socket_bye(&hd);
+#ifdef ENABLE_SRP
gnutls_srp_free_client_credentials(srp_cred);
+#endif
+
gnutls_certificate_free_credentials(xcred);
+
+#ifdef ENABLE_ANON
gnutls_anon_free_client_credentials(anon_cred);
+#endif
gnutls_global_deinit();
@@ -658,7 +664,7 @@ int ret;
}
}
-
+#ifdef ENABLE_SRP
/* SRP stuff */
if (gnutls_srp_allocate_client_credentials(&srp_cred) < 0) {
fprintf(stderr, "SRP authentication error\n");
@@ -669,9 +675,14 @@ int ret;
fprintf(stderr, "SRP credentials set error [%d]\n", ret);
}
}
+#endif
+
+#ifdef ENABLE_ANON
/* ANON stuff */
if (gnutls_anon_allocate_client_credentials(&anon_cred) < 0) {
fprintf(stderr, "Anonymous authentication error\n");
}
+#endif
+
}
diff --git a/src/common.c b/src/common.c
index 3631e35234..15688dd28d 100644
--- a/src/common.c
+++ b/src/common.c
@@ -284,6 +284,7 @@ int print_info(gnutls_session session)
cred = gnutls_auth_get_type(session);
switch (cred) {
+#ifdef ENABLE_ANON
case GNUTLS_CRD_ANON:
printf("- Anonymous DH using prime of %d bits, secret key "
"of %d bits, and peer's public key is %d bits.\n",
@@ -291,6 +292,8 @@ int print_info(gnutls_session session)
gnutls_dh_get_secret_bits(session),
gnutls_dh_get_peers_public_bits(session));
break;
+#endif
+#ifdef ENABLE_SRP
case GNUTLS_CRD_SRP:
/* This should be only called in server
* side.
@@ -299,6 +302,7 @@ int print_info(gnutls_session session)
printf("- SRP authentication. Connected as '%s'\n",
gnutls_srp_server_get_username(session));
break;
+#endif
case GNUTLS_CRD_CERTIFICATE:
{
char dns[256];
diff --git a/src/crypt.c b/src/crypt.c
index 4f354e2bd7..2b37ba8cac 100644
--- a/src/crypt.c
+++ b/src/crypt.c
@@ -18,6 +18,18 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifndef ENABLE_SRP
+
+#include <stdio.h>
+
+int main (int argc, char **argv)
+{
+ printf ("\nSRP not supported. This program is a dummy.\n\n");
+ return 1;
+};
+
+#else
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -31,6 +43,7 @@
#include <sys/stat.h>
#include <unistd.h>
+
#define _MAX(x,y) (x>y?x:y)
/* This may need some rewrite. A lot of stuff which should be here
@@ -564,3 +577,5 @@ static int read_conf_values(gnutls_datum * g, gnutls_datum * n, char *str)
return index;
}
+
+#endif /* ENABLE_SRP */
diff --git a/src/serv.c b/src/serv.c
index 4b283e0dd1..76dfada41b 100644
--- a/src/serv.c
+++ b/src/serv.c
@@ -357,16 +357,20 @@ char *peer_print_info(gnutls_session session, int *ret_length,
}
/* print srp specific data */
+#ifdef ENABLE_SRP
if (gnutls_kx_get(session) == GNUTLS_KX_SRP) {
sprintf(tmp2, "<p>Connected as user '%s'.</p>\n",
gnutls_srp_server_get_username(session));
}
+#endif
+#ifdef ENABLE_ANON
if (gnutls_kx_get(session) == GNUTLS_KX_ANON_DH) {
sprintf(tmp2,
"<p> Connect using anonymous DH (prime of %d bits)</p>\n",
gnutls_dh_get_prime_bits(session));
}
+#endif
if (gnutls_kx_get(session) == GNUTLS_KX_DHE_RSA
|| gnutls_kx_get(session) == GNUTLS_KX_DHE_DSS) {
@@ -577,6 +581,7 @@ int main(int argc, char **argv)
if ((ret = gnutls_certificate_set_x509_trust_file
(cert_cred, x509_cafile, x509ctype)) < 0) {
fprintf(stderr, "Error reading '%s'\n", x509_cafile);
+ fprintf(stderr, "Error: '%s'\n", gnutls_strerror(ret));
exit(1);
} else {
printf("Processed %d CA certificate(s).\n", ret);
@@ -588,6 +593,7 @@ int main(int argc, char **argv)
if ((ret = gnutls_certificate_set_x509_crl_file
(cert_cred, x509_crlfile, x509ctype)) < 0) {
fprintf(stderr, "Error reading '%s'\n", x509_crlfile);
+ fprintf(stderr, "Error: '%s'\n", gnutls_strerror(ret));
exit(1);
} else {
printf("Processed %d CRL(s).\n", ret);
@@ -601,6 +607,7 @@ int main(int argc, char **argv)
pgp_keyring);
if (ret < 0) {
fprintf(stderr, "Error setting the OpenPGP keyring file\n");
+ fprintf(stderr, "Error: '%s'\n", gnutls_strerror(ret));
}
}
@@ -608,6 +615,7 @@ int main(int argc, char **argv)
ret = gnutls_certificate_set_openpgp_trustdb(cert_cred, pgp_trustdb);
if (ret < 0) {
fprintf(stderr, "Error setting the OpenPGP trustdb file\n");
+ fprintf(stderr, "Error: '%s'\n", gnutls_strerror(ret));
}
}
@@ -617,6 +625,7 @@ int main(int argc, char **argv)
fprintf(stderr,
"Error[%d] while reading the OpenPGP key pair ('%s', '%s')\n",
ret, pgp_certfile, pgp_keyfile);
+ fprintf(stderr, "Error: '%s'\n", gnutls_strerror(ret));
}
if (x509_certfile != NULL)
@@ -625,6 +634,7 @@ int main(int argc, char **argv)
fprintf(stderr,
"Error reading '%s' or '%s'\n", x509_certfile,
x509_keyfile);
+ fprintf(stderr, "Error: '%s'\n", gnutls_strerror(ret));
exit(1);
}
@@ -636,6 +646,7 @@ int main(int argc, char **argv)
/* this is a password file (created with the included srpcrypt utility)
* Read README.crypt prior to using SRP.
*/
+#ifdef ENABLE_SRP
gnutls_srp_allocate_server_credentials(&srp_cred);
if (srp_passwd != NULL)
@@ -645,12 +656,15 @@ int main(int argc, char **argv)
/* only exit is this function is not disabled
*/
fprintf(stderr, "Error while setting SRP parameters\n");
+ fprintf(stderr, "Error: '%s'\n", gnutls_strerror(ret));
}
+#endif
+#ifdef ENABLE_ANON
gnutls_anon_allocate_server_credentials(&dh_cred);
if (generate != 0)
gnutls_anon_set_server_dh_params(dh_cred, dh_params);
-
+#endif
h = listen_socket(name, port);
if (h < 0)
@@ -902,8 +916,14 @@ int main(int argc, char **argv)
gnutls_certificate_free_credentials(cert_cred);
+
+#ifdef ENABLE_SRP
gnutls_srp_free_server_credentials(srp_cred);
+#endif
+
+#ifdef ENABLE_ANON
gnutls_anon_free_server_credentials(dh_cred);
+#endif
if (nodb == 0)
wrap_db_deinit();
diff --git a/src/tests.c b/src/tests.c
index 153b8c7282..20155388f4 100644
--- a/src/tests.c
+++ b/src/tests.c
@@ -166,7 +166,7 @@ static void ADD_PROTOCOL(gnutls_session session, int protocol) {
gnutls_protocol_set_priority(session, _proto_priority);
}
-
+#ifdef ENABLE_SRP
int test_srp( gnutls_session session) {
int ret;
@@ -186,6 +186,7 @@ int ret;
return ret;
}
+#endif
int test_export( gnutls_session session) {
ADD_ALL_COMP(session);
@@ -568,7 +569,7 @@ int ret;
}
-
+#ifdef ENABLE_ANON
int test_anonymous( gnutls_session session) {
int ret;
@@ -586,7 +587,7 @@ int ret;
return ret;
}
-
+#endif
int test_session_resume2( gnutls_session session) {
int ret;
diff --git a/src/tls_test.c b/src/tls_test.c
index a61f74d12c..966825f14a 100644
--- a/src/tls_test.c
+++ b/src/tls_test.c
@@ -95,8 +95,10 @@ static const TLS_TEST tls_tests[] = {
{ "whether the server understands TLS closure alerts", test_bye, "yes", "no", "partially"},
{ "whether the server supports session resumption", test_session_resume2, "yes", "no", "dunno"},
{ "for export-grade ciphersuite support", test_export, "yes", "no", "dunno" },
+#ifdef ENABLE_ANON
{ "for anonymous authentication support", test_anonymous, "yes", "no", "dunno"},
{ "for anonymous Diffie Hellman prime size", test_dhe_bits, "", "N/A", "N/A" },
+#endif
{ "for ephemeral Diffie Hellman support", test_dhe, "yes", "no", "dunno" },
{ "for ephemeral Diffie Hellman prime size", test_dhe_bits, "", "N/A", "N/A" },
{ "for AES cipher support", test_aes, "yes", "no", "dunno"},
@@ -105,7 +107,9 @@ static const TLS_TEST tls_tests[] = {
{ "for MD5 MAC support", test_md5, "yes", "no", "dunno"},
{ "for SHA1 MAC support", test_sha, "yes", "no", "dunno"},
{ "for max record size (TLS extension)", test_max_record_size, "yes", "no", "dunno" },
+#ifdef ENABLE_SRP
{ "for SRP authentication support (TLS extension)", test_srp, "yes", "no", "dunno" },
+#endif
{ "for OpenPGP authentication support (TLS extension)", test_openpgp1, "yes", "no", "dunno" },
{ NULL }
};
@@ -166,18 +170,21 @@ int main(int argc, char **argv)
}
/* SRP stuff */
+#ifdef ENABLE_SRP
if (gnutls_srp_allocate_client_credentials(&srp_cred) < 0) {
fprintf(stderr, "memory error\n");
exit(1);
}
gnutls_srp_set_client_credentials( srp_cred, "guest", "guest");
+#endif
+#ifdef ENABLE_ANON
/* ANON stuff */
if (gnutls_anon_allocate_client_credentials(&anon_cred) < 0) {
fprintf(stderr, "memory error\n");
exit(1);
}
-
+#endif
i = 0;
@@ -211,10 +218,13 @@ int main(int argc, char **argv)
i++;
} while(1);
+#ifdef ENABLE_SRP
gnutls_srp_free_client_credentials(srp_cred);
+#endif
gnutls_certificate_free_credentials(xcred);
+#ifdef ENABLE_ANON
gnutls_anon_free_client_credentials(anon_cred);
-
+#endif
gnutls_global_deinit();
return 0;