AC_MSG_WARN([[***
*** GAA was not found. It is only needed if you wish to modify
*** the source code or command-line description files. In this case,
-*** you may want to get it from http://gaa.sourceforge.net/
+*** you may want to get it from http://gaa.sourceforge.net/ and
+*** read doc/README.gaa.
***]])
fi
AM_CONDITIONAL(HAVE_GCC, test "x$GCC" = "xyes")
gl_INIT
-# These are additional warnings we could enable:
-#
-# -Wshadow -Wunsafe-loop-optimizations Wcast-qual Wlogical-op
-# -Waggregate-return Wmissing-prototypes -Wmissing-declarations
-# -Wmissing-noreturn -Wmissing-format-attribute Wredundant-decls -Wvla
-#
# These are warnings we have tried but have turned out not to be useful:
#
# -Wtraditional: warns on #elif which we use often
# -Wno-pointer-sign: too many warnings for now
# -Wno-unused-parameter: added because -Wunused cause too many warns
-BASICS="-Wall -W"
-
-ADDITIONAL="-Wchar-subscripts -Wformat-security -Wnonnull -Winit-self -Wmissing-include-dirs -Wunused -Wfloat-equal -Wdeclaration-after-statement -Wpointer-arith -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wpacked -Wnested-externs -Winline -Wvolatile-register-var -Wdisabled-optimization -Wstack-protector -Woverlength-strings"
-
-REMOVE="-Wno-pointer-sign -Wno-unused-parameter"
-
-for w in $BASICS $ADDITIONAL $REMOVE; do
+gl_WARN_SUPPORTED([WARNINGS])
+
+# Useless warnings.
+USELESS_WARNINGS=" \
+ -Wc++-compat \
+ -Wsystem-headers \
+ -Wundef \
+ -Wtraditional \
+ -Wtraditional-conversion"
+gl_WARN_COMPLEMENT(WARNINGS, [$WARNINGS], [$USELESS_WARNINGS])
+# Review these from time to time.
+USELESS_WARNINGS=" \
+ -Wcast-qual \
+ -Wlogical-op \
+ -Waggregate-return \
+ -Wshadow \
+ -Wswitch-default \
+ -Wswitch-enum \
+ -Wconversion \
+ -Wsign-conversion \
+ -Wold-style-definition \
+ -Wpadded \
+ -Wsign-compare \
+ -Wunreachable-code \
+ -Wformat-y2k \
+ -Wunsafe-loop-optimizations \
+ -Wstrict-overflow"
+gl_WARN_COMPLEMENT(WARNINGS, [$WARNINGS], [$USELESS_WARNINGS])
+
+for w in $WARNINGS; do
gl_WARN_ADD([$w])
done
+
+gl_WARN_ADD([-Wno-missing-field-initializers])
+gl_WARN_ADD([-Wno-pointer-sign])
+gl_WARN_ADD([-Wno-unused-parameter])
+gl_WARN_ADD([-fdiagnostics-show-option])
export WARN_CFLAGS
+gl_WARN_ADD([])
+
AC_CONFIG_SUBDIRS([lib])
AC_CONFIG_SUBDIRS([libextra])
noinst_LTLIBRARIES = libexamples.la
-libexamples_la_SOURCES = ex-alert.c ex-pkcs12.c ex-rfc2818.c \
- ex-session-info.c ex-x509-info.c ex-verify.c tcp.c
+libexamples_la_SOURCES = examples.h ex-alert.c ex-pkcs12.c \
+ ex-rfc2818.c ex-session-info.c ex-x509-info.c ex-verify.c \
+ tcp.c
-/* Copyright 2007 Free Software Foundation
+/* Copyright 2007, 2008 Free Software Foundation
*
* Copying and distribution of this file, with or without modification,
* are permitted in any medium without royalty provided the copyright
#include <stdlib.h>
#include <gnutls/gnutls.h>
+#include "examples.h"
+
/* This function will check whether the given return code from
* a gnutls function (recv/send), is an alert, and will print
* that alert.
char buffer[MAX_BUF + 1];
const char *err;
gnutls_psk_client_credentials_t pskcred;
- const gnutls_datum_t key = { "DEADBEEF", 8 };
+ const gnutls_datum_t key = { (char*) "DEADBEEF", 8 };
gnutls_global_init ();
-/* Copyright 2007 Free Software Foundation
+/* Copyright 2007, 2008 Free Software Foundation
*
* Copying and distribution of this file, with or without modification,
* are permitted in any medium without royalty provided the copyright
#include <gnutls/gnutls.h>
#include <gnutls/pkcs12.h>
+#include "examples.h"
+
#define OUTFILE "out.p12"
/* This function will write a pkcs12 structure into a file.
/* A good idea might be to use gnutls_x509_privkey_get_key_id()
* to obtain a unique ID.
*/
- gnutls_datum_t key_id = { "\x00\x00\x07", 3 };
+ gnutls_datum_t key_id = { (char*) "\x00\x00\x07", 3 };
gnutls_global_init ();
-/* Copyright 2007 Free Software Foundation
+/* Copyright 2007, 2008 Free Software Foundation
*
* Copying and distribution of this file, with or without modification,
* are permitted in any medium without royalty provided the copyright
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
+#include "examples.h"
+
/* This function will try to verify the peer's certificate, and
* also check if the hostname matches, and the activation, expiration dates.
*/
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
-extern void print_x509_certificate_info (gnutls_session_t);
+#include "examples.h"
/* This function will print some details of the
* given session.
-/* Copyright 2007 Free Software Foundation
+/* Copyright 2007, 2008 Free Software Foundation
*
* Copying and distribution of this file, with or without modification,
* are permitted in any medium without royalty provided the copyright
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
+#include "examples.h"
+
/* All the available CRLs
*/
gnutls_x509_crl_t *crl_list;
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
+#include "examples.h"
+
static const char *
bin2hex (const void *bin, size_t bin_size)
{
-/* Copyright 2007 Free Software Foundation
+/* Copyright 2007, 2008 Free Software Foundation
*
* Copying and distribution of this file, with or without modification,
* are permitted in any medium without royalty provided the copyright
#define SA struct sockaddr
+/* tcp.c */
+int tcp_connect (void);
+void tcp_close (int sd);
+
/* Connects to the peer and returns a socket
* descriptor.
*/
return translation;
}
-/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
- can be arbitrary expressions. But for string literals these macros are
- less efficient than those above. */
-
-#include <string.h>
-
-#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
- (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
- /* || __STDC_VERSION__ >= 199901L */ )
-
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
-#include <stdlib.h>
-#endif
-
-#define pgettext_expr(Msgctxt, Msgid) \
- dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
-#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
- dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static const char *
-dcpgettext_expr (const char *domain,
- const char *msgctxt, const char *msgid,
- int category)
-{
- size_t msgctxt_len = strlen (msgctxt) + 1;
- size_t msgid_len = strlen (msgid) + 1;
- const char *translation;
-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
- char msg_ctxt_id[msgctxt_len + msgid_len];
-#else
- char buf[1024];
- char *msg_ctxt_id =
- (msgctxt_len + msgid_len <= sizeof (buf)
- ? buf
- : (char *) malloc (msgctxt_len + msgid_len));
- if (msg_ctxt_id != NULL)
-#endif
- {
- memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
- msg_ctxt_id[msgctxt_len - 1] = '\004';
- memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
- translation = dcgettext (domain, msg_ctxt_id, category);
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
- if (msg_ctxt_id != buf)
- free (msg_ctxt_id);
-#endif
- if (translation != msg_ctxt_id)
- return translation;
- }
- return msgid;
-}
-
-#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
- dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
-#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
- dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static const char *
-dcnpgettext_expr (const char *domain,
- const char *msgctxt, const char *msgid,
- const char *msgid_plural, unsigned long int n,
- int category)
-{
- size_t msgctxt_len = strlen (msgctxt) + 1;
- size_t msgid_len = strlen (msgid) + 1;
- const char *translation;
-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
- char msg_ctxt_id[msgctxt_len + msgid_len];
-#else
- char buf[1024];
- char *msg_ctxt_id =
- (msgctxt_len + msgid_len <= sizeof (buf)
- ? buf
- : (char *) malloc (msgctxt_len + msgid_len));
- if (msg_ctxt_id != NULL)
-#endif
- {
- memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
- msg_ctxt_id[msgctxt_len - 1] = '\004';
- memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
- translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
- if (msg_ctxt_id != buf)
- free (msg_ctxt_id);
-#endif
- if (!(translation == msg_ctxt_id || translation == msgid_plural))
- return translation;
- }
- return (n == 1 ? msgid : msgid_plural);
-}
-
#endif /* _LIBGETTEXT_H */
--- /dev/null
+--- gl/gettext.h.orig 2008-11-17 17:12:20.000000000 +0100
++++ gl/gettext.h 2008-11-17 17:12:29.000000000 +0100
+@@ -162,109 +162,4 @@
+ return translation;
+ }
+
+-/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
+- can be arbitrary expressions. But for string literals these macros are
+- less efficient than those above. */
+-
+-#include <string.h>
+-
+-#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
+- (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
+- /* || __STDC_VERSION__ >= 199901L */ )
+-
+-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+-#include <stdlib.h>
+-#endif
+-
+-#define pgettext_expr(Msgctxt, Msgid) \
+- dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
+-#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
+- dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
+-
+-#ifdef __GNUC__
+-__inline
+-#else
+-#ifdef __cplusplus
+-inline
+-#endif
+-#endif
+-static const char *
+-dcpgettext_expr (const char *domain,
+- const char *msgctxt, const char *msgid,
+- int category)
+-{
+- size_t msgctxt_len = strlen (msgctxt) + 1;
+- size_t msgid_len = strlen (msgid) + 1;
+- const char *translation;
+-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+- char msg_ctxt_id[msgctxt_len + msgid_len];
+-#else
+- char buf[1024];
+- char *msg_ctxt_id =
+- (msgctxt_len + msgid_len <= sizeof (buf)
+- ? buf
+- : (char *) malloc (msgctxt_len + msgid_len));
+- if (msg_ctxt_id != NULL)
+-#endif
+- {
+- memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+- msg_ctxt_id[msgctxt_len - 1] = '\004';
+- memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+- translation = dcgettext (domain, msg_ctxt_id, category);
+-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+- if (msg_ctxt_id != buf)
+- free (msg_ctxt_id);
+-#endif
+- if (translation != msg_ctxt_id)
+- return translation;
+- }
+- return msgid;
+-}
+-
+-#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
+- dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+-#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+- dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+-
+-#ifdef __GNUC__
+-__inline
+-#else
+-#ifdef __cplusplus
+-inline
+-#endif
+-#endif
+-static const char *
+-dcnpgettext_expr (const char *domain,
+- const char *msgctxt, const char *msgid,
+- const char *msgid_plural, unsigned long int n,
+- int category)
+-{
+- size_t msgctxt_len = strlen (msgctxt) + 1;
+- size_t msgid_len = strlen (msgid) + 1;
+- const char *translation;
+-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+- char msg_ctxt_id[msgctxt_len + msgid_len];
+-#else
+- char buf[1024];
+- char *msg_ctxt_id =
+- (msgctxt_len + msgid_len <= sizeof (buf)
+- ? buf
+- : (char *) malloc (msgctxt_len + msgid_len));
+- if (msg_ctxt_id != NULL)
+-#endif
+- {
+- memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+- msg_ctxt_id[msgctxt_len - 1] = '\004';
+- memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+- translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+- if (msg_ctxt_id != buf)
+- free (msg_ctxt_id);
+-#endif
+- if (!(translation == msg_ctxt_id || translation == msgid_plural))
+- return translation;
+- }
+- return (n == 1 ? msgid : msgid_plural);
+-}
+-
+ #endif /* _LIBGETTEXT_H */
return translation;
}
-/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
- can be arbitrary expressions. But for string literals these macros are
- less efficient than those above. */
-
-#include <string.h>
-
-#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
- (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
- /* || __STDC_VERSION__ >= 199901L */ )
-
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
-#include <stdlib.h>
-#endif
-
-#define pgettext_expr(Msgctxt, Msgid) \
- dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
-#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
- dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static const char *
-dcpgettext_expr (const char *domain,
- const char *msgctxt, const char *msgid,
- int category)
-{
- size_t msgctxt_len = strlen (msgctxt) + 1;
- size_t msgid_len = strlen (msgid) + 1;
- const char *translation;
-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
- char msg_ctxt_id[msgctxt_len + msgid_len];
-#else
- char buf[1024];
- char *msg_ctxt_id =
- (msgctxt_len + msgid_len <= sizeof (buf)
- ? buf
- : (char *) malloc (msgctxt_len + msgid_len));
- if (msg_ctxt_id != NULL)
-#endif
- {
- memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
- msg_ctxt_id[msgctxt_len - 1] = '\004';
- memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
- translation = dcgettext (domain, msg_ctxt_id, category);
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
- if (msg_ctxt_id != buf)
- free (msg_ctxt_id);
-#endif
- if (translation != msg_ctxt_id)
- return translation;
- }
- return msgid;
-}
-
-#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
- dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
-#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
- dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static const char *
-dcnpgettext_expr (const char *domain,
- const char *msgctxt, const char *msgid,
- const char *msgid_plural, unsigned long int n,
- int category)
-{
- size_t msgctxt_len = strlen (msgctxt) + 1;
- size_t msgid_len = strlen (msgid) + 1;
- const char *translation;
-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
- char msg_ctxt_id[msgctxt_len + msgid_len];
-#else
- char buf[1024];
- char *msg_ctxt_id =
- (msgctxt_len + msgid_len <= sizeof (buf)
- ? buf
- : (char *) malloc (msgctxt_len + msgid_len));
- if (msg_ctxt_id != NULL)
-#endif
- {
- memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
- msg_ctxt_id[msgctxt_len - 1] = '\004';
- memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
- translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
- if (msg_ctxt_id != buf)
- free (msg_ctxt_id);
-#endif
- if (!(translation == msg_ctxt_id || translation == msgid_plural))
- return translation;
- }
- return (n == 1 ? msgid : msgid_plural);
-}
-
#endif /* _LIBGETTEXT_H */
--- /dev/null
+--- lib/gl/gettext.h.orig 2008-11-17 17:11:58.000000000 +0100
++++ lib/gl/gettext.h 2008-11-17 17:12:03.000000000 +0100
+@@ -162,109 +162,4 @@
+ return translation;
+ }
+
+-/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
+- can be arbitrary expressions. But for string literals these macros are
+- less efficient than those above. */
+-
+-#include <string.h>
+-
+-#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
+- (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
+- /* || __STDC_VERSION__ >= 199901L */ )
+-
+-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+-#include <stdlib.h>
+-#endif
+-
+-#define pgettext_expr(Msgctxt, Msgid) \
+- dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
+-#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
+- dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
+-
+-#ifdef __GNUC__
+-__inline
+-#else
+-#ifdef __cplusplus
+-inline
+-#endif
+-#endif
+-static const char *
+-dcpgettext_expr (const char *domain,
+- const char *msgctxt, const char *msgid,
+- int category)
+-{
+- size_t msgctxt_len = strlen (msgctxt) + 1;
+- size_t msgid_len = strlen (msgid) + 1;
+- const char *translation;
+-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+- char msg_ctxt_id[msgctxt_len + msgid_len];
+-#else
+- char buf[1024];
+- char *msg_ctxt_id =
+- (msgctxt_len + msgid_len <= sizeof (buf)
+- ? buf
+- : (char *) malloc (msgctxt_len + msgid_len));
+- if (msg_ctxt_id != NULL)
+-#endif
+- {
+- memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+- msg_ctxt_id[msgctxt_len - 1] = '\004';
+- memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+- translation = dcgettext (domain, msg_ctxt_id, category);
+-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+- if (msg_ctxt_id != buf)
+- free (msg_ctxt_id);
+-#endif
+- if (translation != msg_ctxt_id)
+- return translation;
+- }
+- return msgid;
+-}
+-
+-#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
+- dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+-#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+- dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+-
+-#ifdef __GNUC__
+-__inline
+-#else
+-#ifdef __cplusplus
+-inline
+-#endif
+-#endif
+-static const char *
+-dcnpgettext_expr (const char *domain,
+- const char *msgctxt, const char *msgid,
+- const char *msgid_plural, unsigned long int n,
+- int category)
+-{
+- size_t msgctxt_len = strlen (msgctxt) + 1;
+- size_t msgid_len = strlen (msgid) + 1;
+- const char *translation;
+-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+- char msg_ctxt_id[msgctxt_len + msgid_len];
+-#else
+- char buf[1024];
+- char *msg_ctxt_id =
+- (msgctxt_len + msgid_len <= sizeof (buf)
+- ? buf
+- : (char *) malloc (msgctxt_len + msgid_len));
+- if (msg_ctxt_id != NULL)
+-#endif
+- {
+- memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+- msg_ctxt_id[msgctxt_len - 1] = '\004';
+- memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+- translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+- if (msg_ctxt_id != buf)
+- free (msg_ctxt_id);
+-#endif
+- if (!(translation == msg_ctxt_id || translation == msgid_plural))
+- return translation;
+- }
+- return (n == 1 ? msgid : msgid_plural);
+-}
+-
+ #endif /* _LIBGETTEXT_H */
}
int
-_gnutls_ssl3_hash_md5 (void *first, int first_len,
- void *second, int second_len, int ret_len,
- opaque * ret)
+_gnutls_ssl3_hash_md5 (const void *first, int first_len,
+ const void *second, int second_len,
+ int ret_len, opaque * ret)
{
opaque digest[MAX_HASH_SIZE];
digest_hd_st td;
int _gnutls_ssl3_generate_random (void *secret, int secret_len,
void *rnd, int random_len, int bytes,
opaque * ret);
-int _gnutls_ssl3_hash_md5 (void *first, int first_len, void *second,
- int second_len, int ret_len, opaque * ret);
+int _gnutls_ssl3_hash_md5 (const void *first, int first_len,
+ const void *second, int second_len,
+ int ret_len, opaque * ret);
void _gnutls_mac_deinit_ssl3_handshake (digest_hd_st* handle, void *digest,
opaque * key, uint32_t key_size);
#include <gnutls_algorithms.h>
#include <gnutls_rsa_export.h>
+/* These should really be static, but src/tests.c calls them. Make
+ them public functions? */
+void
+_gnutls_record_set_default_version (gnutls_session_t session,
+ unsigned char major, unsigned char minor);
+void
+_gnutls_rsa_pms_set_version (gnutls_session_t session,
+ unsigned char major, unsigned char minor);
+
void
_gnutls_session_cert_type_set (gnutls_session_t session,
gnutls_certificate_type_t ct)
int _gnutls_string_append_str (gnutls_string *, const char *str);
int _gnutls_string_append_data (gnutls_string *, const void *data,
size_t data_size);
-int _gnutls_string_append_printf (gnutls_string * dest, const char *fmt, ...);
+
+
+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later. */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
+# define __attribute__(Spec) /* empty */
+# endif
+#endif
+
+int _gnutls_string_append_printf (gnutls_string * dest, const char *fmt, ...)
+ __attribute__ ((format (printf, 2, 3)));
typedef gnutls_string gnutls_buffer;
struct tm t;
if (gmtime_r (&tim, &t) == NULL)
- addf (str, "error: gmtime_r (%d)\n", t);
+ addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
else if (strftime (s, max, "%a %b %e %H:%M:%S UTC %Y", &t) == 0)
- addf (str, "error: strftime (%d)\n", t);
+ addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
else
addf (str, _("\t\tCreation: %s\n"), s);
}
if (tim == 0)
{
- addf (str, _("\t\tExpiration: Never\n"), s);
+ addf (str, _("\t\tExpiration: Never\n"));
}
else
{
if (gmtime_r (&tim, &t) == NULL)
- addf (str, "error: gmtime_r (%d)\n", t);
+ addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
else if (strftime (s, max, "%a %b %e %H:%M:%S UTC %Y", &t) == 0)
- addf (str, "error: strftime (%d)\n", t);
+ addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
else
addf (str, _("\t\tExpiration: %s\n"), s);
}
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA
+AM_CFLAGS = $(WARN_CFLAGS)
AM_CPPFLAGS = \
- $(WARN_CFLAGS) \
-I$(srcdir)/../gl \
-I$(builddir)/../gl \
-I$(srcdir)/../includes \
if ((result = _gnutls_x509_oid_data_choice (given_oid)) > 0)
{
- char *string_type;
+ const char *string_type;
int i;
string_type = "printableString";
#define addf _gnutls_string_append_printf
#define adds _gnutls_string_append_str
-#define ERROR_STR "(error)"
+#define ERROR_STR (char*) "(error)"
static void
hexdump (gnutls_string * str, const char *data, size_t len, const char *spc)
struct tm t;
if (gmtime_r (&tim, &t) == NULL)
- addf (str, "error: gmtime_r (%d)\n", t);
+ addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
- addf (str, "error: strftime (%d)\n", t);
+ addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
else
addf (str, _("\t\tNot Before: %s\n"), s);
}
struct tm t;
if (gmtime_r (&tim, &t) == NULL)
- addf (str, "error: gmtime_r (%d)\n", t);
+ addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
- addf (str, "error: strftime (%d)\n", t);
+ addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
else
addf (str, _("\t\tNot After: %s\n"), s);
}
struct tm t;
if (gmtime_r (&tim, &t) == NULL)
- addf (str, "unknown activation (%d), ", t);
+ addf (str, "unknown activation (%ld), ", (unsigned long) tim);
else if (strftime (s, max, "%Y-%m-%d %H:%M:%S UTC", &t) == 0)
- addf (str, "failed activation (%d), ", t);
+ addf (str, "failed activation (%ld), ", (unsigned long) tim);
else
addf (str, "activated `%s', ", s);
}
struct tm t;
if (gmtime_r (&tim, &t) == NULL)
- addf (str, "unknown expiry (%d), ", t);
+ addf (str, "unknown expiry (%ld), ", (unsigned long) tim);
else if (strftime (s, max, "%Y-%m-%d %H:%M:%S UTC", &t) == 0)
- addf (str, "failed expiry (%d), ", t);
+ addf (str, "failed expiry (%ld), ", (unsigned long) tim);
else
addf (str, "expires `%s', ", s);
}
struct tm t;
if (gmtime_r (&tim, &t) == NULL)
- addf (str, "error: gmtime_r (%d)\n", t);
+ addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
- addf (str, "error: strftime (%d)\n", t);
+ addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
else
addf (str, _("\t\tIssued: %s\n"), s);
}
if (tim == -1)
addf (str, "\t\tNo next update time.\n");
else if (gmtime_r (&tim, &t) == NULL)
- addf (str, "error: gmtime_r (%d)\n", t);
+ addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
- addf (str, "error: strftime (%d)\n", t);
+ addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
else
addf (str, _("\t\tNext at: %s\n"), s);
}
adds (str, "\n");
if (gmtime_r (&tim, &t) == NULL)
- addf (str, "error: gmtime_r (%d)\n", t);
+ addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
- addf (str, "error: strftime (%d)\n", t);
+ addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
else
addf (str, _("\t\tRevoked at: %s\n"), s);
}
gnutls_x509_crt_fmt_t format, void *output_data,
size_t * output_data_size)
{
- char *msg;
+ const char *msg;
int ret;
if (key == NULL)
#include <gnutls_int.h>
#include <gnutls/crypto.h>
+#include <gnutls/extra.h>
#include <md5.h>
#include <hmac.h>
# include <lzo1x.h>
# endif
#endif
+#include <gnutls/extra.h>
#ifdef USE_LZO
#include <gnutls_compress.h>
{
if (local_alloc)
free (tmpbuf);
- return "Buffer too small";
+ return (char*) "Buffer too small";
}
return tmpbuf;
SUBDIRS = cfg
-INCS = \
+AM_CFLAGS = $(WARN_CFLAGS)
+AM_CPPFLAGS = \
-I$(srcdir)/../gl \
-I$(builddir)/../gl \
-I$(builddir)/../lib/includes \
-I$(srcdir)/../lib/includes \
-I$(srcdir)/../libextra/includes \
-I$(srcdir)/cfg
-AM_CPPFLAGS = $(WARN_CFLAGS) $(INCS)
bin_PROGRAMS = gnutls-serv gnutls-cli psktool gnutls-cli-debug
if ENABLE_PKI
bin_PROGRAMS += srptool
endif
-gnutls_serv_SOURCES = serv.gaa serv-gaa.h serv-gaa.c list.h serv.c \
- common.h common.c certtool-common.h
+noinst_LTLIBRARIES =
+
+gnutls_serv_SOURCES = list.h serv.c common.h common.c certtool-common.h
gnutls_serv_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la \
- ../gl/libgnu.la
+ ../gl/libgnu.la libcmd-serv.la
+noinst_LTLIBRARIES += libcmd-serv.la
+libcmd_serv_la_CFLAGS =
+libcmd_serv_la_SOURCES = serv.gaa serv-gaa.h serv-gaa.c
if ENABLE_SRP
-srptool_SOURCES = crypt.gaa crypt-gaa.h crypt-gaa.c crypt.c
-srptool_LDADD = ../lib/libgnutls.la ../gl/libgnu.la ../lib/gl/liblgnu.la
+srptool_SOURCES = crypt.c
+srptool_LDADD = ../lib/libgnutls.la ../gl/libgnu.la ../lib/gl/liblgnu.la \
+ libcmd-srp.la
+noinst_LTLIBRARIES += libcmd-srp.la
+libcmd_srp_la_CFLAGS =
+libcmd_srp_la_SOURCES = crypt.gaa crypt-gaa.h crypt-gaa.c
endif
-psktool_SOURCES = psk.gaa psk-gaa.h psk-gaa.c psk.c
-psktool_LDADD = ../lib/libgnutls.la ../gl/libgnu.la ../lib/gl/liblgnu.la
+psktool_SOURCES = psk.c
+psktool_LDADD = ../lib/libgnutls.la ../gl/libgnu.la ../lib/gl/liblgnu.la \
+ libcmd-psk.la
+noinst_LTLIBRARIES += libcmd-psk.la
+libcmd_psk_la_CFLAGS =
+libcmd_psk_la_SOURCES = psk.gaa psk-gaa.h psk-gaa.c
-gnutls_cli_SOURCES = cli.gaa cli-gaa.h cli-gaa.c cli.c common.h \
- common.c
+gnutls_cli_SOURCES = cli.c common.h common.c
gnutls_cli_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la \
- ../gl/libgnu.la
+ ../gl/libgnu.la libcmd-cli.la
+noinst_LTLIBRARIES += libcmd-cli.la
+libcmd_cli_la_CFLAGS =
+libcmd_cli_la_SOURCES = cli.gaa cli-gaa.h cli-gaa.c
-gnutls_cli_debug_SOURCES = tls_test.gaa tls_test-gaa.h tls_test-gaa.c \
- tls_test.c tests.h tests.c common.h common.c
-gnutls_cli_debug_LDADD = ../lib/libgnutls.la ../gl/libgnu.la
+gnutls_cli_debug_SOURCES = tls_test.c tests.h tests.c common.h common.c
+gnutls_cli_debug_LDADD = ../lib/libgnutls.la ../gl/libgnu.la \
+ libcmd-cli-debug.la
+noinst_LTLIBRARIES += libcmd-cli-debug.la
+libcmd_cli_debug_la_CFLAGS =
+libcmd_cli_debug_la_SOURCES = tls_test.gaa tls_test-gaa.h tls_test-gaa.c
-certtool_SOURCES = certtool.gaa certtool-gaa.h certtool-cfg.h \
- certtool-gaa.c certtool.c prime.c certtool-cfg.c
-certtool_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la \
- ../gl/libgnu.la ../lib/gl/liblgnu.la @LTLIBREADLINE@
+certtool_SOURCES = certtool.c prime.c
+certtool_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la \
+ ../gl/libgnu.la ../lib/gl/liblgnu.la @LTLIBREADLINE@ \
+ libcmd-certtool.la
if HAVE_LIBCFG
certtool_LDADD += -lcfg+
else
-noinst_LTLIBRARIES = libcfg.la
-libcfg_la_CPPFLAGS = $(INCS)
+noinst_LTLIBRARIES += libcfg.la
+libcfg_la_CFLAGS =
libcfg_la_SOURCES = cfg/cfg+.c cfg/cfgfile.c cfg/cmdline.c cfg/parse.c \
cfg/props.c cfg/shared.c cfg/platon/str/dynfgets.c \
cfg/platon/str/strctype.c cfg/platon/str/strdyn.c \
cfg/platon/str/strplus.c
certtool_LDADD += libcfg.la
endif
+noinst_LTLIBRARIES += libcmd-certtool.la
+libcmd_certtool_la_CFLAGS =
+libcmd_certtool_la_SOURCES = certtool.gaa certtool-gaa.h \
+ certtool-gaa.c certtool-cfg.h certtool-cfg.c
+libcmd_certtool_la_LIBADD = ../gl/libgnu.la
noinst_PROGRAMS = errcodes printlist
errcodes_SOURCES = errcodes.c
/* global stuff here */
int resume, starttls, insecure;
-char *hostname = NULL;
+const char *hostname = NULL;
char *service;
int record_max_size;
int fingerprint;
parse_comp (info.comp, info.ncomp, comp_priority);
}
+void cli_version (void);
+
void
cli_version (void)
{
# include <winbase.h>
#endif
+#ifndef __attribute__
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
+# define __attribute__(Spec) /* empty */
+# endif
+#endif
+
/* the number of elements in the priority structures.
*/
#define PRI_MAX 16
const gnutls_datum_t * g,
const gnutls_datum_t * n);
-
static void
print_num (const char *msg, const gnutls_datum_t * num)
{
}
if (info.passwd == NULL)
- info.passwd = KPASSWD;
+ info.passwd = (char*) KPASSWD;
if (info.passwd_conf == NULL)
- info.passwd_conf = KPASSWD_CONF;
+ info.passwd_conf = (char*) KPASSWD_CONF;
if (info.username == NULL)
{
return index;
}
+extern void srptool_version(void);
+
void
srptool_version (void)
{
static int cparams = 0;
+int generate_prime (int bits, int how);
+
/* If how is zero then the included parameters are used.
*/
int
}
if (info.passwd == NULL)
- info.passwd = KPASSWD;
+ info.passwd = (char*) KPASSWD;
if (info.username == NULL)
{
#endif /* ENABLE_PSK */
+void psktool_version (void);
+
void
psktool_version (void)
{
*response_length = ((*response) ? strlen (*response) : 0);
}
+static void terminate (int sig) __attribute__ ((noreturn));
+
static void
terminate (int sig)
{
parse_comp (info.comp, info.ncomp, comp_priority);
}
+extern void serv_version(void);
+
void
serv_version (void)
{
/* global stuff here */
int resume;
-char *hostname = NULL;
+const char *hostname = NULL;
int port;
int record_max_size;
int fingerprint;
typedef struct
{
- char *test_name;
+ const char *test_name;
TEST_FUNC func;
- char *suc_str;
- char *fail_str;
- char *unsure_str;
+ const char *suc_str;
+ const char *fail_str;
+ const char *unsure_str;
} TLS_TEST;
static const TLS_TEST tls_tests[] = {
}
+void tls_test_version (void);
+
void
tls_test_version (void)
{
EXTRA_DIST = libgcrypt.supp hostname-check.README
+AM_CFLAGS = $(WARN_CFLAGS)
AM_CPPFLAGS = \
- $(WARN_CFLAGS) \
-I$(top_srcdir)/gl \
-I$(top_builddir)/gl \
-I$(top_srcdir)/lib/includes \
#include <unistd.h>
#include <gnutls/gnutls.h>
+#include "tcp.c"
+
#include "utils.h"
static void
#define MAX_BUF 1024
#define MSG "Hello TLS"
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
- const char *PORT = "5556";
- const char *SERVER = "127.0.0.1";
- int err, sd;
- struct sockaddr_in sa;
-
- /* connects to server
- */
- sd = socket (AF_INET, SOCK_STREAM, 0);
-
- memset (&sa, '\0', sizeof (sa));
- sa.sin_family = AF_INET;
- sa.sin_port = htons (atoi (PORT));
- inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
- err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
- if (err < 0)
- {
- fprintf (stderr, "Connect error\n");
- exit (1);
- }
-
- return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
- shutdown (sd, SHUT_RDWR); /* no more receptions */
- close (sd);
-}
-
-void
+static void
client (void)
{
int ret, sd, ii;
/* These are global */
gnutls_anon_server_credentials_t anoncred;
-gnutls_session_t
+static gnutls_session_t
initialize_tls_session (void)
{
gnutls_session_t session;
static int
generate_dh_params (void)
{
- const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+ const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
/* Generate Diffie Hellman parameters - for use with DHE
* kx algorithms. These should be discarded and regenerated
* once a day, once a week or once a month. Depending on the
char buffer[MAX_BUF + 1];
int optval = 1;
-void
+static void
server_start (void)
{
/* Socket operations
success ("server: ready. Listening to port '%d'.\n", PORT);
}
-void
+static void
server (void)
{
/* this must be called once in the program
#include <gnutls/crypto.h>
#include "../lib/random.h"
-void
-mylogfn (int level, const char *ptr)
-{
- printf ("Got Logs: ");
- if (ptr)
- printf ("%s", ptr);
-}
-
-int
+static int
rng_init (void **ctx)
{
return 0;
}
-int
+static int
rng_rnd (void *ctx, int level, void *data, size_t datasize)
{
memset (data, 1, datasize);
return 0;
}
-void
+static void
rng_deinit (void *ctx)
{
}
#include <unistd.h>
#include <gnutls/gnutls.h>
+#include "tcp.c"
+
#include "utils.h"
/* A very basic TLS client, with PSK authentication.
fprintf (stderr, "|<%d>| %s", level, str);
}
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
- const char *PORT = "5556";
- const char *SERVER = "127.0.0.1";
- int err, sd;
- struct sockaddr_in sa;
-
- /* connects to server
- */
- sd = socket (AF_INET, SOCK_STREAM, 0);
-
- memset (&sa, '\0', sizeof (sa));
- sa.sin_family = AF_INET;
- sa.sin_port = htons (atoi (PORT));
- inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
- err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
- if (err < 0)
- {
- fprintf (stderr, "Connect error\n");
- exit (1);
- }
-
- return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
- shutdown (sd, SHUT_RDWR); /* no more receptions */
- close (sd);
-}
-
-void
+static void
client (void)
{
int ret, sd, ii;
gnutls_session_t session;
char buffer[MAX_BUF + 1];
gnutls_psk_client_credentials_t pskcred;
- const gnutls_datum_t key = { "DEADBEEF", 8 };
+ const gnutls_datum_t key = { (char*) "DEADBEEF", 8 };
gnutls_global_init ();
/* These are global */
gnutls_psk_server_credentials_t server_pskcred;
-gnutls_session_t
+static gnutls_session_t
initialize_tls_session (void)
{
gnutls_session_t session;
static int
generate_dh_params (void)
{
- const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+ const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
/* Generate Diffie Hellman parameters - for use with DHE
* kx algorithms. These should be discarded and regenerated
* once a day, once a week or once a month. Depending on the
char buffer[MAX_BUF + 1];
int optval = 1;
-void
+static void
server_start (void)
{
success ("Launched, generating DH parameters...\n");
success ("server: ready. Listening to port '%d'.\n", PORT);
}
-void
+static void
server (void)
{
/* this must be called once in the program
/*
- * Copyright (C) 2006, 2007 Free Software Foundation
+ * Copyright (C) 2006, 2007, 2008 Free Software Foundation
* Author: Simon Josefsson, Howard Chu
*
* This file is part of GNUTLS.
"bHarWgDg9CKVP1DggVkcD838s//kE1Vl2DReyfAtEQ1agSXLFncgxL+yOi1o3lcq\n"
"+dmDgpDn168TY1Iug80uVKg7AfkLrA==\n" "-----END CERTIFICATE-----\n";
-void
+static void
print_dn (gnutls_x509_dn_t dn)
{
int i, j, ret = 0;
char *to_client;
size_t to_client_len;
-ssize_t
+static ssize_t
client_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
{
success ("client_pull len %d has %d\n", len, to_client_len);
return len;
}
-ssize_t
+static ssize_t
client_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
{
size_t newlen = to_server_len + len;
return len;
}
-ssize_t
+static ssize_t
server_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
{
success ("server_pull len %d has %d\n", len, to_server_len);
return len;
}
-ssize_t
+static ssize_t
server_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
{
size_t newlen = to_client_len + len;
return len;
}
-void
+static void
client_finished_callback (gnutls_session_t session,
const void *finished, size_t len)
{
hexprint (finished, len);
}
-void
+static void
server_finished_callback (gnutls_session_t session,
const void *finished, size_t len)
{
{
/* Server stuff. */
gnutls_anon_server_credentials_t s_anoncred;
- const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+ const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
static gnutls_dh_params_t dh_params;
gnutls_session_t server;
int sret = GNUTLS_E_AGAIN;
#include "../lib/x509/pbkdf2-sha1.h"
#include "../lib/debug.h"
-int
-is_secure_mem (const void *ign)
-{
- return 0;
-}
-
void
doit (void)
{
char *to_client;
size_t to_client_len;
-ssize_t
+static ssize_t
client_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
{
success ("client_pull len %d has %d\n", len, to_client_len);
return len;
}
-ssize_t
+static ssize_t
client_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
{
size_t newlen = to_server_len + len;
return len;
}
-ssize_t
+static ssize_t
server_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
{
success ("server_pull len %d has %d\n", len, to_server_len);
return len;
}
-ssize_t
+static ssize_t
server_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
{
size_t newlen = to_client_len + len;
{
/* Server stuff. */
gnutls_anon_server_credentials_t s_anoncred;
- const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+ const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
static gnutls_dh_params_t dh_params;
gnutls_session_t server;
int sret = GNUTLS_E_AGAIN;
#include "ex-session-info.c"
#include "ex-x509-info.c"
+#include "tcp.c"
pid_t child;
#define MAX_BUF 1024
#define MSG "Hello TLS"
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
- const char *PORT = "5556";
- const char *SERVER = "127.0.0.1";
- int err, sd;
- struct sockaddr_in sa;
-
- /* connects to server
- */
- sd = socket (AF_INET, SOCK_STREAM, 0);
-
- memset (&sa, '\0', sizeof (sa));
- sa.sin_family = AF_INET;
- sa.sin_port = htons (atoi (PORT));
- inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
- err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
- if (err < 0)
- {
- fprintf (stderr, "Connect error\n");
- exit (1);
- }
-
- return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
- shutdown (sd, SHUT_RDWR); /* no more receptions */
- close (sd);
-}
-
static unsigned char cert_txt[] =
"-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
"Version: GnuPG v1.0.6 (GNU/Linux)\n"
"=4M0W\n" "-----END PGP PRIVATE KEY BLOCK-----\n";
const gnutls_datum_t key = { key_txt, sizeof (key_txt) };
-void
+static void
client (void)
{
int ret, sd, ii;
/* These are global */
gnutls_certificate_credentials_t pgp_cred;
-gnutls_session_t
+static gnutls_session_t
initialize_tls_session (void)
{
gnutls_session_t session;
static int
generate_dh_params (void)
{
- const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+ const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
/* Generate Diffie Hellman parameters - for use with DHE
* kx algorithms. These should be discarded and regenerated
* once a day, once a week or once a month. Depending on the
"=mZnW\n" "-----END PGP PRIVATE KEY BLOCK-----\n";
const gnutls_datum_t server_key = { server_key_txt, sizeof (server_key_txt) };
-void
+static void
server_start (void)
{
/* Socket operations
success ("server: ready. Listening to port '%d'.\n", PORT);
}
-void
+static void
server (void)
{
/* this must be called once in the program
/*
- * Copyright (C) 2007 Free Software Foundation
+ * Copyright (C) 2007, 2008 Free Software Foundation
*
* Author: Simon Josefsson
*
fprintf (stderr, "|<%d>| %s", level, str);
}
-char *salt[3] = { "salt1", "ltsa22", "balt33" };
-char *pw[3] = { "secret1", "verysecret2", "veryverysecret3" };
+static const char *salt[3] = { "salt1", "ltsa22", "balt33" };
+static const char *pw[3] = { "secret1", "verysecret2", "veryverysecret3" };
-char *values[] = {
+static const char *values[] = {
/* 1.0 */
"85a3c676a66f0960f4807144a28c8d61a0001b81846f301a1ac164289879972f",
/* 1.2 */
#include <unistd.h>
#include <gnutls/gnutls.h>
+#include "tcp.c"
+
#include "utils.h"
/* A very basic TLS client, with PSK authentication.
#define MAX_BUF 1024
#define MSG "Hello TLS"
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
- const char *PORT = "5556";
- const char *SERVER = "127.0.0.1";
- int err, sd;
- struct sockaddr_in sa;
-
- /* connects to server
- */
- sd = socket (AF_INET, SOCK_STREAM, 0);
-
- memset (&sa, '\0', sizeof (sa));
- sa.sin_family = AF_INET;
- sa.sin_port = htons (atoi (PORT));
- inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
- err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
- if (err < 0)
- {
- fprintf (stderr, "Connect error\n");
- exit (1);
- }
-
- return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
- shutdown (sd, SHUT_RDWR); /* no more receptions */
- close (sd);
-}
-
-void
+static void
client (void)
{
int ret, sd, ii;
gnutls_psk_client_credentials_t pskcred;
/* Need to enable anonymous KX specifically. */
const int kx_prio[] = { GNUTLS_KX_PSK, 0 };
- const gnutls_datum_t key = { "DEADBEEF", 8 };
+ const gnutls_datum_t key = { (char*) "DEADBEEF", 8 };
gnutls_global_init ();
/* These are global */
gnutls_psk_server_credentials_t server_pskcred;
-gnutls_session_t
+static gnutls_session_t
initialize_tls_session (void)
{
gnutls_session_t session;
char buffer[MAX_BUF + 1];
int optval = 1;
-void
+static void
server_start (void)
{
success ("Launched...\n");
success ("server: ready. Listening to port '%d'.\n", PORT);
}
-void
+static void
server (void)
{
/* this must be called once in the program
#include <unistd.h>
#include <gnutls/gnutls.h>
+#include "tcp.c"
+
#include "utils.h"
static void wrap_db_init (void);
#define MAX_BUF 1024
#define MSG "Hello TLS"
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
- const char *PORT = "5556";
- const char *SERVER = "127.0.0.1";
- int err, sd;
- struct sockaddr_in sa;
-
- /* connects to server
- */
- sd = socket (AF_INET, SOCK_STREAM, 0);
-
- memset (&sa, '\0', sizeof (sa));
- sa.sin_family = AF_INET;
- sa.sin_port = htons (atoi (PORT));
- inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
- err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
- if (err < 0)
- {
- fprintf (stderr, "Connect error\n");
- exit (1);
- }
-
- return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
- shutdown (sd, SHUT_RDWR); /* no more receptions */
- close (sd);
-}
-
-void
+static void
client (void)
{
int ret, sd, ii;
/* These are global */
gnutls_anon_server_credentials_t anoncred;
-gnutls_session_t
+static gnutls_session_t
initialize_tls_session (void)
{
gnutls_session_t session;
static int
generate_dh_params (void)
{
- const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+ const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
/* Generate Diffie Hellman parameters - for use with DHE
* kx algorithms. These should be discarded and regenerated
* once a day, once a week or once a month. Depending on the
char buffer[MAX_BUF + 1];
int optval = 1;
-void
+static void
global_start (void)
{
/* Socket operations
success ("server: ready. Listening to port '%d'.\n", PORT);
}
-void
+static void
global_stop (void)
{
success ("global stop\n");
gnutls_global_deinit ();
}
-void
+static void
server (void)
{
size_t t;
doit (void)
{
gnutls_certificate_credentials_t x509cred;
- char *file, *password;
+ const char *file, *password;
int ret;
ret = gnutls_global_init ();
#include "utils.h"
+#include "tcp.c"
+
#include <readline.h>
/* A very basic TLS client, with anonymous authentication.
#define MAX_BUF 1024
#define MSG "Hello TLS"
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
- const char *PORT = "5556";
- const char *SERVER = "127.0.0.1";
- int err, sd;
- struct sockaddr_in sa;
-
- /* connects to server
- */
- sd = socket (AF_INET, SOCK_STREAM, 0);
-
- memset (&sa, '\0', sizeof (sa));
- sa.sin_family = AF_INET;
- sa.sin_port = htons (atoi (PORT));
- inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
- err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
- if (err < 0)
- {
- fprintf (stderr, "Connect error\n");
- exit (1);
- }
-
- return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
- shutdown (sd, SHUT_RDWR); /* no more receptions */
- close (sd);
-}
-
-int
+static int
client_avp (gnutls_session_t session, void *ptr,
const char *last, size_t lastlen, char **new, size_t * newlen)
{
static int iter = 0;
- char *p;
+ const char *p;
if (last)
printf ("client: received %d bytes AVP: `%.*s'\n",
return 0;
}
-void
+static void
client (void)
{
int ret, sd, ii;
gnutls_anon_server_credentials_t anoncred;
gnutls_ia_server_credentials_t iacred;
-gnutls_session_t
+static gnutls_session_t
initialize_tls_session (void)
{
gnutls_session_t session;
static int
generate_dh_params (void)
{
- const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+ const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
/* Generate Diffie Hellman parameters - for use with DHE
* kx algorithms. These should be discarded and regenerated
* once a day, once a week or once a month. Depending on the
char buffer[MAX_BUF + 1];
int optval = 1;
-int
+static int
server_avp (gnutls_session_t session, void *ptr,
const char *last, size_t lastlen, char **new, size_t * newlen)
{
static int iter = 0;
- char *p;
+ const char *p;
if (last)
printf ("server: received %d bytes AVP: `%.*s'\n",
return 0;
}
-void
+static void
server_start (void)
{
/* Socket operations
success ("server: ready. Listening to port '%d'\n", PORT);
}
-void
+static void
server (void)
{
/* this must be called once in the program
/*
- * Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation
*
* Author: Simon Josefsson
*
int error_count = 0;
int break_on_error = 0;
-char *pkcs3 =
+const char *pkcs3 =
"-----BEGIN DH PARAMETERS-----\n"
"MIGGAoGAtkxw2jlsVCsrfLqxrN+IrF/3W8vVFvDzYbLmxi2GQv9s/PQGWP1d9i22\n"
"P2DprfcJknWt7KhCI1SaYseOQIIIAYP78CfyIpGScW/vS8khrw0rlQiyeCvQgF3O\n"
/*
- * Copyright (C) 2004, 2005, 2007 Free Software Foundation
+ * Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation
*
* Author: Simon Josefsson
*
# include <stdarg.h>
# include <gnutls/gnutls.h>
+#ifndef __attribute__
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
+# define __attribute__(Spec) /* empty */
+# endif
+#endif
+
extern int debug;
extern int error_count;
extern int break_on_error;
-extern char *pkcs3;
+extern const char *pkcs3;
-extern void fail (const char *format, ...);
-extern void success (const char *format, ...);
+extern void fail (const char *format, ...)
+ __attribute__ ((format (printf, 1, 2)));
+extern void success (const char *format, ...)
+ __attribute__ ((format (printf, 1, 2)));
extern void escapeprint (const char *str, size_t len);
extern void hexprint (const char *str, size_t len);
#include "ex-session-info.c"
#include "ex-x509-info.c"
+#include "tcp.c"
pid_t child;
#define MAX_BUF 1024
#define MSG "Hello TLS"
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
- const char *PORT = "5556";
- const char *SERVER = "127.0.0.1";
- int err, sd;
- struct sockaddr_in sa;
-
- /* connects to server
- */
- sd = socket (AF_INET, SOCK_STREAM, 0);
-
- memset (&sa, '\0', sizeof (sa));
- sa.sin_family = AF_INET;
- sa.sin_port = htons (atoi (PORT));
- inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
- err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
- if (err < 0)
- {
- fprintf (stderr, "Connect error\n");
- exit (1);
- }
-
- return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
- shutdown (sd, SHUT_RDWR); /* no more receptions */
- close (sd);
-}
-
static unsigned char ca_pem[] =
"-----BEGIN CERTIFICATE-----\n"
"MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
}
-void
+static void
client (void)
{
int ret, sd, ii;
/* These are global */
gnutls_certificate_credentials_t x509_cred;
-gnutls_session_t
+static gnutls_session_t
initialize_tls_session (void)
{
gnutls_session_t session;
static int
generate_dh_params (void)
{
- const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+ const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
/* Generate Diffie Hellman parameters - for use with DHE
* kx algorithms. These should be discarded and regenerated
* once a day, once a week or once a month. Depending on the
sizeof (server_key_pem)
};
-void
+static void
server_start (void)
{
/* Socket operations
success ("server: ready. Listening to port '%d'.\n", PORT);
}
-void
+static void
server (void)
{
/* this must be called once in the program
#include "ex-session-info.c"
#include "ex-x509-info.c"
+#include "tcp.c"
pid_t child;
#define MAX_BUF 1024
#define MSG "Hello TLS"
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
- const char *PORT = "5556";
- const char *SERVER = "127.0.0.1";
- int err, sd;
- struct sockaddr_in sa;
-
- /* connects to server
- */
- sd = socket (AF_INET, SOCK_STREAM, 0);
-
- memset (&sa, '\0', sizeof (sa));
- sa.sin_family = AF_INET;
- sa.sin_port = htons (atoi (PORT));
- inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
- err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
- if (err < 0)
- {
- fprintf (stderr, "Connect error\n");
- exit (1);
- }
-
- return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
- shutdown (sd, SHUT_RDWR); /* no more receptions */
- close (sd);
-}
-
static unsigned char ca_pem[] =
"-----BEGIN CERTIFICATE-----\n"
"MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
"-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t key = { key_pem, sizeof (key_pem) };
-void
+static void
client (void)
{
int ret, sd, ii;
/* These are global */
gnutls_certificate_credentials_t x509_cred;
-gnutls_session_t
+static gnutls_session_t
initialize_tls_session (void)
{
gnutls_session_t session;
static int
generate_dh_params (void)
{
- const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+ const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
/* Generate Diffie Hellman parameters - for use with DHE
* kx algorithms. These should be discarded and regenerated
* once a day, once a week or once a month. Depending on the
sizeof (server_key_pem)
};
-void
+static void
server_start (void)
{
/* Socket operations
success ("server: ready. Listening to port '%d'.\n", PORT);
}
-void
+static void
server (void)
{
/* this must be called once in the program
#include "ex-session-info.c"
#include "ex-x509-info.c"
-extern int print_info (gnutls_session_t session);
+#include "tcp.c"
#include "utils.h"
#define MAX_BUF 1024
#define MSG "Hello TLS"
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
- const char *PORT = "5556";
- const char *SERVER = "127.0.0.1";
- int err, sd;
- struct sockaddr_in sa;
-
- /* connects to server
- */
- sd = socket (AF_INET, SOCK_STREAM, 0);
-
- memset (&sa, '\0', sizeof (sa));
- sa.sin_family = AF_INET;
- sa.sin_port = htons (atoi (PORT));
- inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
- err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
- if (err < 0)
- {
- fprintf (stderr, "Connect error\n");
- exit (1);
- }
-
- return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
- shutdown (sd, SHUT_RDWR); /* no more receptions */
- close (sd);
-}
-
static char ca_pem[] =
"-----BEGIN CERTIFICATE-----\n"
"MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
"dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t cert = { cert_pem, sizeof (cert_pem) };
-int
+static int
sign_func (gnutls_session_t session,
void *userdata,
gnutls_certificate_type_t cert_type,
return ret;
}
-void
+static void
client (void)
{
int ret, sd, ii;
/* These are global */
gnutls_certificate_credentials_t x509_cred;
-gnutls_session_t
+static gnutls_session_t
initialize_tls_session (void)
{
gnutls_session_t session;
static int
generate_dh_params (void)
{
- const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+ const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
/* Generate Diffie Hellman parameters - for use with DHE
* kx algorithms. These should be discarded and regenerated
* once a day, once a week or once a month. Depending on the
sizeof (server_key_pem)
};
-void
+static void
server_start (void)
{
/* Socket operations
success ("server: ready. Listening to port '%d'.\n", PORT);
}
-void
+static void
server (void)
{
/* this must be called once in the program