11 #if defined( __MVS__ ) || defined( __VMCMS__ )
13 #pragma convlit( suspend )
15 #if defined( __ILEC400__ )
35 #if defined( _MSC_VER ) && defined( _WIN32 ) && !defined( _WIN32_WCE )
37 #define DATABASE_AUTOCONFIG
41 #define DRIVER_NAME TEXT( "Microsoft Access Driver (*.MDB)" )
42 #define DATABASE_ATTR_NAME "DSN=" DATABASE_KEYSET_NAME_ASCII "#" \
43 "DESCRIPTION=cryptlib test key database#" \
45 #define DATABASE_ATTR_CREATE "DSN=" DATABASE_KEYSET_NAME_ASCII "#" \
46 "DESCRIPTION=cryptlib test key database#" \
48 #define DATABASE_ATTR_TAIL DATABASE_KEYSET_NAME_ASCII ".mdb#"
49 #define CERTSTORE_ATTR_NAME "DSN=" CERTSTORE_KEYSET_NAME_ASCII "#" \
50 "DESCRIPTION=cryptlib test key database#" \
52 #define CERTSTORE_ATTR_CREATE "DSN=" CERTSTORE_KEYSET_NAME_ASCII "#" \
53 "DESCRIPTION=cryptlib test key database#" \
55 #define CERTSTORE_ATTR_TAIL CERTSTORE_KEYSET_NAME_ASCII ".mdb#"
57 #define DRIVER_NAME_ALT TEXT( "SQL Server" )
58 #define DATABASE_ATTR_NAME_ALT "DSN=" DATABASE_KEYSET_NAME_ASCII "#" \
59 "DESCRIPTION=cryptlib test key database#" \
62 #define DATABASE_ATTR_CREATE_ALT ""
63 #define DATABASE_ATTR_TAIL_ALT DATABASE_KEYSET_NAME_ASCII "#"
64 #define CERTSTORE_ATTR_NAME_ALT "DSN=" CERTSTORE_KEYSET_NAME_ASCII "#" \
65 "DESCRIPTION=cryptlib test key database#" \
68 #define CERTSTORE_ATTR_CREATE_ALT ""
69 #define CERTSTORE_ATTR_TAIL_ALT CERTSTORE_KEYSET_NAME_ASCII "#"
71 static void buildDBString(
char *
buffer,
const char *attrName,
72 const char *attrTail,
const char *
path )
74 const int attrNameSize = strlen( attrName );
75 const int attrTailSize = strlen( attrTail ) + 1;
76 const int pathSize = strlen( path );
80 memcpy( buffer, attrName, attrNameSize + 1 );
81 memcpy( buffer + attrNameSize, path, pathSize );
82 if( attrTailSize > 0 )
84 memcpy( buffer + attrNameSize + pathSize, attrTail,
87 buffer[ attrNameSize + pathSize + attrTailSize ] =
'\0';
91 dbStringLen = strlen( buffer );
92 for( i = 0; i < dbStringLen; i++ )
94 if( buffer[ i ] ==
'#' )
99 static BOOLEAN createDatabase(
const char *driverName,
100 const char *keysetName,
101 const char *nameString,
102 const char *createString,
103 const char *trailerString,
106 char tempPathBuffer[ 512 ];
107 char attrBuffer[ 1024 ];
108 #ifdef UNICODE_STRINGS
109 wchar_t wcAttrBuffer[ 1024 ];
113 if( !GetTempPath( 512, tempPathBuffer ) )
114 strcpy( tempPathBuffer,
"C:\\Temp\\" );
122 printf(
"Attempting to create keyset '%s' using alternative data "
123 "source...\n", keysetName );
127 printf(
"Database keyset '%s' not found, attempting to create data "
128 "source...\n", keysetName );
130 buildDBString( attrBuffer, nameString, trailerString, tempPathBuffer );
131 #ifdef UNICODE_STRINGS
132 mbstowcs( wcAttrBuffer, attrBuffer, strlen( attrBuffer ) + 1 );
133 status = SQLConfigDataSource( NULL, ODBC_ADD_DSN, driverName,
136 status = SQLConfigDataSource( NULL, ODBC_ADD_DSN, driverName,
142 WORD errorMessageLen;
143 char errorMessage[ 256 ];
145 if( SQLInstallerError( 1, &dwErrorCode, errorMessage, 256,
146 &errorMessageLen ) != SQL_NO_DATA )
148 printf(
"SQLConfigDataSource() returned error code %d,\n "
149 "message '%s'.\n", dwErrorCode, errorMessage );
150 #if defined( _M_X64 )
153 puts(
" (This is probably because there's no appropriate "
154 "64-bit driver present,\n retrying the create with "
155 "an alternative driver...)." );
166 buildDBString( attrBuffer, createString, trailerString, tempPathBuffer );
167 #ifdef UNICODE_STRINGS
168 mbstowcs( wcAttrBuffer, attrBuffer, strlen( attrBuffer ) + 1 );
169 status = SQLConfigDataSource( NULL, ODBC_ADD_DSN, driverName,
172 status = SQLConfigDataSource( NULL, ODBC_ADD_DSN, driverName,
176 return( ( status == 1 ) ?
TRUE :
FALSE );
179 static BOOLEAN createDatabaseKeyset(
void )
184 DATABASE_ATTR_NAME, DATABASE_ATTR_CREATE,
185 DATABASE_ATTR_TAIL,
FALSE );
186 if( status ==
FALSE )
191 DATABASE_ATTR_NAME_ALT,
192 DATABASE_ATTR_CREATE_ALT,
193 DATABASE_ATTR_TAIL_ALT,
TRUE );
195 puts( ( status ==
TRUE ) ?
"Data source creation succeeded." : \
196 "Data source creation failed.\n\nYou need to create the "
197 "keyset data source as described in the cryptlib manual\n"
198 "for the database keyset tests to run." );
203 static BOOLEAN createDatabaseCertstore(
void )
208 CERTSTORE_ATTR_NAME, CERTSTORE_ATTR_CREATE,
209 CERTSTORE_ATTR_TAIL,
FALSE );
210 if( status ==
FALSE )
215 CERTSTORE_ATTR_NAME_ALT,
216 CERTSTORE_ATTR_CREATE_ALT,
217 CERTSTORE_ATTR_TAIL_ALT,
TRUE );
219 puts( ( status ==
TRUE ) ?
"Data source creation succeeded.\n" : \
220 "Data source creation failed.\n\nYou need to create the "
221 "certificate store data source as described in the\n"
222 "cryptlib manual for the certificate management tests to "
228 static void checkCreateDatabaseKeysets(
void )
242 createDatabaseKeyset();
257 createDatabaseCertstore();
282 printf(
"Attempt to perform cryptlib algorithm self-test failed "
283 "with error code %d, line %d.\n", status, __LINE__ );
293 printf(
"cryptlib algorithm self-test failed, line %d.\n",
297 puts(
"cryptlib algorithm self-test succeeded.\n" );
305 puts(
"Skipping test of self-test routines...\n" );
320 algosEnabled =
FALSE;
332 puts(
"(No conventional-encryption algorithms enabled)." );
335 algosEnabled =
FALSE;
350 puts(
"(No public-key algorithms enabled)." );
353 algosEnabled =
FALSE;
365 puts(
"(No hash algorithms enabled)." );
368 algosEnabled =
FALSE;
380 puts(
"(No MAC algorithms enabled)." );
389 puts(
"Skipping test of low-level encryption routines...\n" );
408 puts(
"The self-test will proceed without using a strong random "
409 "number source.\n" );
421 puts(
"Skipping test of randomness routines...\n" );
501 if( configOption[ i ].isNumeric )
507 printf(
"%s appears to be disabled/unavailable in this build.\n",
508 configOption[ i ].
name );
511 printf(
"%s = %d.\n", configOption[ i ].
name, value );
519 printf(
"%s appears to be disabled/unavailable in this build.\n",
520 configOption[ i ].
name );
523 assert( length < 256 );
524 #ifdef UNICODE_STRINGS
525 buffer[ length /
sizeof(
wchar_t ) ] =
TEXT(
'\0' );
526 printf(
"%s = %S.\n", configOption[ i ].
name, buffer );
529 printf(
"%s = %s.\n", configOption[ i ].
name, buffer );
540 puts(
"Skipping display of config options...\n" );
556 puts(
"Handling for crypto devices doesn't appear to be enabled in "
557 "this build of\ncryptlib.\n" );
569 puts(
"Skipping test of crypto device routines...\n" );
618 puts(
"Skipping test of mid-level encryption routines...\n" );
623 #ifdef TEST_HIGHLEVEL
641 puts(
"Skipping test of high-level routines...\n" );
733 puts(
"Skipping test of certificate routines...\n" );
738 #ifdef TEST_CERTPROCESS
754 puts(
"Handling for CA certificate stores doesn't appear to be "
755 "enabled in this\nbuild of cryptlib, skipping the test of "
756 "the certificate management routines.\n" );
770 puts(
"Skipping test of certificate handling/CA management...\n" );
838 #ifdef DATABASE_AUTOCONFIG
839 checkCreateDatabaseKeysets();
844 puts(
"Handling for certificate databases doesn't appear to be "
845 "enabled in this\nbuild of cryptlib, skipping the test of "
846 "the certificate database routines.\n" );
865 puts(
"Handling for LDAP certificate directories doesn't appear to "
866 "be enabled in\nthis build of cryptlib, skipping the test of "
867 "the certificate directory\nroutines.\n" );
883 puts(
"Handling for fetching certificates from web pages doesn't "
884 "appear to be\nenabled in this build of cryptlib, skipping "
885 "the test of the HTTP routines.\n" );
902 puts(
"Skipping test of file keyset read routines...\n" );
908 puts(
"Skipping test of database keyset read routines...\n" );
984 puts(
"Skipping test of enveloping routines...\n" );
1008 puts(
"Network access doesn't appear to be enabled in this build of "
1009 "cryptlib,\nskipping the test of the secure session routines.\n" );
1014 puts(
"Couldn't perform a test connect to a well-known site "
1015 "(Amazon.com) which\nindicates that external network access "
1016 "isn't available. Is this machine\nsituated behind a "
1065 puts(
"Skipping test of session routines...\n" );
1070 #ifdef TEST_SESSION_LOOPBACK
1082 #ifdef DATABASE_AUTOCONFIG
1083 checkCreateDatabaseKeysets();
1150 #if defined( __WINDOWS__ ) && !defined( _WIN32_WCE )
1152 char name[ MAX_COMPUTERNAME_LENGTH + 1 ];
1153 int length = MAX_COMPUTERNAME_LENGTH + 1;
1155 if( GetComputerName( name, &length ) && length == 7 && \
1156 !memcmp( name,
"WHISPER", length ) && 0 )
1173 puts(
"Skipping test of session routines...\n" );
1199 puts(
"Skipping test of user routines...\n" );