Commit cce9d777 authored by Paul Bakker's avatar Paul Bakker
Browse files

- Lots of minimal changes to better support WINCE as a build target

parent 33008eef
......@@ -22,6 +22,7 @@ Changes
So now there is a module that is controlled with POLARSSL_ASN1_PARSE_C.
* Changed the defined key-length of DES ciphers in cipher.h to include the
parity bits, to prevent mistakes in copying data. (Closes ticket #33)
* Loads of minimal changes to better support WINCE as a build target
Bugfix
* Fixed faulty HMAC-MD2 implementation. Found by dibac. (Closes
......
......@@ -5,7 +5,7 @@
*
* \author Adriaan de Jong <dejong@fox-it.com>
*
* Copyright (C) 2006-2010, Brainspark B.V.
* Copyright (C) 2006-2011, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......@@ -26,13 +26,12 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef POLARSSL_CIPHER_WRAP_H
#define POLARSSL_CIPHER_WRAP_H
#include "config.h"
#include "cipher.h"
#ifndef POLARSSL_CIPHER_WRAP_H
#define POLARSSL_CIPHER_WRAP_H
#ifdef __cplusplus
extern "C" {
#endif
......
......@@ -31,7 +31,7 @@
#ifndef POLARSSL_CONFIG_H
#define POLARSSL_CONFIG_H
#ifndef _CRT_SECURE_NO_DEPRECATE
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
#define _CRT_SECURE_NO_DEPRECATE 1
#endif
......
......@@ -3,7 +3,7 @@
*
* \brief Debug functions
*
* Copyright (C) 2006-2010, Brainspark B.V.
* Copyright (C) 2006-2011, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......@@ -24,8 +24,8 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef SSL_DEBUG_H
#define SSL_DEBUG_H
#ifndef POLARSSL_DEBUG_H
#define POLARSSL_DEBUG_H
#include "config.h"
#include "ssl.h"
......
......@@ -26,7 +26,6 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef POLARSSL_MD_H
#define POLARSSL_MD_H
......
......@@ -5,7 +5,7 @@
*
* \author Adriaan de Jong <dejong@fox-it.com>
*
* Copyright (C) 2006-2010, Brainspark B.V.
* Copyright (C) 2006-2011, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......@@ -26,13 +26,12 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef POLARSSL_MD_WRAP_H
#define POLARSSL_MD_WRAP_H
#include "config.h"
#include "md.h"
#ifndef POLARSSL_MD_WRAP_H
#define POLARSSL_MD_WRAP_H
#ifdef __cplusplus
extern "C" {
#endif
......
/**
* \file net.h
*
* \brief MD5 message digest algorithm (hash function)
* \brief Network communication functions
*
* Copyright (C) 2006-2010, Brainspark B.V.
* Copyright (C) 2006-2011, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......
......@@ -5,7 +5,7 @@
*
* \author Adriaan de Jong <dejong@fox-it.com>
*
* Copyright (C) 2006-2010, Brainspark B.V.
* Copyright (C) 2006-2011, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......@@ -26,9 +26,8 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef PKCS11_H_
#define PKCS11_H_
#ifndef POLARSSL_PKCS11_H
#define POLARSSL_PKCS11_H
#include "config.h"
......@@ -124,4 +123,4 @@ int pkcs11_sign( pkcs11_context *ctx,
#endif /* POLARSSL_PKCS11_C */
#endif /* PKCS11_H_ */
#endif /* POLARSSL_PKCS11_H */
......@@ -52,7 +52,11 @@
#include <string.h>
#include <stdlib.h>
#if defined(_WIN32_WCE)
#include <windows.h>
#else
#include <time.h>
#endif
#if defined(POLARSSL_FS_IO)
#include <stdio.h>
......@@ -2609,43 +2613,66 @@ int x509parse_crl_info( char *buf, size_t size, const char *prefix,
*/
int x509parse_time_expired( const x509_time *to )
{
int year, mon, day;
int hour, min, sec;
#if defined(_WIN32)
SYSTEMTIME st;
GetLocalTime(&st);
year = st.wYear;
mon = st.wMonth;
day = st.wDay;
hour = st.wHour;
min = st.wMinute;
sec = st.wSecond;
#else
struct tm *lt;
time_t tt;
tt = time( NULL );
lt = localtime( &tt );
if( lt->tm_year > to->year - 1900 )
year = lt->tm_year + 1900;
mon = lt->tm_mon + 1;
day = lt->tm_mday;
hour = lt->tm_hour;
min = lt->tm_min;
sec = lt->tm_sec;
#endif
if( year > to->year )
return( 1 );
if( lt->tm_year == to->year - 1900 &&
lt->tm_mon > to->mon - 1 )
if( year == to->year &&
mon > to->mon )
return( 1 );
if( lt->tm_year == to->year - 1900 &&
lt->tm_mon == to->mon - 1 &&
lt->tm_mday > to->day )
if( year == to->year &&
mon == to->mon &&
day > to->day )
return( 1 );
if( lt->tm_year == to->year - 1900 &&
lt->tm_mon == to->mon - 1 &&
lt->tm_mday == to->day &&
lt->tm_hour > to->hour - 1)
if( year == to->year &&
mon == to->mon &&
day == to->day &&
hour > to->hour )
return( 1 );
if( lt->tm_year == to->year - 1900 &&
lt->tm_mon == to->mon - 1 &&
lt->tm_mday == to->day &&
lt->tm_hour == to->hour - 1 &&
lt->tm_min > to->min - 1 )
if( year == to->year &&
mon == to->mon &&
day == to->day &&
hour == to->hour &&
min > to->min )
return( 1 );
if( lt->tm_year == to->year - 1900 &&
lt->tm_mon == to->mon - 1 &&
lt->tm_mday == to->day &&
lt->tm_hour == to->hour - 1 &&
lt->tm_min == to->min - 1 &&
lt->tm_sec > to->sec - 1 )
if( year == to->year &&
mon == to->mon &&
day == to->day &&
hour == to->hour &&
min == to->min &&
sec > to->sec )
return( 1 );
return( 0 );
......
/*
* AES-256 file encryption program
*
* Copyright (C) 2006-2010, Brainspark B.V.
* Copyright (C) 2006-2011, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......@@ -29,7 +29,9 @@
#if defined(_WIN32)
#include <windows.h>
#if !defined(_WIN32_WCE)
#include <io.h>
#endif
#else
#include <sys/types.h>
#include <unistd.h>
......@@ -55,8 +57,10 @@
"\n"
#if !defined(POLARSSL_AES_C) || !defined(POLARSSL_SHA2_C)
int main( void )
int main( int argc, char *argv[] )
{
((void) argc);
((void) argv);
printf("POLARSSL_AES_C and/or POLARSSL_SHA2_C not defined.\n");
return( 0 );
}
......@@ -79,7 +83,9 @@ int main( int argc, char *argv[] )
aes_context aes_ctx;
sha2_context sha_ctx;
#if defined(WIN32)
#if defined(_WIN32_WCE)
long filesize, offset;
#elif defined(_WIN32)
LARGE_INTEGER li_size;
__int64 filesize, offset;
#else
......@@ -93,7 +99,7 @@ int main( int argc, char *argv[] )
{
printf( USAGE );
#if defined(WIN32)
#if defined(_WIN32)
printf( "\n Press Enter to exit this program.\n" );
fflush( stdout ); getchar();
#endif
......@@ -162,7 +168,10 @@ int main( int argc, char *argv[] )
memset( argv[4], 0, strlen( argv[4] ) );
#if defined(WIN32)
#if defined(_WIN32_WCE)
filesize = fseek( fin, 0L, SEEK_END );
#else
#if defined(_WIN32)
/*
* Support large files (> 2Gb) on Win32
*/
......@@ -184,6 +193,7 @@ int main( int argc, char *argv[] )
perror( "lseek" );
goto exit;
}
#endif
#endif
if( fseek( fin, 0, SEEK_SET ) < 0 )
......
......@@ -2,7 +2,7 @@
* \brief Generic file encryption program using generic wrappers for configured
* security.
*
* Copyright (C) 2006-2010, Brainspark B.V.
* Copyright (C) 2006-2011, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......@@ -30,7 +30,9 @@
#if defined(_WIN32)
#include <windows.h>
#if !defined(_WIN32_WCE)
#include <io.h>
#endif
#else
#include <sys/types.h>
#include <unistd.h>
......@@ -56,8 +58,11 @@
"\n"
#if !defined(POLARSSL_CIPHER_C) || !defined(POLARSSL_MD_C)
int main( void )
int main( int argc, char *argv[] )
{
((void) argc);
((void) argv);
printf("POLARSSL_CIPHER_C and/or POLARSSL_MD_C not defined.\n");
return( 0 );
}
......@@ -80,7 +85,9 @@ int main( int argc, char *argv[] )
const md_info_t *md_info;
cipher_context_t cipher_ctx;
md_context_t md_ctx;
#if defined(WIN32)
#if defined(_WIN32_WCE)
long filesize, offset;
#elif defined(_WIN32)
LARGE_INTEGER li_size;
__int64 filesize, offset;
#else
......@@ -117,7 +124,7 @@ int main( int argc, char *argv[] )
list++;
}
#if defined(WIN32)
#if defined(_WIN32)
printf( "\n Press Enter to exit this program.\n" );
fflush( stdout ); getchar();
#endif
......@@ -205,7 +212,10 @@ int main( int argc, char *argv[] )
memset( argv[6], 0, strlen( argv[6] ) );
#if defined(WIN32)
#if defined(_WIN32_WCE)
filesize = fseek( fin, 0L, SEEK_END );
#else
#if defined(_WIN32)
/*
* Support large files (> 2Gb) on Win32
*/
......@@ -227,6 +237,7 @@ int main( int argc, char *argv[] )
perror( "lseek" );
goto exit;
}
#endif
#endif
if( fseek( fin, 0, SEEK_SET ) < 0 )
......
/*
* generic message digest layer demonstration program
*
* Copyright (C) 2006-2010, Brainspark B.V.
* Copyright (C) 2006-2011, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......@@ -35,8 +35,11 @@
#include "polarssl/md.h"
#if !defined(POLARSSL_MD_C)
int main( void )
int main( int argc, char *argv[] )
{
((void) argc);
((void) argv);
printf("POLARSSL_MD_C not defined.\n");
return( 0 );
}
......@@ -172,7 +175,7 @@ int main( int argc, char *argv[] )
list++;
}
#ifdef WIN32
#if defined(_WIN32)
printf( "\n Press Enter to exit this program.\n" );
fflush( stdout ); getchar();
#endif
......
/*
* Classic "Hello, world" demonstration program
*
* Copyright (C) 2006-2010, Brainspark B.V.
* Copyright (C) 2006-2011, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......@@ -34,18 +34,24 @@
#include "polarssl/md5.h"
#if !defined(POLARSSL_MD5_C)
int main( void )
int main( int argc, char *argv[] )
{
((void) argc);
((void) argv);
printf("POLARSSL_MD5_C not defined.\n");
return( 0 );
}
#else
int main( void )
int main( int argc, char *argv[] )
{
int i;
unsigned char digest[16];
char str[] = "Hello, world!";
((void) argc);
((void) argv);
printf( "\n MD5('%s') = ", str );
md5( (unsigned char *) str, 13, digest );
......@@ -55,7 +61,7 @@ int main( void )
printf( "\n\n" );
#ifdef WIN32
#if defined(_WIN32)
printf( " Press Enter to exit this program.\n" );
fflush( stdout ); getchar();
#endif
......
/*
* md5sum demonstration program
*
* Copyright (C) 2006-2010, Brainspark B.V.
* Copyright (C) 2006-2011, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......@@ -35,8 +35,11 @@
#include "polarssl/md5.h"
#if !defined(POLARSSL_MD5_C) || !defined(POLARSSL_FS_IO)
int main( void )
int main( int argc, char *argv[] )
{
((void) argc);
((void) argv);
printf("POLARSSL_MD5_C and/or POLARSSL_FS_IO not defined.\n");
return( 0 );
}
......@@ -151,7 +154,7 @@ int main( int argc, char *argv[] )
printf( "print mode: md5sum <file> <file> ...\n" );
printf( "check mode: md5sum -c <checksum file>\n" );
#ifdef WIN32
#if defined(_WIN32)
printf( "\n Press Enter to exit this program.\n" );
fflush( stdout ); getchar();
#endif
......
/*
* sha1sum demonstration program
*
* Copyright (C) 2006-2010, Brainspark B.V.
* Copyright (C) 2006-2011, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......@@ -35,8 +35,11 @@
#include "polarssl/sha1.h"
#if !defined(POLARSSL_SHA1_C) || !defined(POLARSSL_FS_IO)
int main( void )
int main( int argc, char *argv[] )
{
((void) argc);
((void) argv);
printf("POLARSSL_SHA1_C and/or POLARSSL_FS_IO not defined.\n");
return( 0 );
}
......@@ -151,7 +154,7 @@ int main( int argc, char *argv[] )
printf( "print mode: sha1sum <file> <file> ...\n" );
printf( "check mode: sha1sum -c <checksum file>\n" );
#ifdef WIN32
#if defined(_WIN32)
printf( "\n Press Enter to exit this program.\n" );
fflush( stdout ); getchar();
#endif
......
/*
* sha2sum demonstration program
*
* Copyright (C) 2006-2010, Brainspark B.V.
* Copyright (C) 2006-2011, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......@@ -35,8 +35,11 @@
#include "polarssl/sha2.h"
#if !defined(POLARSSL_SHA2_C) || !defined(POLARSSL_FS_IO)
int main( void )
int main( int argc, char *argv[] )
{
((void) argc);
((void) argv);
printf("POLARSSL_SHA2_C and/or POLARSSL_FS_IO not defined.\n");
return( 0 );
}
......@@ -151,7 +154,7 @@ int main( int argc, char *argv[] )
printf( "print mode: sha2sum <file> <file> ...\n" );
printf( "check mode: sha2sum -c <checksum file>\n" );
#ifdef WIN32
#if defined(_WIN32)
printf( "\n Press Enter to exit this program.\n" );
fflush( stdout ); getchar();
#endif
......
/*
* Diffie-Hellman-Merkle key exchange (client side)
*
* Copyright (C) 2006-2010, Brainspark B.V.
* Copyright (C) 2006-2011, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......@@ -46,15 +46,18 @@
!defined(POLARSSL_HAVEGE_C) || !defined(POLARSSL_NET_C) || \
!defined(POLARSSL_RSA_C) || !defined(POLARSSL_SHA1_C) || \
!defined(POLARSSL_FS_IO)
int main( void )
int main( int argc, char *argv[] )
{
((void) argc);
((void) argv);
printf("POLARSSL_AES_C and/or POLARSSL_DHM_C and/or POLARSSL_HAVEGE_C "
"and/or POLARSSL_NET_C and/or POLARSSL_RSA_C and/or "
"POLARSSL_SHA1_C and/or POLARSSL_FS_IO not defined.\n");
return( 0 );
}
#else
int main( void )
int main( int argc, char *argv[] )
{
FILE *f;
......@@ -71,6 +74,9 @@ int main( void )
dhm_context dhm;
aes_context aes;
((void) argc);
((void) argv);
memset( &rsa, 0, sizeof( rsa ) );
memset( &dhm, 0, sizeof( dhm ) );
......@@ -260,7 +266,7 @@ exit:
rsa_free( &rsa );
dhm_free( &dhm );
#ifdef WIN32
#if defined(_WIN32)
printf( " + Press Enter to exit this program.\n" );
fflush( stdout ); getchar();
#endif
......
/*
* Diffie-Hellman-Merkle key exchange (prime generation)
*
* Copyright (C) 2006-2010, Brainspark B.V.
* Copyright (C) 2006-2011, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......@@ -43,14 +43,17 @@
#if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_HAVEGE_C) || \
!defined(POLARSSL_FS_IO)
int main( void )
int main( int argc, char *argv[] )
{
((void) argc);
((void) argv);
printf("POLARSSL_BIGNUM_C and/or POLARSSL_HAVEGE_C and/or "
"POLARSSL_FS_IO not defined.\n");
return( 0 );
}
#else
int main( void )
int main( int argc, char *argv[] )
{
int ret = 1;
......@@ -59,6 +62,9 @@ int main( void )
havege_state hs;
FILE *fout;
((void) argc);
((void) argv);