Permalink
Browse files

Updated autoconf files and code to support Solaris (ver 10 x86 at lea…

…st). This includes better type checking and resolving some conflicting names under Solaris.

git-svn-id: file:///home/mbr/svn/fwknop/trunk@73 510a4753-2344-4c79-9c09-4d669213fbeb
  • Loading branch information...
1 parent e1b5b7e commit 7f0e7a9a350e6a3da83b2953d6ccff27e342603e Damien Stuart committed Mar 15, 2009
Showing with 198 additions and 223 deletions.
  1. +7 −8 configure.ac
  2. +1 −1 fko/Makefile.am
  3. +4 −4 fko/base64.c
  4. +2 −2 fko/base64.h
  5. +19 −19 fko/digest.c
  6. +9 −9 fko/digest.h
  7. +5 −2 fko/fko_common.h
  8. +3 −3 fko/fko_digest.c
  9. +0 −44 fko/fko_types.h
  10. +15 −14 fko/md5.c
  11. +3 −3 fko/md5.h
  12. +37 −37 fko/rijndael.c
  13. +21 −18 fko/rijndael.h
  14. +8 −8 fko/sha.h
  15. +32 −26 fko/sha1.c
  16. +27 −20 fko/sha256.c
  17. +5 −5 src/fwknop.c
View
@@ -31,22 +31,18 @@ AC_PROG_LIBTOOL
# Checks for header files.
#
AC_HEADER_STDC
-AC_CHECK_HEADERS([ctype.h endian.h netinet/in.h stdlib.h string.h strings.h sys/endian.h sys/socket.h sys/time.h termios.h unistd.h])
+AC_CHECK_HEADERS([ctype.h endian.h netinet/in.h stdint.h stdlib.h string.h strings.h sys/endian.h sys/socket.h sys/time.h termios.h unistd.h])
# Type checks.
#
AC_C_CONST
AC_TYPE_OFF_T
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_CHECK_SIZEOF(unsigned int)
+AC_CHECK_TYPES([uint8_t, uint32_t])
+
+AC_C_BIGENDIAN
# Checks for library functions.
#
@@ -55,6 +51,9 @@ AC_FUNC_REALLOC
AC_FUNC_STAT
AC_CHECK_FUNCS([bzero gettimeofday memmove memset socket strchr strcspn strdup strncasecmp strndup strrchr strspn])
+AC_SEARCH_LIBS([socket], [socket])
+AC_SEARCH_LIBS([inet_addr], [nsl])
+
dnl For finding and checking gpgme (taken from the gpgme.m4 file that
dnl comes with gpgme)
dnl
View
@@ -5,7 +5,7 @@ libfko_source_files = \
fko_client_timeout.c fko_common.h fko_digest.c fko_encode.c \
fko_decode.c fko_encryption.c fko_error.c fko_funcs.c fko_message.c \
fko_nat_access.c fko_rand_value.c fko_server_auth.c fko.h fko_limits.h \
- fko_timestamp.c fko_types.h fko_user.c fko_util.h md5.c md5.h \
+ fko_timestamp.c fko_user.c fko_util.h md5.c md5.h \
rijndael.c rijndael.h sha1.c sha256.c sha.h strlcat.c \
strlcpy.c fko_state.h fko_context.h gpgme_funcs.c gpgme_funcs.h
View
@@ -24,7 +24,7 @@
*/
#include "base64.h"
-static uchar map2[] =
+static unsigned char map2[] =
{
0x3e, 0xff, 0xff, 0xff, 0x3f, 0x34, 0x35, 0x36,
0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0xff,
@@ -39,10 +39,10 @@ static uchar map2[] =
};
int
-b64_decode(char *in, uchar *out, int out_len)
+b64_decode(char *in, unsigned char *out, int out_len)
{
int i, v;
- uchar *dst = out;
+ unsigned char *dst = out;
v = 0;
for (i = 0; in[i] && in[i] != '='; i++) {
@@ -69,7 +69,7 @@ b64_decode(char *in, uchar *out, int out_len)
*****************************************************************************
*/
int
-b64_encode(uchar *in, char *out, int in_len)
+b64_encode(unsigned char *in, char *out, int in_len)
{
static const char b64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
View
@@ -28,8 +28,8 @@
/* Prototypes
*/
-int b64_encode(uchar *in, char *out, int in_len);
-int b64_decode(char *in, uchar *out, int out_len);
+int b64_encode(unsigned char *in, char *out, int in_len);
+int b64_decode(char *in, unsigned char *out, int out_len);
void strip_b64_eq(char *data);
#endif /* BASE64_H */
View
@@ -27,7 +27,7 @@
/* Convert a raw digest into its hex string representation.
*/
void
-digest_to_hex(char *out, uchar *in, int size)
+digest_to_hex(char *out, unsigned char *in, int size)
{
int i;
for(i=0; i<size; i++)
@@ -40,21 +40,21 @@ digest_to_hex(char *out, uchar *in, int size)
/* Compute MD5 hash on in and store result in out.
*/
void
-md5(uchar *out, uchar *in, int size)
+md5(unsigned char *out, unsigned char *in, int size)
{
MD5Context ctx;
MD5Init(&ctx);
- MD5Update(&ctx, (uchar*)in, size);
+ MD5Update(&ctx, (unsigned char*)in, size);
MD5Final(out, &ctx);
}
/* Compute MD5 hash on in and store the hex string result in out.
*/
void
-md5_hex(char *out, uchar *in, int size)
+md5_hex(char *out, unsigned char *in, int size)
{
- uint8 md[MD5_DIGESTSIZE];
+ uint8_t md[MD5_DIGESTSIZE];
md5(md, in, size);
digest_to_hex(out, md, MD5_DIGESTSIZE);
@@ -63,9 +63,9 @@ md5_hex(char *out, uchar *in, int size)
/* Compute MD5 hash on in and store the base64 string result in out.
*/
void
-md5_base64(char *out, uchar *in, int size)
+md5_base64(char *out, unsigned char *in, int size)
{
- uint8 md[MD5_DIGESTSIZE];
+ uint8_t md[MD5_DIGESTSIZE];
md5(md, in, size);
b64_encode(md, out, MD5_DIGESTSIZE);
@@ -76,21 +76,21 @@ md5_base64(char *out, uchar *in, int size)
/* Compute SHA1 hash on in and store result in out.
*/
void
-sha1(uchar *out, uchar *in, int size)
+sha1(unsigned char *out, unsigned char *in, int size)
{
SHA_INFO sha_info;
sha1_init(&sha_info);
- sha1_update(&sha_info, (uint8*)in, size);
+ sha1_update(&sha_info, (uint8_t*)in, size);
sha1_final(out, &sha_info);
}
/* Compute SHA1 hash on in and store the hex string result in out.
*/
void
-sha1_hex(char *out, uchar *in, int size)
+sha1_hex(char *out, unsigned char *in, int size)
{
- uint8 md[SHA1_DIGESTSIZE];
+ uint8_t md[SHA1_DIGESTSIZE];
sha1(md, in, size);
digest_to_hex(out, md, SHA1_DIGESTSIZE);
@@ -99,9 +99,9 @@ sha1_hex(char *out, uchar *in, int size)
/* Compute SHA1 hash on in and store the base64 string result in out.
*/
void
-sha1_base64(char *out, uchar *in, int size)
+sha1_base64(char *out, unsigned char *in, int size)
{
- uint8 md[SHA1_DIGESTSIZE];
+ uint8_t md[SHA1_DIGESTSIZE];
sha1(md, in, size);
b64_encode(md, out, SHA1_DIGESTSIZE);
@@ -112,22 +112,22 @@ sha1_base64(char *out, uchar *in, int size)
/* Compute SHA256 hash on in and store the hex string result in out.
*/
void
-sha256(uchar *out, uchar *in, int size)
+sha256(unsigned char *out, unsigned char *in, int size)
{
SHA_INFO sha_info;
sha256_init(&sha_info);
- sha256_update(&sha_info, (uint8*)in, size);
+ sha256_update(&sha_info, (uint8_t*)in, size);
sha256_final(&sha_info);
sha256_unpackdigest(out, &sha_info);
}
/* Compute SHA256 hash on in and store the hex string result in out.
*/
void
-sha256_hex(char *out, uchar *in, int size)
+sha256_hex(char *out, unsigned char *in, int size)
{
- uint8 md[SHA256_DIGESTSIZE];
+ uint8_t md[SHA256_DIGESTSIZE];
sha256(md, in, size);
digest_to_hex(out, md, SHA256_DIGESTSIZE);
@@ -136,9 +136,9 @@ sha256_hex(char *out, uchar *in, int size)
/* Compute SHA256 hash on in and store the base64 string result in out.
*/
void
-sha256_base64(char *out, uchar *in, int size)
+sha256_base64(char *out, unsigned char *in, int size)
{
- uint8 md[SHA256_DIGESTSIZE];
+ uint8_t md[SHA256_DIGESTSIZE];
sha256(md, in, size);
b64_encode(md, out, SHA256_DIGESTSIZE);
View
@@ -34,15 +34,15 @@
#define MD_HEX_SIZE(x) x * 2
#define MD_B64_SIZE(x) ((x * 4) / 3) + 1
-void md5(uchar* out, uchar* in, int size);
-void md5_hex(char* out, uchar* in, int size);
-void md5_base64(char* out, uchar* in, int size);
-void sha1(uchar* out, uchar* in, int size);
-void sha1_hex(char* out, uchar* in, int size);
-void sha1_base64(char* out, uchar* in, int size);
-void sha256(uchar* out, uchar* in, int size);
-void sha256_hex(char* out, uchar* in, int size);
-void sha256_base64(char* out, uchar* in, int size);
+void md5(unsigned char* out, unsigned char* in, int size);
+void md5_hex(char* out, unsigned char* in, int size);
+void md5_base64(char* out, unsigned char* in, int size);
+void sha1(unsigned char* out, unsigned char* in, int size);
+void sha1_hex(char* out, unsigned char* in, int size);
+void sha1_base64(char* out, unsigned char* in, int size);
+void sha256(unsigned char* out, unsigned char* in, int size);
+void sha256_hex(char* out, unsigned char* in, int size);
+void sha256_base64(char* out, unsigned char* in, int size);
#endif /* DIGEST_H */
View
@@ -45,12 +45,16 @@
#endif
#if HAVE_CTYPE_H
- #include <ctype.h> /* Using this if isdigit() */
+ #include <ctype.h> /* Using this for isdigit() */
#else
/* Fall-back does not account for locale */
#define isdigit(c) (c >= 48 && c <= 57)
#endif
+#if HAVE_STDINT_H
+ #include <stdint.h>
+#endif
+
/* Work out endianess (sp?)
*/
#if HAVE_ENDIAN_H /* Should cover most Linux systems */
@@ -77,7 +81,6 @@
#include <gpgme.h>
#endif
-#include "fko_types.h"
#include "fko_util.h"
#include "fko_limits.h"
#include "fko_state.h"
View
@@ -85,7 +85,7 @@ fko_set_spa_digest(fko_ctx_t ctx)
return(FKO_ERROR_MEMORY_ALLOCATION);
md5_base64(md,
- (uchar*)ctx->encoded_msg, strlen(ctx->encoded_msg));
+ (unsigned char*)ctx->encoded_msg, strlen(ctx->encoded_msg));
break;
case FKO_DIGEST_SHA1:
@@ -94,7 +94,7 @@ fko_set_spa_digest(fko_ctx_t ctx)
return(FKO_ERROR_MEMORY_ALLOCATION);
sha1_base64(md,
- (uchar*)ctx->encoded_msg, strlen(ctx->encoded_msg));
+ (unsigned char*)ctx->encoded_msg, strlen(ctx->encoded_msg));
break;
case FKO_DIGEST_SHA256:
@@ -103,7 +103,7 @@ fko_set_spa_digest(fko_ctx_t ctx)
return(FKO_ERROR_MEMORY_ALLOCATION);
sha256_base64(md,
- (uchar*)ctx->encoded_msg, strlen(ctx->encoded_msg));
+ (unsigned char*)ctx->encoded_msg, strlen(ctx->encoded_msg));
break;
default:
View
@@ -1,44 +0,0 @@
-/* $Id$
- *****************************************************************************
- *
- * File: fko_types.h
- *
- * Purpose: Typedefs for fwknop.
- *
- * 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
- *
- *****************************************************************************
-*/
-#ifndef FKO_TYPES_H
-#define FKO_TYPES_H 1
-
-#include <sys/types.h>
-
-typedef u_int8_t uint8;
-typedef u_int16_t uint16;
-typedef u_int32_t uint32;
-typedef u_int64_t uint64;
-
-typedef int8_t int8;
-typedef int16_t int16;
-typedef int32_t int32;
-typedef int64_t int64;
-
-typedef unsigned char uchar;
-typedef unsigned short ushort;
-
-#endif /* FKO_TYPES_H */
-
-/***EOF***/
Oops, something went wrong.

0 comments on commit 7f0e7a9

Please sign in to comment.