00001 /* 00002 * Self-test demonstration program 00003 * 00004 * Copyright (C) 2006-2007 Christophe Devine 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program; if not, write to the Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00019 */ 00020 00021 #ifndef _CRT_SECURE_NO_DEPRECATE 00022 #define _CRT_SECURE_NO_DEPRECATE 1 00023 #endif 00024 00025 #include <string.h> 00026 #include <stdio.h> 00027 00028 #include "xyssl/config.h" 00029 00030 #include "xyssl/md2.h" 00031 #include "xyssl/md4.h" 00032 #include "xyssl/md5.h" 00033 #include "xyssl/sha1.h" 00034 #include "xyssl/sha2.h" 00035 #include "xyssl/sha4.h" 00036 #include "xyssl/arc4.h" 00037 #include "xyssl/des.h" 00038 #include "xyssl/aes.h" 00039 #include "xyssl/base64.h" 00040 #include "xyssl/bignum.h" 00041 #include "xyssl/rsa.h" 00042 #include "xyssl/x509.h" 00043 00044 int main( int argc, char *argv[] ) 00045 { 00046 int ret, v; 00047 00048 if( argc == 2 && strcmp( argv[1], "-quiet" ) == 0 ) 00049 v = 0; 00050 else 00051 { 00052 v = 1; 00053 printf( "\n" ); 00054 } 00055 00056 #if defined(XYSSL_MD2_C) 00057 if( ( ret = md2_self_test( v ) ) != 0 ) 00058 return( ret ); 00059 #endif 00060 00061 #if defined(XYSSL_MD4_C) 00062 if( ( ret = md4_self_test( v ) ) != 0 ) 00063 return( ret ); 00064 #endif 00065 00066 #if defined(XYSSL_MD5_C) 00067 if( ( ret = md5_self_test( v ) ) != 0 ) 00068 return( ret ); 00069 #endif 00070 00071 #if defined(XYSSL_SHA1_C) 00072 if( ( ret = sha1_self_test( v ) ) != 0 ) 00073 return( ret ); 00074 #endif 00075 00076 #if defined(XYSSL_SHA2_C) 00077 if( ( ret = sha2_self_test( v ) ) != 0 ) 00078 return( ret ); 00079 #endif 00080 00081 #if defined(XYSSL_SHA4_C) 00082 if( ( ret = sha4_self_test( v ) ) != 0 ) 00083 return( ret ); 00084 #endif 00085 00086 #if defined(XYSSL_ARC4_C) 00087 if( ( ret = arc4_self_test( v ) ) != 0 ) 00088 return( ret ); 00089 #endif 00090 00091 #if defined(XYSSL_DES_C) 00092 if( ( ret = des_self_test( v ) ) != 0 ) 00093 return( ret ); 00094 #endif 00095 00096 #if defined(XYSSL_AES_C) 00097 if( ( ret = aes_self_test( v ) ) != 0 ) 00098 return( ret ); 00099 #endif 00100 00101 #if defined(XYSSL_BASE64_C) 00102 if( ( ret = base64_self_test( v ) ) != 0 ) 00103 return( ret ); 00104 #endif 00105 00106 #if defined(XYSSL_BIGNUM_C) 00107 if( ( ret = mpi_self_test( v ) ) != 0 ) 00108 return( ret ); 00109 #endif 00110 00111 #if defined(XYSSL_RSA_C) 00112 if( ( ret = rsa_self_test( v ) ) != 0 ) 00113 return( ret ); 00114 #endif 00115 00116 #if defined(XYSSL_X509_C) 00117 if( ( ret = x509_self_test( v ) ) != 0 ) 00118 return( ret ); 00119 #endif 00120 00121 if( v != 0 ) 00122 { 00123 printf( " [ All tests passed ]\n\n" ); 00124 #ifdef WIN32 00125 printf( " Press Enter to exit this program.\n" ); 00126 fflush( stdout ); getchar(); 00127 #endif 00128 } 00129 00130 return( ret ); 00131 }