16 #if defined( __MVS__ ) || defined( __VMCMS__ )
18 #pragma convlit( suspend )
20 #if defined( __ILEC400__ )
24 #ifdef CONFIG_SUITEB_TESTS
28 #define TESTFLAG_SENDHTTPREQ 0x01
29 #define TESTFLAG_GENERIC 0x02
36 SUITEB_TEST_CLIINVALIDCURVE,
37 SUITEB_TEST_SVRINVALIDCURVE,
38 SUITEB_TEST_BOTHCURVES,
39 SUITEB_TEST_BOTHSIGALGOS,
43 C_RET cryptSuiteBTestConfig(
C_IN int magicValue );
53 #define SECLVL_128 CRYPT_SSLOPTION_SUITEB_128
54 #define SECLVL_256 CRYPT_SSLOPTION_SUITEB_256
55 #define SECLVL_BOTH SECLVL_128
56 #define FORCE_TLS12 CRYPT_SSLOPTION_MINVER_TLS12
65 #define ALIAS 0, 0, 0, 0, 0, 0
66 #define ALIAS_SPECIAL 0, 0, 0, 0, 0
75 SPECIAL_SVR_INVALIDCURVE,
80 SPECIAL_BOTH_SUPPCURVES,
87 SPECIAL_CLI_INVALIDCURVE,
89 SPECIAL_BOTH_SUPPALGO,
91 } SPECIAL_HANDLING_TYPE;
101 const int clientOptions;
102 const int clientAuthKeySizeBits;
104 const int serverOptions;
105 const int serverKeySizeBits;
108 const SPECIAL_HANDLING_TYPE handlingType;
110 const char *aliasTestName;
113 static const SUITEB_TEST_INFO clientTestInfo[] = {
114 { NULL, 0, 0, 0, 0, 0 },
118 {
"A.1.1.1", SECLVL_128, 0, SECLVL_128, P256,
TRUE },
119 {
"A.1.1.2", SECLVL_128, 0, SECLVL_128, P521,
FALSE, SPECIAL_SVR_INVALIDCURVE },
120 {
"A.1.2.1", SECLVL_256, 0, SECLVL_256, P384,
TRUE },
121 {
"A.1.2.2", SECLVL_256, 0, SECLVL_256, P521,
FALSE, SPECIAL_SVR_INVALIDCURVE },
122 {
"A.1.3.1", ALIAS,
"A.1.1.1" },
123 {
"A.1.4.1", ALIAS,
"A.1.1.1" },
124 {
"A.1.5.1", ALIAS_SPECIAL, SPECIAL_CLI_TLSALERT,
"A.1.1.2" },
125 {
"A.1.5.2", ALIAS_SPECIAL, SPECIAL_CLI_TLSALERT,
"A.1.2.2" },
126 {
"A.1.6.1", ALIAS,
"A.1.4.1" },
127 {
"A.1.7.1", SECLVL_128, P256, SECLVL_BOTH, P384,
TRUE },
128 {
"A.1.7.2", SECLVL_BOTH, P384, SECLVL_128, P256,
TRUE },
129 {
"A.1.8.1", ALIAS,
"A.1.1.1" },
130 {
"A.1.9.1", SECLVL_128, 0, SECLVL_BOTH, P384,
TRUE },
131 {
"A.1.10.1", ALIAS,
"A.1.2.1" },
132 {
"A.1.11.1", ALIAS,
"A.1.2.1" },
133 {
"A.1.12.1", ALIAS,
"A.1.1.1" },
134 {
"A.1.13.1", SECLVL_128, 0, SECLVL_128 | FORCE_TLS12, P256,
TRUE },
135 {
"A.1.14.1", SECLVL_128, 0, SECLVL_128, P256,
TRUE },
136 {
"A.1.15.1", SECLVL_128, 0, SECLVL_128, P256,
TRUE },
137 {
"A.1.16.1", SECLVL_256, 0, SECLVL_256, P384,
TRUE },
138 {
"A.1.17.1", ALIAS,
"A.1.14.1" },
139 {
"A.1.18.1", ALIAS,
"A.1.14.1" },
140 {
"A.1.19.1", ALIAS,
"A.1.1.1" },
141 {
"A.1.20.1", ALIAS,
"A.1.1.1" },
142 {
"A.1.21.1", ALIAS,
"A.1.2.1" },
143 {
"A.1.22.1", ALIAS,
"A.1.1.1" },
144 {
"A.1.21.2", ALIAS,
"A.1.2.1" },
145 {
"A.1.24.1", SECLVL_128, 0, SECLVL_128, P256,
TRUE },
146 {
"A.1.24.2", SECLVL_256, 0, SECLVL_256, P384,
TRUE },
147 {
"A.1.25.1", ALIAS,
"A.1.24.1" },
148 {
"A.1.26.1", SECLVL_128, 0, SECLVL_128, P384,
TRUE, SPECIAL_BOTH_SUPPCURVES },
149 {
"A.1.27.1", ALIAS,
"A.1.24.2" },
150 {
"A.1.28.1", ALIAS,
"A.1.1.1" },
151 {
"A.1.29.1", ALIAS,
"A.2.8.1" },
152 {
"A.1.30.1", ALIAS,
"A.1.2.1" },
153 {
"A.1.31.1", ALIAS,
"A.1.1.1" },
154 {
"A.1.32.1", ALIAS,
"A.1.1.1" },
155 {
"A.1.33.1", ALIAS,
"A.1.7.1" },
156 {
"A.1.34.1", SECLVL_128, 0, SECLVL_128, P256,
TRUE },
157 {
"A.1.34.2", SECLVL_256, 0, SECLVL_256, P384,
TRUE },
158 {
"A.1.35.1", ALIAS,
"A.1.34.1" },
159 {
"A.1.36.1", SECLVL_BOTH, 0, SECLVL_BOTH, P384,
TRUE, SPECIAL_BOTH_SIGALGO },
160 {
"A.1.37.1", ALIAS,
"A.1.34.2" },
161 {
"A.1.39.1", SECLVL_128, P256, SECLVL_128, P256,
TRUE },
162 {
"A.1.39.2", SECLVL_256, P384, SECLVL_256, P384,
TRUE },
163 {
"A.1.40.1", ALIAS,
"A.1.39.1" },
164 {
"A.1.41.1", ALIAS,
"A.1.39.2" },
171 static const SUITEB_TEST_INFO serverTestInfo[] = {
172 { NULL, 0, 0, 0, 0, 0 },
176 {
"A.2.1.1", SECLVL_128, 0, SECLVL_128, P256,
TRUE },
177 {
"A.2.1.2", SECLVL_256, 0, SECLVL_128, P256,
FALSE, SPECIAL_CLI_INVALIDCURVE },
178 {
"A.2.2.1", SECLVL_256, 0, SECLVL_256, P384,
TRUE },
179 {
"A.2.2.2", SECLVL_256, 0, SECLVL_256, P384,
FALSE, SPECIAL_CLI_INVALIDCURVE },
180 {
"A.2.5.1", ALIAS,
"A.2.1.2" },
181 {
"A.2.5.1", ALIAS,
"A.2.2.2" },
182 {
"A.2.3.1", ALIAS_SPECIAL, SPECIAL_SVR_TLSALERT,
"A.2.1.2" },
183 {
"A.2.4.1", ALIAS_SPECIAL, SPECIAL_SVR_TLSALERT,
"A.2.2.2" },
184 {
"A.2.6.1", SECLVL_128, P384, SECLVL_BOTH, P256,
TRUE },
185 {
"A.2.6.2", SECLVL_128, P256, SECLVL_BOTH, P384,
TRUE },
186 {
"A.2.7.1", ALIAS,
"A.2.1.1" },
187 {
"A.2.8.1", SECLVL_128, P384, SECLVL_BOTH, P256,
TRUE },
188 {
"A.2.9.1", ALIAS,
"A.2.2.1" },
189 {
"A.2.10.1", ALIAS,
"A.2.2.1" },
190 {
"A.2.11.1", ALIAS,
"A.2.6.1" },
191 {
"A.2.12.1", SECLVL_128 | FORCE_TLS12, 0, SECLVL_128, P256,
TRUE },
192 {
"A.2.13.1", SECLVL_BOTH, 0, SECLVL_128, P256,
TRUE },
193 {
"A.2.14.1", SECLVL_256, 0, SECLVL_256, P384,
TRUE },
194 {
"A.2.15.1", ALIAS,
"A.2.1.1" },
195 {
"A.2.16.1", ALIAS,
"A.2.1.1" },
196 {
"A.2.17.1", ALIAS,
"A.2.2.1" },
197 {
"A.2.18.1", ALIAS,
"A.2.1.1" },
198 {
"A.2.18.2", ALIAS,
"A.2.2.1" },
199 {
"A.2.20.1", ALIAS,
"A.2.1.1" },
200 {
"A.2.21.1", ALIAS,
"A.2.8.1" },
201 {
"A.2.22.1", ALIAS,
"A.2.2.1" },
202 {
"A.2.23.1", SECLVL_128, 0, SECLVL_BOTH, P256,
FALSE, SPECIAL_CLI_INVALIDCURVE },
203 {
"A.2.24.1", ALIAS_SPECIAL, SPECIAL_SVR_TLSALERT,
"A.2.23.1" },
204 {
"A.2.26.1", SECLVL_128, P256, SECLVL_128, P256,
TRUE },
205 {
"A.2.26.2", SECLVL_256, P384, SECLVL_256, P384,
TRUE },
206 {
"A.2.27.1", ALIAS,
"A.2.26.1" },
207 {
"A.2.28.1", SECLVL_BOTH, P256, SECLVL_BOTH, P256,
TRUE, SPECIAL_BOTH_SUPPALGO },
208 {
"A.2.29.1", ALIAS,
"A.2.26.2" },
209 {
"A.2.30.1", ALIAS,
"A.2.1.1" },
210 {
"A.2.30.2", ALIAS,
"A.2.1.2" },
211 {
"A.2.31.1", ALIAS,
"A.2.30.1" },
212 {
"A.2.32.1", ALIAS,
"A.2.30.1" },
213 {
"A.2.33.1", ALIAS,
"A.2.30.2" },
221 #define SUITEB_FIRST_CLIENT 1
222 #define SUITEB_LAST_CLIENT 48
223 #define SUITEB_FIRST_SERVER 1
224 #define SUITEB_LAST_SERVER 38
228 static int showTest(
const SUITEB_TEST_INFO *testInfoPtr )
232 for( i = 0; i < 6; i++ )
234 if( testInfoPtr->testName == NULL )
236 printf(
" %8s", testInfoPtr->testName );
244 static void showTestInfo(
void )
248 puts(
" Suite B client tests:" );
249 for( i = 1; clientTestInfo[ i ].testName != NULL; i += 6 )
251 if( !showTest( &clientTestInfo[ i ] ) )
257 puts(
"\n Suite B server tests:" );
258 for( i = 1; serverTestInfo[ i ].testName != NULL; i += 6 )
260 if( !showTest( &serverTestInfo[ i ] ) )
271 static int lookupTestNo(
const char *testName )
275 for( i = 1; clientTestInfo[ i ].testName != NULL; i++ )
277 if( !strcmp( testName + 1, clientTestInfo[ i ].testName + 1 ) )
280 for( i = 1; serverTestInfo[ i ].testName != NULL; i++ )
282 if( !strcmp( testName + 1, serverTestInfo[ i ].testName + 1 ) )
297 static const SUITEB_TEST_INFO *findAliasTest(
const SUITEB_TEST_INFO *testInfo,
298 const char *testName )
302 for( i = 0; testInfo[ i ].testName != NULL; i++ )
304 if( !strcmp( testInfo[ i ].testName, testName ) )
305 return( &testInfo[ i ] );
314 static int suitebServer(
const int testNo,
const char *hostName,
315 const int port,
const int flags,
320 const SUITEB_TEST_INFO *testInfoPtr = isServerTest ? \
321 &serverTestInfo[ testNo ] : &clientTestInfo[ testNo ];
322 const char *testName = testInfoPtr->testName;
323 const BOOLEAN isLoopbackTest = \
324 ( !strcmp( hostName,
"localhost" ) && port == 0 ) ?
TRUE :
FALSE;
326 ( flags & TESTFLAG_SENDHTTPREQ ) ?
TRUE :
FALSE;
328 #ifdef UNICODE_STRINGS
331 SPECIAL_HANDLING_TYPE handlingTypeAlt = SPECIAL_NONE;
332 void *fileNamePtr = filenameBuffer;
338 if( testNo < SUITEB_FIRST_SERVER || testNo > SUITEB_LAST_SERVER )
343 if( testNo < SUITEB_FIRST_CLIENT || testNo > SUITEB_LAST_CLIENT )
348 if( testInfoPtr->aliasTestName != NULL )
350 handlingTypeAlt = testInfoPtr->handlingType;
351 testInfoPtr = findAliasTest( isServerTest ? \
352 &serverTestInfo[ 1 ] : &clientTestInfo[ 1 ],
353 testInfoPtr->aliasTestName );
354 if( testInfoPtr == NULL )
363 cryptSuiteBTestConfig( SUITEB_TEST_NONE );
365 printf(
"SVR: Running Suite B server " );
366 if( flags & TESTFLAG_GENERIC )
367 printf(
"as generic test server.\n" );
369 printf(
"with test %s.\n", testInfoPtr->testName );
378 printf(
"cryptCreateSession() failed with error code %d, line %d.\n",
383 if(
cryptStatusOK( status ) && testInfoPtr->serverOptions != 0 )
386 testInfoPtr->serverOptions );
388 if( testInfoPtr->clientAuthKeySizeBits > 0 )
391 cryptSuiteBTestConfig( 1000 );
395 printf(
"cryptSetAttribute() failed with error code %d, line %d.\n",
411 hostName, strlen( hostName ) );
417 printf(
"cryptSetAttribute()/cryptSetAttributeString() failed "
418 "with error code %d, line %d.\n", status, __LINE__ );
426 switch( testInfoPtr->handlingType )
428 case SPECIAL_SVR_INVALIDCURVE:
430 status = cryptSuiteBTestConfig( SUITEB_TEST_SVRINVALIDCURVE );
433 case SPECIAL_BOTH_SUPPCURVES:
436 status = cryptSuiteBTestConfig( SUITEB_TEST_BOTHCURVES );
439 case SPECIAL_BOTH_SIGALGO:
442 status = cryptSuiteBTestConfig( SUITEB_TEST_BOTHSIGALGOS );
447 printf(
"Custom config set failed with error code %d, line %d.\n",
454 testInfoPtr->serverKeySizeBits );
455 #ifdef UNICODE_STRINGS
456 mbstowcs( wcBuffer, filenameBuffer, strlen( filenameBuffer ) + 1 );
457 fileNamePtr = wcBuffer;
469 printf(
"SVR: cryptSetAttribute/AttributeString() failed with error "
470 "code %d, line %d.\n", status, __LINE__ );
487 if( testInfoPtr->result )
488 printf(
"SVR: Test %s failed, should have succeeded.\n",
491 printf(
"SVR: Test %s succeeded, should have failed.\n",
495 printExtError( cryptSession,
"SVR: Failure reason is:", status,
504 if( testInfoPtr->handlingType != 0 || handlingTypeAlt != 0 )
506 const SPECIAL_HANDLING_TYPE handlingType = \
507 ( handlingTypeAlt != 0 ) ? handlingTypeAlt : \
508 testInfoPtr->handlingType;
512 switch( handlingType )
514 case SPECIAL_CLI_TLSALERT:
519 memcmp(
buffer,
"Received TLS alert", 18 ) )
521 printf(
"SVR: Test %s should have returned a TLS alert "
522 "but didn't.\n", testName );
532 const char serverReply[] = \
534 "Date: Fri, 7 September 2010 20:02:07 GMT\n"
535 "Server: cryptlib Suite B test\n"
536 "Content-Type: text/html\n"
537 "Connection: Close\n"
539 "<!DOCTYPE HTML SYSTEM \"html.dtd\">\n"
542 "<title>cryptlib Suite B test page</title>\n"
544 "Test message from the cryptlib Suite B server.<p>\n"
555 printExtError( cryptSession,
"SVR: Attempt to read data from "
556 "client", status, __LINE__ );
561 printf(
"---- Client sent %d bytes ----\n", bytesCopied );
563 puts(
"---- End of output ----" );
567 sizeof( serverReply ) - 1, &bytesCopied );
571 bytesCopied !=
sizeof( serverReply ) - 1 )
573 printExtError( cryptSession,
"Attempt to send data to client",
584 printf(
"cryptDestroySession() failed with error code %d, line %d.\n",
588 printf(
"SVR: Suite B server test %s succeeded.\n", testName );
595 static int suitebClient(
const int testNo,
const char *hostName,
596 const int port,
const int flags,
600 const SUITEB_TEST_INFO *testInfoPtr = isServerTest ? \
601 &serverTestInfo[ testNo ] : &clientTestInfo[ testNo ];
602 const BOOLEAN isLoopbackTest = \
603 ( !strcmp( hostName,
"localhost" ) && port == 0 ) ?
TRUE :
FALSE;
605 ( flags & TESTFLAG_SENDHTTPREQ ) ?
TRUE :
FALSE;
606 const char *testName = testInfoPtr->testName;
607 SPECIAL_HANDLING_TYPE handlingTypeAlt = SPECIAL_NONE;
613 if( testNo < SUITEB_FIRST_SERVER || testNo > SUITEB_LAST_SERVER )
618 if( testNo < SUITEB_FIRST_CLIENT || testNo > SUITEB_LAST_CLIENT )
623 if( testInfoPtr->aliasTestName != NULL )
625 handlingTypeAlt = testInfoPtr->handlingType;
626 testInfoPtr = findAliasTest( isServerTest ? \
627 &serverTestInfo[ 1 ] : &clientTestInfo[ 1 ],
628 testInfoPtr->aliasTestName );
629 if( testInfoPtr == NULL )
639 printf(
"Timed out waiting for server to initialise, line %d.\n",
643 if( !isLoopbackTest )
648 cryptSuiteBTestConfig( SUITEB_TEST_NONE );
651 printf(
"Running Suite B client " );
652 if( flags & TESTFLAG_GENERIC )
653 printf(
"as generic test client.\n" );
655 printf(
"with test %s.\n", testInfoPtr->testName );
664 printf(
"cryptCreateSession() failed with error code %d, line %d.\n",
669 if(
cryptStatusOK( status ) && testInfoPtr->clientOptions != 0 )
672 testInfoPtr->clientOptions );
676 printf(
"cryptSetAttribute() failed with error code %d, line %d.\n",
692 hostName, strlen( hostName ) );
698 printf(
"cryptSetAttribute()/cryptSetAttributeString() failed "
699 "with error code %d, line %d.\n", status, __LINE__ );
704 testInfoPtr->clientAuthKeySizeBits > 0 )
708 #ifdef UNICODE_STRINGS
711 void *fileNamePtr = filenameBuffer;
716 testInfoPtr->clientAuthKeySizeBits );
717 #ifdef UNICODE_STRINGS
718 mbstowcs( wcBuffer, filenameBuffer, strlen( filenameBuffer ) + 1 );
719 fileNamePtr = wcBuffer;
732 printf(
"cryptSetAttribute/AttributeString() failed with error code "
733 "%d, line %d.\n", status, __LINE__ );
743 switch( testInfoPtr->handlingType )
745 case SPECIAL_CLI_INVALIDCURVE:
747 status = cryptSuiteBTestConfig( SUITEB_TEST_CLIINVALIDCURVE );
750 case SPECIAL_BOTH_SUPPALGO:
753 status = cryptSuiteBTestConfig( SUITEB_TEST_BOTHSIGALGOS );
758 printf(
"Custom config set failed with error code %d, line %d.\n",
768 if( testInfoPtr->result )
769 printf(
"Test %s failed, should have succeeded.\n", testName );
771 printf(
"Test %s succeeded, should have failed.\n", testName );
783 if( testInfoPtr->handlingType != 0 || handlingTypeAlt != 0 )
785 const SPECIAL_HANDLING_TYPE handlingType = \
786 ( handlingTypeAlt != 0 ) ? handlingTypeAlt : \
787 testInfoPtr->handlingType;
791 switch( handlingType )
793 case SPECIAL_CLI_INVALIDCURVE:
794 case SPECIAL_BOTH_SUPPALGO:
799 case SPECIAL_SVR_TLSALERT:
804 memcmp( buffer,
"Received TLS alert", 18 ) )
806 printf(
"Test %s should have returned a TLS alert but "
807 "didn't.\n", testName );
812 case SPECIAL_SVR_INVALIDCURVE:
825 const char *fetchString =
"GET / HTTP/1.0\r\n\r\n";
826 const int fetchStringLen =
sizeof( fetchString ) - 1;
830 fetchStringLen, &bytesCopied );
835 printExtError( cryptSession,
"Attempt to send data to server",
846 printf(
"cryptDestroySession() failed with error code %d, line %d.\n",
850 printf(
"Suite B client test %s succeeded.\n", testName );
856 const char *hostName,
const int port,
869 if( hostName == NULL )
870 hostName =
"localhost";
875 status = suitebServer( value, hostName, port, flags,
878 status = suitebClient( value, hostName, port, flags,
884 #ifdef WINDOWS_THREADS
886 unsigned __stdcall suitebServerThread(
void *arg )
889 int value = *( (
int * ) arg );
896 suitebServer( value,
"localhost", 0,
FALSE, isServerTest );
910 hThread = (
HANDLE ) _beginthreadex( NULL, 0, suitebServerThread,
911 &value, 0, &threadID );
920 status = suitebClient( value,
"localhost", 0,
FALSE, isServerTest );
944 static int generateKey(
const int keyBits,
const char *certRequestFileName )
952 void *fileNamePtr = filenameBuffer;
973 printf(
"Key generation failed with error code %d, line %d.\n",
985 !
addCertFields( cryptCertRequest, certRequestData, __LINE__ ) )
998 printf(
"Certificate request creation failed with error code %d, "
999 "line %d.\n", status, __LINE__ );
1002 if( ( filePtr = fopen( certRequestFileName,
"wb" ) ) != NULL )
1004 count = fwrite( certBuffer, 1, length, filePtr );
1007 if( filePtr == NULL || count < length )
1009 printf(
"Couldn't write certificate request to disk, line %d.\n",
1021 printf(
"cryptKeysetOpen() failed with error code %d, line %d.\n",
1041 static int updateKey(
const int keyBits,
const char *certFileName )
1046 void *fileNamePtr = filenameBuffer;
1053 printf(
"Couldn't import certificate from file, status %d, "
1054 "line %d.\n", status, __LINE__ );
1070 printf(
"Couldn't update private key with certificate, status %d, "
1071 "line %d.\n", status, __LINE__ );
1086 static void usageExit(
void )
1088 puts(
"Usage: testlib c|s [-h hostname] [-p port] [-s] <test>" );
1090 puts(
" Operation type:" );
1091 puts(
" c = Run test as the client." );
1092 puts(
" s = Run test as the server." );
1093 puts(
" <test> = Test name, e.g. 'A.1.1.1', or '128'/'256' to run as a" );
1094 puts(
" generic 128/256-bit client or server." );
1097 puts(
" Options:" );
1098 puts(
" -s = Send HTTP request." );
1099 puts(
" -h <hostname> = Host name (default localhost)." );
1100 puts(
" -p <port> = Port (default 443 or 4443)." );
1101 puts(
" -- = End of arg list." );
1106 puts(
" Keygen commands:" );
1108 puts(
" kg [256|384] <cert-request filename>" );
1109 puts(
" = Generate 256/384-bit key and PKCS #10 cert request." );
1110 puts(
" ka [256|384] <certificate filename>" );
1111 puts(
" = Add issued certificate to previously-generated 256/384-bit key." );
1119 static int processArgs(
int argc,
char **argv,
int *testNo,
1120 const char **stringArg,
int *intArg,
1123 const char *argPtr = argv[ 0 ];
1128 *testNo = *intArg = 0;
1130 *isServer = *sendHTTPheader =
FALSE;
1137 switch( tolower( *argPtr ) )
1150 switch( tolower( argPtr[ 1 ] ) )
1161 printf(
"Error: Unknown key management option '%c'.\n",
1170 puts(
"Error: Missing key size." );
1175 if( *argPtr ==
'2' || *argPtr ==
'3' )
1176 value = atoi( argv[ 0 ] );
1177 if( value != 256 && value != 384 )
1179 puts(
"Error: Key size must be '256' or '384'." );
1188 puts(
"Error: Missing file name." );
1191 *stringArg = argv[ 0 ];
1197 filePtr = fopen( argv[ 0 ],
"rb" );
1198 if( filePtr == NULL )
1200 printf(
"Error: Can't open '%s'.\n", argv[ 0 ] );
1210 printf(
"Error: Spurious option '%s'.\n", argv[ 0 ] );
1220 while( argc > 0 && moreArgs )
1223 if( *argPtr ==
'1' || *argPtr ==
'2' )
1227 value = atoi( argPtr );
1228 if( value != 128 && value != 256 )
1230 puts(
"Error: Generic client/server type must be '128' "
1239 if( *argPtr ==
'a' || *argPtr ==
'A' )
1248 if( argPtr[ 1 ] !=
'.' || \
1249 ( argPtr[ 2 ] !=
'1' && argPtr[ 2 ] !=
'2' ) || \
1250 argPtr[ 3 ] !=
'.' || \
1251 ( argPtr[ 4 ] <
'1' || argPtr[ 4 ] >
'3' ) )
1253 value = lookupTestNo( argPtr );
1256 printf(
"Error: Unknown test type '%s'.\n", argPtr );
1264 if( *argPtr !=
'-' )
1266 printf(
"Error: Unknown argument '%s'.\n", argPtr );
1272 switch( toupper( *argPtr ) )
1279 if( *stringArg != NULL )
1284 puts(
"Error: Missing host name" );
1287 *stringArg = argv[ 0 ];
1297 puts(
"Error: Missing port number" );
1300 value = atoi( argv[ 0 ] );
1308 if( *sendHTTPheader !=
FALSE )
1310 *sendHTTPheader =
TRUE;
1315 printf(
"Error: Unknown argument '%c'.\n", *argPtr );
1324 puts(
"Error: Missing test name" );
1333 int suiteBMain(
int argc,
char **argv )
1335 const char *stringArg;
1337 int testNo, intArg,
status;
1341 printf(
"testlib - cryptlib %d-bit Suite B test framework.\n",
1342 (
int )
sizeof(
long ) * 8 );
1343 puts(
"Copyright Peter Gutmann 1995 - 2011." );
1348 status = processArgs( argc, argv, &testNo, &stringArg, &intArg,
1349 &isServer, &sendHTTPheader );
1360 printf(
"\ncryptInit() failed with error code %d, line %d.\n",
1387 status = generateKey( intArg, stringArg );
1388 if( status ==
TRUE )
1389 printf(
"Wrote %d-bit certificate request to "
1390 "file '%s'.\n\n", intArg, stringArg );
1394 status = updateKey( intArg, stringArg );
1395 if( status ==
TRUE )
1396 printf(
"Updated %d-bit key with certificate from "
1397 "file '%s'.\n\n", intArg, stringArg );
1404 status = suitebTest( isServer, testNo, stringArg, intArg,