Permalink
Browse files

Another major re-write of the fwknop library.

git-svn-id: file:///home/mbr/svn/fwknop/trunk@13 510a4753-2344-4c79-9c09-4d669213fbeb
  • Loading branch information...
1 parent deb85dd commit a82c361e28fc513dae3d46da16d57906e636cda2 Damien Stuart committed Dec 24, 2008
View
@@ -1 +1 @@
-SUBDIRS = lib client server
+SUBDIRS = lib src
View
@@ -6,6 +6,7 @@
#
aclocal
libtoolize --automake
+autoheader
automake -a
autoconf
View
@@ -1,161 +0,0 @@
-/* $Id$
- *****************************************************************************
- *
- * File: fwknop.c
- *
- * Author: Damien S. Stuart
- *
- * Purpose: fwknop client program (or will be evenually :).
- *
- * Copyright (C) 2008 Damien Stuart (dstuart@dstuart.org)
- *
- * License (GNU Public License):
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- *
- *****************************************************************************
-*/
-#include "fwknop.h"
-
-/* Local prototypes
-*/
-void init_spa_message(spa_message_t *sm);
-void dump_spa_message_data(spa_message_t *sm);
-
-int main(int argc, char **argv)
-{
- spa_message_t sm;
- int enc_size;
- char spa_pkt_raw[1024] = {0}; // -DSS what is max size?
- uchar spa_pkt_enc[1500] = {0}; // -DSS what is max size?
- char spa_pkt_b64[1500] = {0}; // -DSS what is max size?
-
- char *spb64_p = spa_pkt_b64;
-
- char *test_pw = "BubbaWasHere";
-
- /* Initialize - this sets random, user, and other defaults.
- */
- init_spa_message(&sm);
-
- /* Timestamp
- */
- spa_timestamp(&sm, 0);
-
- /* Construct the spa message based on what we have so far.
- */
- spa_message(&sm);
-
- /* Create the digest for this message.
- */
- spa_digest(&sm);
-
- /* Dump the spa_message struct - temp for testing.
- */
- dump_spa_message_data(&sm);
-
- /* Now take a shot at constructing the packet data.
- * --DSS this is just a slap-together for testing at this point.
- * I do not think we will do it this way in the end. :)
- */
- sprintf(spa_pkt_raw, "%s:%s", sm.message, sm.digest);
-
- /* Encrypt it
- */
- enc_size = fko_encrypt((uchar*)spa_pkt_raw, strlen(spa_pkt_raw), test_pw, spa_pkt_enc);
-
- /* Base64 encode it and strip off trailing '='s
- */
- b64_encode(spa_pkt_enc, spb64_p, enc_size);
- strip_b64_eq(spb64_p);
-
- /* Remove the preceeding encoded "Salted__" string (if it is there).
- */
- if(strncmp(spb64_p, "U2FsdGVkX1", 10) == 0)
- spb64_p += 10;
-
- printf("Hexdump of encrypted data: (%i bytes)\n", enc_size);
- hex_dump(spa_pkt_enc, enc_size);
-
- printf("Base64 version:\n\n%s\n\n", spb64_p);
-
- return(0);
-}
-
-/* Initialize the spa_message data struct, and set some default/preliminary
- * values.
-*/
-void init_spa_message(spa_message_t *sm)
-{
- /* Zero our SPA message struct.
- */
- memset(sm, 0x0, sizeof(spa_message_t));
-
- /* Initialize default values.
- */
- sm->digest_type = DEFAULT_DIGEST;
- sm->enc_pcap_port = DEFAULT_PORT;
- sm->message_type = DEFAULT_MSG_TYPE;
- sm->client_timeout = DEFAULT_CLIENT_TIMEOUT;
-
- strlcpy(sm->access_str, DEFAULT_ACCESS_STR, MAX_ACCESS_STR_SIZE);
- strlcpy(sm->allow_ip, DEFAULT_ALLOW_IP, MAX_IP_ADDR_SIZE);
-
- /* Go ahead and and setup the random and user fields.
- */
- spa_random_number(sm);
- spa_user(sm, NULL);
-
- /* Version is static, so we add it here as well.
- */
- spa_version(sm);
-}
-
-/* Pretty print the data in the spa_message data struct.
-*/
-void dump_spa_message_data(spa_message_t *sm)
-{
- printf(
- "\nCurrent SPA Message Data:\n\n"
- " Random Val: '%s'\n"
- " User: '%s'\n"
- " Timestamp: '%u'\n"
- " Version: '%s'\n"
- " Message Type: '%u'\n"
- " Access: '%s'\n"
- " Allow IP: '%s'\n"
- " Nat Access: '%s'\n"
- " Server Auth: '%s'\n"
- " Client Timeout: '%u'\n"
- " Message: '%s'\n"
- " Digest: '%s'\n"
- "\n"
- " Digest Type: '%u'\n"
- " Port: '%u'\n"
- "\n",
- sm->rand_val,
- sm->user,
- sm->timestamp,
- sm->version,
- sm->message_type,
- sm->access_str,
- sm->allow_ip,
- sm->nat_access,
- sm->server_auth,
- sm->client_timeout,
- sm->message,
- sm->digest,
- sm->digest_type,
- sm->enc_pcap_port
- );
-}
-
-/***EOF***/
View
@@ -3,35 +3,53 @@ dnl Process thie file with autoconf to produce teh configure script
AC_PREREQ(2.53)
m4_define(my_package, [fwknop])
-m4_define(my_version, [2.0.0])
+m4_define(my_version, [2.0.0-alpha])
+m4_define(my_bug_email, [dstuart@dstuart.org])
-AC_INIT(my_package, my_version)
+AC_INIT(my_package, my_version, my_bug_email)
AM_INIT_AUTOMAKE(my_package, my_version)
+dnl AM_MAINTAINER_MODE
+
+AC_CONFIG_HEADER([config.h])
+
AC_GNU_SOURCE
+
AC_PROG_CC
AM_PROG_CC_C_O
+AC_PROG_CXX
AC_PROG_RANLIB
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+
+# Checks for header files.
+#
+AC_HEADER_STDC
+AC_CHECK_HEADERS([locale.h stdlib.h string.h sys/time.h unistd.h])
# Type checks.
+#
AC_C_INLINE
AC_CHECK_SIZEOF(unsigned int)
AC_TYPE_OFF_T
-
-# Network library fun.
-AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname,
- [NETLIBS="-lnsl $NETLIBS"]))
-AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt,
- [NETLIBS="-lsocket $NETLIBS"]))
-AC_SUBST(NETLIBS)
-
-dnl # Checking for libgpg-error.
-dnl AM_PATH_GPG_ERROR(1.4,, AC_MSG_ERROR([libgpg-error was not found]))
-dnl AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
-dnl [The default error source for GPGME.])
-
-dnl # GPGME
-dnl AM_PATH_GPGME
-
-
-AC_OUTPUT(lib/Makefile client/Makefile server/Makefile Makefile)
+AC_TYPE_SIZE_T
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_INT8_T
+AC_TYPE_SIZE_T
+AC_HEADER_TIME
+AC_TYPE_UINT32_T
+AC_TYPE_UINT8_T
+AC_C_CONST
+
+# Checks for library functions.
+#
+AC_CHECK_FUNCS([gettimeofday memmove memset setlocale strchr])
+
+
+# Generate the Makefiles
+#
+AC_OUTPUT(lib/Makefile src/Makefile Makefile)
View
@@ -1,26 +1,12 @@
lib_LIBRARIES = libfko.a
-libfko_a_SOURCES = base64.c \
- md5.c \
- spa_message.c \
- spa_version.c \
- cipher_funcs.c \
- rijndael.c \
- spa_message_type.c \
- strlcat.c \
- digest.c \
- sha1.c \
- spa_random_number.c \
- strlcpy.c \
- sha256.c \
- spa_timestamp.c \
- spa_digest.c \
- spa_user.c \
- base64.h \
- cipher_funcs.h \
- digest.h \
- fwknop.h \
- md5.h \
- rijndael.h \
- sha.h \
- types.h
+libfko_source_files = \
+ base64.c base64.h cipher_funcs.c cipher_funcs.h digest.c digest.h \
+ fko_client_timeout.c fko_common.h fko_digest.c fko_encode.c \
+ fko_encryption.c fko_error.c fko_funcs.c fko.h fko_message.c \
+ fko_nat_access.c fko_rand_value.c fko_server_auth.c \
+ fko_timestamp.c fko_types.h fko_user.c fko_util.c fko_util.h \
+ md5.c md5.h rijndael.c rijndael.h sha1.c sha256.c sha.h strlcat.c \
+ strlcpy.c
+
+libfko_a_SOURCES = $(libfko_source_files)
View
@@ -22,10 +22,9 @@
*
*****************************************************************************
*/
-#include "types.h"
#include "base64.h"
-static unsigned char map2[] =
+static uchar map2[] =
{
0x3e, 0xff, 0xff, 0xff, 0x3f, 0x34, 0x35, 0x36,
0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0xff,
@@ -53,13 +52,10 @@ int b64_decode(char *in, uchar *out, int out_len)
v = (v << 6) + map2[index];
- if (i & 3) {
- //--DSS temp for test
- //if (dst - out < out_len) {
- *dst++ = v >> (6 - 2 * (i & 3));
- //}
- }
+ if (i & 3)
+ *dst++ = v >> (6 - 2 * (i & 3));
}
+
*dst = '\0';
return(dst - out);
View
@@ -21,19 +21,17 @@
*
*****************************************************************************
*/
-#ifndef _BASE64_H_
-#define _BASE64_H_
+#ifndef BASE64_H
+#define BASE64_H 1
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include "fko_common.h"
/* Prototypes
*/
int b64_encode(uchar *in, char *out, int in_len);
int b64_decode(char *in, uchar *out, int out_len);
void strip_b64_eq(char *data);
-#endif /* _BASE64_H_ */
+#endif /* BASE64_H */
/***EOF***/
Oops, something went wrong.

0 comments on commit a82c361

Please sign in to comment.