AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)
+case "${target}" in
+ *-*-mingw32*)
+ SERV_LIBS="$SERV_LIBS -lwsock32"
+ ;;
+ *)
+ ;;
+esac
+
+
opt_dmalloc_mode=no
AC_MSG_CHECKING([whether in dmalloc mode])
AC_ARG_ENABLE(dmalloc-mode,
AC_CHECK_HEADERS(unistd.h strings.h stddef.h alloca.h)
AC_CHECK_HEADERS(sys/stat.h sys/types.h sys/socket.h)
AC_CHECK_HEADERS(errno.h sys/time.h time.h)
-AC_CHECK_FUNCS(memmove strnstr mmap gmtime_r,,)
+AC_CHECK_FUNCS(memmove strnstr mmap gmtime_r inet_ntop,,)
AC_FUNC_ALLOCA
# include <errno.h>
#endif
+#ifdef _WIN32
+# include <winsock2.h>
+#endif
+
#ifndef EAGAIN
# define EAGAIN EWOULDBLOCK
#endif
size_t verifier_size;
int indx;
- p = rindex( str, ':'); /* we have index */
+ p = strrchr( str, ':'); /* we have index */
if (p==NULL) {
gnutls_assert();
return GNUTLS_E_SRP_PWD_PARSING_ERROR;
}
/* now go for salt */
- p = rindex( str, ':'); /* we have salt */
+ p = strrchr( str, ':'); /* we have salt */
if (p==NULL) {
gnutls_assert();
return GNUTLS_E_SRP_PWD_PARSING_ERROR;
}
/* now go for verifier */
- p = rindex( str, ':'); /* we have verifier */
+ p = strrchr( str, ':'); /* we have verifier */
if (p==NULL) {
_gnutls_free_datum(&entry->salt);
return GNUTLS_E_SRP_PWD_PARSING_ERROR;
opaque * tmp;
int ret;
- p = rindex( str, ':'); /* we have g */
+ p = strrchr( str, ':'); /* we have g */
if (p==NULL) {
gnutls_assert();
return GNUTLS_E_SRP_PWD_PARSING_ERROR;
entry->g.size = ret;
/* now go for n - modulo */
- p = rindex( str, ':'); /* we have n */
+ p = strrchr( str, ':'); /* we have n */
if (p==NULL) {
_gnutls_free_datum( &entry->g);
gnutls_assert();
#include <opencdk.h>
#include <time.h>
#include <sys/stat.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <assert.h>
#define OPENPGP_NAME_SIZE 256
fi
fi
fi
- if test $ok = yes; then
+ if test x$ok = xyes; then
LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG $libgcrypt_config_args --cflags`
LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG $libgcrypt_config_args --libs`
AC_MSG_RESULT(yes)
gnutls_srpcrypt_SOURCES = crypt-gaa.c crypt.c
gnutls_srpcrypt_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la $(LIBGCRYPT_LIBS) $(LIBOPENCDK_LIBS)
gnutls_cli_SOURCES = cli-gaa.c cli.c common.c
-gnutls_cli_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la $(LIBGCRYPT_LIBS) $(LIBOPENCDK_LIBS)
+gnutls_cli_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la $(LIBGCRYPT_LIBS) $(LIBOPENCDK_LIBS) $(SERV_LIBS)
gnutls_cli_debug_SOURCES = tls_test-gaa.c tls_test.c tests.c common.c
-gnutls_cli_debug_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la $(LIBGCRYPT_LIBS) $(LIBOPENCDK_LIBS)
+gnutls_cli_debug_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la $(LIBGCRYPT_LIBS) $(LIBOPENCDK_LIBS) $(SERV_LIBS)
noinst_PROGRAMS = retcodes
return atoi(input);
}
+#ifdef _WIN32
+# define getpass read_str
+#endif
+
static const char* read_str( const char* input_str)
{
static char input[128];
{
int tmp;
char a;
- if(sscanf(arg, "%d%c", &tmp, &a) != 1)
+ if(sscanf(arg, "%d%c", &tmp, &a) < 1)
{
printf("Option %s: '%s' isn't an integer\n", gaa_current_option, arg);
GAAERROR(-1);
{
float tmp;
char a;
- if(sscanf(arg, "%f%c", &tmp, &a) != 1)
+ if(sscanf(arg, "%f%c", &tmp, &a) < 1)
{
printf("Option %s: '%s' isn't a float number\n", gaa_current_option, arg);
GAAERROR(-1);
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+
+#ifdef _WIN32
+# include <winsock.h>
+# include <io.h>
+# include <winbase.h>
+# define socklen_t int
+# define close closesocket
+#else
+# include <sys/socket.h>
+# include <netinet/in.h>
+# include <arpa/inet.h>
+# include <unistd.h>
+# include <netdb.h>
+# include <signal.h>
+#endif
+
#include <string.h>
-#include <unistd.h>
#include <gnutls/gnutls.h>
#include <gnutls/extra.h>
#include <gnutls/x509.h>
#include <sys/time.h>
-#include <signal.h>
-#include <netdb.h>
#include "common.h"
#include "cli-gaa.h"
int user_term = 0;
struct hostent *server_host;
socket_st hd;
+#ifdef _WIN32
+ WORD wVersionRequested;
+ WSADATA wsaData;
+#endif
gaa_parser(argc, argv);
if (hostname == NULL) {
exit(1);
}
+#ifdef _WIN32
+ wVersionRequested = MAKEWORD(1, 1);
+ if (WSAStartup(wVersionRequested, &wsaData) != 0) {
+ perror("WSA_STARTUP_ERROR");
+ }
+#endif
+
+#ifndef _WIN32
signal(SIGPIPE, SIG_IGN);
+#endif
init_global_tls_stuff();
sa.sin_addr.s_addr = *((unsigned int *) server_host->h_addr);
+#ifdef HAVE_INET_NTOP
if (inet_ntop(AF_INET, &sa.sin_addr, buffer, MAX_BUF) == NULL) {
perror("inet_ntop()");
return(1);
}
-
fprintf(stderr, "Connecting to '%s:%d'...\n", buffer, port);
+#else /* use inet_ntoa */
+ fprintf(stderr, "Connecting to '%s:%d'...\n", inet_ntoa( ((struct sockaddr_in*)&sa)->sin_addr),
+ port);
+#endif
+
err = connect(sd, (SA *) & sa, sizeof(sa));
ERR(err, "connect");
printf("\n- Simple Client Mode:\n\n");
+#ifndef _WIN32
signal (SIGALRM, &starttls_alarm);
+#endif
/* do not buffer */
setbuf(stdin, NULL);
#include <gnutls/gnutls.h>
#include <gnutls/extra.h>
#include <gcrypt.h> /* for randomize */
-#include <pwd.h>
+
#include <sys/types.h>
#include <sys/stat.h>
-#include <unistd.h>
+#ifndef _WIN32
+# include <pwd.h>
+# include <unistd.h>
+#endif
#define _MAX(x,y) (x>y?x:y)
/* copy salt, and null terminate after the ':' */
strcpy( _salt, salt);
- pos = index(_salt, ':');
+ pos = strchr(_salt, ':');
if (pos!=NULL) *pos = 0;
/* convert salt to binary. */
}
/* accepts password file */
-static int find_index(char* username, char* file) {
+static int find_strchr(char* username, char* file) {
FILE * fd;
char *pos;
char line[5*1024];
}
if (strncmp(username, line, _MAX(i,strlen(username)) ) == 0) {
/* find the index */
- pos = rindex(line, ':');
+ pos = strrchr(line, ':');
pos++;
fclose(fd);
return atoi(pos);
int iindex;
char *p, *pos;
- iindex = find_index( username, tpasswd);
+ iindex = find_strchr( username, tpasswd);
if (iindex==-1) {
fprintf(stderr, "Cannot find '%s' in %s\n", username, tpasswd);
return -1;
if (strncmp(username, line, _MAX(i,strlen(username)) ) == 0) {
char* verifier_pos, *salt_pos;
- pos = index(line, ':');
+ pos = strchr(line, ':');
fclose(fd);
if (pos==NULL) {
fprintf(stderr, "Cannot parse conf file '%s'\n", conffile);
verifier_pos = pos;
/* Move to the salt */
- pos = index(pos, ':');
+ pos = strchr(pos, ':');
if (pos==NULL) {
fprintf(stderr, "Cannot parse conf file '%s'\n", conffile);
return -1;
info.passwd_conf = KPASSWD_CONF;
if (info.username == NULL) {
+#ifndef _WIN32
pwd = getpwuid(getuid());
if (pwd == NULL) {
}
info.username = pwd->pw_name;
+#else
+ fprintf(stderr, "Please specify a user\n");
+ return -1;
+#endif
}
salt = 16;
p = fgets( line, sizeof(line)-1, fd2);
if (p==NULL) break;
- pp = index( line, ':');
+ pp = strchr( line, ':');
if (pp==NULL) continue;
if ( strncmp( p, username, _MAX(strlen(username), (unsigned int)(pp-p)) ) == 0 ) {
index = atoi(str);
- p = rindex(str, ':'); /* we have g */
+ p = strrchr(str, ':'); /* we have g */
if (p == NULL) {
return -1;
}
}
/* now go for n - modulo */
- p = rindex(str, ':'); /* we have n */
+ p = strrchr(str, ':'); /* we have n */
if (p == NULL) {
return -1;
}
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+
+#ifdef _WIN32
+# include <winsock.h>
+# include <io.h>
+# include <winbase.h>
+# define socklen_t int
+# define close closesocket
+#else
+# include <sys/socket.h>
+# include <netinet/in.h>
+# include <arpa/inet.h>
+# include <unistd.h>
+# include <signal.h>
+#endif
+
#include <string.h>
-#include <unistd.h>
#include <gnutls/gnutls.h>
#include <gnutls/extra.h>
#include "common.h"
-#include <signal.h>
#include "serv-gaa.h"
#include <sys/time.h>
#include <fcntl.h>
char name[256];
int accept_fd;
struct sockaddr_in client_address;
+#ifdef _WIN32
+ WORD wVersionRequested;
+ WSADATA wsaData;
+#endif
+#ifndef _WIN32
signal(SIGPIPE, SIG_IGN);
signal(SIGHUP, SIG_IGN);
signal(SIGTERM, terminate);
if (signal(SIGINT, terminate) == SIG_IGN)
signal(SIGINT, SIG_IGN); /* e.g. background process */
+#else
+ wVersionRequested = MAKEWORD(1, 1);
+ if (WSAStartup(wVersionRequested, &wsaData) != 0) {
+ perror("WSA_STARTUP_ERROR");
+ }
+#endif
gaa_parser(argc, argv);
/* flag which connections we are reading or writing to within the fd sets */
lloopstart(listener_list, j) {
+#ifndef _WIN32
val = fcntl(j->fd, F_GETFL, 0);
if ( (val == -1) || (fcntl(j->fd, F_SETFL, val | O_NONBLOCK) < 0) ) {
perror("fcntl()");
exit(1);
}
+#endif
if (j->http_state == HTTP_STATE_REQUEST) {
FD_SET(j->fd, &rd);
printf("*** This is a resumed session\n");
if (quiet == 0) {
+#ifdef HAVE_INET_NTOP
printf("\n* connection from %s, port %d\n",
inet_ntop(AF_INET, &client_address.sin_addr,
topbuf, sizeof(topbuf)),
ntohs(client_address.sin_port));
+#else
+ printf("\n* connection from %s, port %d\n",
+ inet_ntoa(((struct sockaddr_in*)&client_address)->sin_addr),
+ ntohs(client_address.sin_port));
+#endif
print_info(j->tls_session, NULL);
}
j->handshake_ok = 1;
&& quiet == 0)
printf("*** This is a resumed session\n");
if (quiet == 0) {
+#ifdef HAVE_INET_NTOP
printf("- connection from %s, port %d\n",
inet_ntop(AF_INET, &client_address.sin_addr,
topbuf, sizeof(topbuf)),
ntohs(client_address.sin_port));
+#else
+ printf("\n* connection from %s, port %d\n",
+ inet_ntoa(((struct sockaddr_in*)&client_address)->sin_addr),
+ ntohs(client_address.sin_port));
+#endif
+
print_info(j->tls_session, NULL);
}
j->handshake_ok = 1;
#include <gnutls/extra.h>
#include <gnutls/x509.h>
#include <tests.h>
-#include <unistd.h>
-#include <signal.h>
+
+#ifndef _WIN32
+# include <unistd.h>
+# include <signal.h>
+#endif
+
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <common.h>
int ret;
char data[20];
int old;
+
+#ifndef _WIN32
signal( SIGALRM, got_alarm);
+#endif
ADD_ALL_CIPHERS(session);
ADD_ALL_COMP(session);
ret = gnutls_bye( session, GNUTLS_SHUT_WR);
if (ret<0) return FAILED;
+#ifndef _WIN32
old = siginterrupt( SIGALRM, 1);
alarm(6);
+#endif
do {
ret = gnutls_record_recv( session, data, sizeof(data));
} while( ret > 0);
+#ifndef _WIN32
siginterrupt( SIGALRM, old);
+#endif
if (ret==0) return SUCCEED;
if (alrm == 0) return UNSURE;
-#include <stdio.h>
-
#define SUCCEED 1
#define FAILED 0
#define UNSURE -1
{
int tmp;
char a;
- if(sscanf(arg, "%d%c", &tmp, &a) != 1)
+ if(sscanf(arg, "%d%c", &tmp, &a) < 1)
{
printf("Option %s: '%s' isn't an integer\n", gaa_current_option, arg);
GAAERROR(-1);
{
float tmp;
char a;
- if(sscanf(arg, "%f%c", &tmp, &a) != 1)
+ if(sscanf(arg, "%f%c", &tmp, &a) < 1)
{
printf("Option %s: '%s' isn't a float number\n", gaa_current_option, arg);
GAAERROR(-1);
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+
+#ifdef _WIN32
+# include <winsock.h>
+# include <io.h>
+# include <winbase.h>
+# define socklen_t int
+# define close closesocket
+#else
+# include <sys/socket.h>
+# include <netinet/in.h>
+# include <arpa/inet.h>
+# include <unistd.h>
+# include <signal.h>
+# include <netdb.h>
+#endif
+
#include <string.h>
-#include <unistd.h>
#include <gnutls/gnutls.h>
#include <gnutls/extra.h>
#include <sys/time.h>
-#include <signal.h>
-#include <netdb.h>
#include <tests.h>
#include <tls_test-gaa.h>
};
static int tt = 0;
+char* ip;
+
+#ifdef HAVE_INET_NTOP
+# define IP inet_ntop(AF_INET, &sa.sin_addr, buffer, MAX_BUF)
+#else
+# define IP inet_ntoa( ((struct sockaddr_in*)&sa)->sin_addr)
+#endif
#define CONNECT() \
sd = socket(AF_INET, SOCK_STREAM, 0); \
sa.sin_family = AF_INET; \
sa.sin_port = htons(port); \
sa.sin_addr.s_addr = *((unsigned int *) server_host->h_addr); \
- inet_ntop(AF_INET, &sa.sin_addr, buffer, MAX_BUF); \
- if (tt++ == 0) printf("Connecting to '%s:%d'...\n", buffer, port); \
+ ip = IP; \
+ if (tt++ == 0) printf("Connecting to '%s:%d'...\n", ip, port); \
err = connect(sd, (SA *) & sa, sizeof(sa)); \
ERR(err, "connect")
struct hostent *server_host;
int ssl3_ok = 0;
int tls1_ok = 0;
+#ifdef _WIN32
+ WORD wVersionRequested;
+ WSADATA wsaData;
+#endif
gaa_parser(argc, argv);
+#ifndef _WIN32
signal(SIGPIPE, SIG_IGN);
+#else
+ wVersionRequested = MAKEWORD(1, 1);
+ if (WSAStartup(wVersionRequested, &wsaData) != 0) {
+ perror("WSA_STARTUP_ERROR");
+ }
+#endif
if (gnutls_global_init() < 0) {
fprintf(stderr, "global state initialization error\n");