blob: 6fc0e1f3e95e3d5705e660366d9bb7e89a45e949 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/*
2 * Self-test demonstration program
3 *
4 * Copyright (C) 2006-2007 Christophe Devine
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#ifndef _CRT_SECURE_NO_DEPRECATE
22#define _CRT_SECURE_NO_DEPRECATE 1
23#endif
24
25#include <string.h>
26#include <stdio.h>
27
28#include "xyssl/config.h"
29
30#include "xyssl/md2.h"
31#include "xyssl/md4.h"
32#include "xyssl/md5.h"
33#include "xyssl/sha1.h"
34#include "xyssl/sha2.h"
35#include "xyssl/sha4.h"
36#include "xyssl/arc4.h"
37#include "xyssl/des.h"
38#include "xyssl/aes.h"
39#include "xyssl/base64.h"
40#include "xyssl/bignum.h"
41#include "xyssl/rsa.h"
42#include "xyssl/x509.h"
43
44int main( int argc, char *argv[] )
45{
46 int ret, v;
47
48 if( argc == 2 && strcmp( argv[1], "-quiet" ) == 0 )
49 v = 0;
50 else
51 {
52 v = 1;
53 printf( "\n" );
54 }
55
56#if defined(XYSSL_MD2_C)
57 if( ( ret = md2_self_test( v ) ) != 0 )
58 return( ret );
59#endif
60
61#if defined(XYSSL_MD4_C)
62 if( ( ret = md4_self_test( v ) ) != 0 )
63 return( ret );
64#endif
65
66#if defined(XYSSL_MD5_C)
67 if( ( ret = md5_self_test( v ) ) != 0 )
68 return( ret );
69#endif
70
71#if defined(XYSSL_SHA1_C)
72 if( ( ret = sha1_self_test( v ) ) != 0 )
73 return( ret );
74#endif
75
76#if defined(XYSSL_SHA2_C)
77 if( ( ret = sha2_self_test( v ) ) != 0 )
78 return( ret );
79#endif
80
81#if defined(XYSSL_SHA4_C)
82 if( ( ret = sha4_self_test( v ) ) != 0 )
83 return( ret );
84#endif
85
86#if defined(XYSSL_ARC4_C)
87 if( ( ret = arc4_self_test( v ) ) != 0 )
88 return( ret );
89#endif
90
91#if defined(XYSSL_DES_C)
92 if( ( ret = des_self_test( v ) ) != 0 )
93 return( ret );
94#endif
95
96#if defined(XYSSL_AES_C)
97 if( ( ret = aes_self_test( v ) ) != 0 )
98 return( ret );
99#endif
100
101#if defined(XYSSL_BASE64_C)
102 if( ( ret = base64_self_test( v ) ) != 0 )
103 return( ret );
104#endif
105
106#if defined(XYSSL_BIGNUM_C)
107 if( ( ret = mpi_self_test( v ) ) != 0 )
108 return( ret );
109#endif
110
111#if defined(XYSSL_RSA_C)
112 if( ( ret = rsa_self_test( v ) ) != 0 )
113 return( ret );
114#endif
115
116#if defined(XYSSL_X509_C)
117 if( ( ret = x509_self_test( v ) ) != 0 )
118 return( ret );
119#endif
120
121 if( v != 0 )
122 {
123 printf( " [ All tests passed ]\n\n" );
124#ifdef WIN32
125 printf( " Press Enter to exit this program.\n" );
126 fflush( stdout ); getchar();
127#endif
128 }
129
130 return( ret );
131}