12 #if defined( __MVS__ ) || defined( __VMCMS__ )
14 #pragma convlit( suspend )
16 #if defined( __ILEC400__ )
26 #if defined( __MVS__ ) || defined( __VMCMS__ )
27 #define ENVELOPE_TESTDATA ( ( BYTE * ) "\x53\x6F\x6D\x65\x20\x74\x65\x73\x74\x20\x64\x61\x74\x61" )
28 #define ENVELOPE_PGP_TESTDATA ( ( BYTE * ) "\x53\x6F\x6D\x65\x20\x74\x65\x73\x74\x20\x64\x61\x74\x61\x2E" )
29 #define ENVELOPE_COMPRESSEDDATA "\x2F\x2A\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x6C\x6F\x77\x65\x73\x74\x2D"
31 #define ENVELOPE_TESTDATA ( ( BYTE * ) "Some test data" )
32 #define ENVELOPE_PGP_TESTDATA ( ( BYTE * ) "Some test data." )
33 #define ENVELOPE_COMPRESSEDDATA "
35 #define ENVELOPE_TESTDATA_SIZE 15
36 #define ENVELOPE_COMPRESSEDDATA_SIZE 20
66 #if defined( TEST_ENVELOPE ) || defined( TEST_SESSION )
84 static int getFileSize(
const char *
fileName )
89 if( ( filePtr = fopen( fileName,
"rb" ) ) == NULL )
92 size = ftell( filePtr );
97 return( (
int ) size );
102 static int readFileData(
const char *
fileName,
const char *description,
108 if( ( filePtr = fopen( fileName,
"rb" ) ) == NULL )
110 printf(
"Couldn't find %s file, skipping test of data import...\n",
114 printf(
"Testing %s import...\n", description );
115 count = fread( buffer, 1, bufSize, filePtr );
117 if( count >= bufSize )
119 puts(
"The data buffer size is too small for the data. To fix this, "
120 "either increase\nthe BUFFER_SIZE value in " __FILE__
" and "
121 "recompile the code, or use the\ntest code with dynamically-"
122 "allocated buffers." );
127 printf(
"Read failed, only read %d bytes.\n", count );
130 printf(
"%s has size %d bytes.\n", description, count );
146 printf(
"cryptCreateEnvelope() failed with error code %d, line %d.\n",
162 printf(
"cryptCreateDeevelope() failed with error code %d, line %d.\n",
172 const void *envInfo,
const int envInfoLen )
179 printf(
"cryptSetAttributeString() failed with error code %d, "
180 "line %d.\n", status, __LINE__ );
196 printf(
"cryptSetAttribute() of %d failed with error code %d, "
197 "line %d.\n", type, status, __LINE__ );
204 static int processEnvelopeResource(
const CRYPT_ENVELOPE envelope,
205 const void *stringEnvInfo,
206 const int numericEnvInfo,
210 int integrityLevel,
status;
213 *isRestartable =
FALSE;
221 printf(
"Attempt to move cursor to start of list failed with error "
222 "code %d, line %d.\n", status, __LINE__ );
234 printf(
"Attempt to read current group failed with error code "
235 "%d, line %d.\n", status, __LINE__ );
239 switch( cryptEnvInfo )
246 puts(
"(Decryption key was recovered using crypto device or "
247 "non-password-protected\n private key)." );
253 if( stringEnvInfo == NULL )
260 printf(
"Attempt to add private key failed with "
261 "error code %d, line %d.\n", status,
265 *isRestartable =
TRUE;
273 label, &labelLength );
276 printf(
"Private key label read failed with error code "
277 "%d, line %d.\n", status, __LINE__ );
280 #ifdef UNICODE_STRINGS
281 label[ labelLength /
sizeof(
wchar_t ) ] =
'\0';
282 printf(
"Need password to decrypt private key '%S'.\n",
285 label[ labelLength ] =
'\0';
286 printf(
"Need password to decrypt private key '%s'.\n",
292 *isRestartable =
TRUE;
296 puts(
"Need user password." );
300 *isRestartable =
TRUE;
304 puts(
"Need session key." );
308 *isRestartable =
TRUE;
312 puts(
"Need conventional encryption key." );
316 *isRestartable =
TRUE;
327 printf(
"Need unknown enveloping information type %d.\n",
340 printf(
"Couldn't query integrity protection used in envelope, "
341 "status %d, line %d.\n", status, __LINE__ );
346 printf(
"Data is integrity-proteced using %s authentication.\n",
350 "MAC+encrypt" :
"unknown" );
369 printf(
"Couldn't query encryption algorithm and keysize used in "
370 "envelope, status %d, line %d.\n", status, __LINE__ );
373 printf(
"Data is protected using algorithm %d with %d bit key.\n",
374 cryptAlgo, keySize * 8 );
380 const int length,
const void *stringEnvInfo,
381 const int numericEnvInfo )
383 int bytesIn, contentType,
status;
386 status =
cryptPushData( envelope, buffer, length, &bytesIn );
392 status = processEnvelopeResource( envelope, stringEnvInfo,
393 numericEnvInfo, &isRestartable );
399 if( bytesIn < length && isRestartable )
401 const int initialBytesIn = bytesIn;
404 length - initialBytesIn, &bytesIn );
407 printf(
"cryptPushData() for remaining data failed with "
408 "error code %d, line %d.\n", status, __LINE__ );
411 bytesIn += initialBytesIn;
418 printExtError( envelope,
"cryptPushData()", status, __LINE__ );
422 if( bytesIn < length )
424 BYTE tempBuffer[ 8192 ];
425 int bytesIn2, bytesOut;
433 printf(
"(Ran out of input buffer data space, popping %d bytes to "
434 "make room).\n", 8192 );
435 status =
cryptPopData( envelope, tempBuffer, 8192, &bytesOut );
438 printf(
"cryptPopData() to make way for remaining data failed "
439 "with error code %d, line %d.\n", status, __LINE__ );
443 length - bytesIn, &bytesIn2 );
446 printExtError( envelope,
"cryptPushData() of remaining data",
452 if( bytesIn != length )
454 printf(
"cryptPushData() only copied %d of %d bytes, line %d.\n",
455 bytesIn, length, __LINE__ );
463 printExtError( envelope,
"cryptFlushData()", status, __LINE__ );
483 puts(
"(Data is from a detached signature, couldn't determine "
487 printf(
"Couldn't query content type in envelope, status %d, "
488 "line %d.\n", status, __LINE__ );
492 printf(
"Nested content type = %d.\n", contentType );
501 status =
cryptPopData( envelope, buffer, bufferSize, &bytesOut );
504 printExtError( envelope,
"cryptPopData()", status, __LINE__ );
519 printf(
"cryptDestroyEnvelope() failed with error code %d, line %d.\n",
535 static int envelopeData(
const char *dumpFileName,
537 const int bufferSize,
541 BYTE *inBufPtr, *outBufPtr = globalBuffer;
547 printf(
"Testing %splain data enveloping%s...\n",
550 " with datasize hint" :
"" );
556 printf(
"Testing %splain data enveloping of intermediate-size data...\n",
559 inBufPtr = globalBuffer;
560 for( count = 0; count <
length; count++ )
561 inBufPtr[ count ] = count & 0xFF;
565 printf(
"Testing %senveloping of large data quantity...\n",
569 length = ( INT_MAX <= 32768L ) ? 16384 : 1048576;
570 if( ( inBufPtr = malloc( length + 128 ) ) == NULL )
572 printf(
"Couldn't allocate buffer of %d bytes, skipping large "
573 "buffer enveloping test.\n", length );
576 outBufPtr = inBufPtr;
577 for( count = 0; count <
length; count++ )
578 inBufPtr[ count ] = count & 0xFF;
584 bufSize = length + 128;
588 if( !createEnvelope( &cryptEnvelope, formatType ) )
595 count = pushData( cryptEnvelope, inBufPtr, length, NULL, 0 );
598 count = popData( cryptEnvelope, outBufPtr, bufSize );
601 if( !destroyEnvelope( cryptEnvelope ) )
603 if( bufferSize == 0 && \
605 useDatasize ? 17 : 25 ) )
607 printf(
"Enveloped data length %d, should be %d, line %d.\n",
608 count, length + 25, __LINE__ );
613 printf(
"Enveloped data has size %d bytes.\n", count );
615 debugDump( dumpFileName, outBufPtr, count );
619 if( !createDeenvelope( &cryptEnvelope ) )
624 count = pushData( cryptEnvelope, outBufPtr, count, NULL, 0 );
627 count = popData( cryptEnvelope, outBufPtr, bufSize );
630 if( !destroyEnvelope( cryptEnvelope ) )
634 if( count != length )
636 puts(
"De-enveloped data length != original length." );
643 for( i = 0; i <
length; i++ )
644 if( outBufPtr[ i ] != ( i & 0xFF ) )
646 printf(
"De-enveloped data != original data at byte %d, "
647 "line %d.\n", i, __LINE__ );
655 puts(
"De-enveloped data != original data." );
663 puts(
"Enveloping of plain data succeeded.\n" );
687 static int envelopeDecompress(
BYTE *buffer,
const int bufSize,
691 BYTE smallBuffer[ 128 ];
692 int count, zeroCount;
696 if( !createDeenvelope( &cryptEnvelope ) )
698 count = pushData( cryptEnvelope, buffer, length, NULL, 0 );
701 count = popData( cryptEnvelope, buffer, bufSize );
707 puts(
"Older HPUX compilers break zlib, to remedy this you can "
708 "either get a better\ncompiler/OS or grab a debugger and "
709 "try to figure out what HPUX is doing to\nzlib. To "
710 "continue the self-tests, comment out the call to\n"
711 "testEnvelopeCompress() and rebuild." );
721 zeroCount = popData( cryptEnvelope, smallBuffer, 128 );
724 puts(
"Attempt to pop more data after end-of-data had been reached "
725 "succeeded, the\nenvelope should have reported 0 bytes "
731 if( !destroyEnvelope( cryptEnvelope ) )
736 static int envelopeCompress(
const char *dumpFileName,
743 int dataCount = 0, count,
status;
745 printf(
"Testing %scompressed data enveloping%s...\n",
747 useDatasize ?
" with datasize hint" :
"" );
756 puts(
"Couldn't allocate test buffers." );
769 free( envelopedBuffer );
770 puts(
"Couldn't read test file for compression." );
776 if( !createEnvelope( &cryptEnvelope, formatType ) )
782 printf(
"Attempt to enable compression failed, status = %d, "
783 "line %d.\n", status, __LINE__ );
788 count = pushData( cryptEnvelope, buffer, dataCount, NULL, 0 );
792 if( count > dataCount - 1000 )
794 printf(
"Compression of data failed, %d bytes in -> %d bytes out, "
795 "line %d.\n", dataCount, count, __LINE__ );
800 if( !destroyEnvelope( cryptEnvelope ) )
804 printf(
"Enveloped data has size %d bytes.\n", count );
805 debugDump( dumpFileName, envelopedBuffer, count );
812 if( count != dataCount || memcmp( buffer, envelopedBuffer, dataCount ) )
814 puts(
"De-enveloped data != original data." );
820 free( envelopedBuffer );
821 puts(
"Enveloping of compressed data succeeded.\n" );
845 static int envelopeSessionCrypt(
const char *dumpFileName,
857 #if defined( __MSDOS16__ ) || defined( __WIN16__ )
862 const int bufSize = length + 128;
869 printf(
"Testing %sraw-session-key encrypted enveloping of large "
870 "data quantity...\n",
874 if( ( inBufPtr = malloc( bufSize ) ) == NULL )
876 printf(
"Couldn't allocate buffer of %d bytes, skipping large "
877 "buffer enveloping test.\n", length );
880 outBufPtr = inBufPtr;
881 for( i = 0; i <
length; i++ )
882 inBufPtr[ i ] = i & 0xFF;
886 printf(
"Testing %sraw-session-key encrypted enveloping%s...\n",
888 ( useStreamCipher ) ?
" with stream cipher" : \
890 " with datasize hint" :
"" );
909 puts(
"Can't test PGP enveloping because the IDEA algorithm "
910 "isn't available in this\nbuild of cryptlib.\n" );
921 "0123456789ABCDEF", 16 );
925 if( !createEnvelope( &cryptEnvelope, formatType ) || \
929 if( useDatasize && !useLargeBuffer )
940 "0123456789ABCDEF", 16 );
947 printf(
"Addition of duplicate session key succeeded when it "
948 "should have failed,\nline %d.\n", __LINE__ );
951 puts(
" (The above message indicates that the test condition was "
952 "successfully\n checked)." );
959 count = pushData( cryptEnvelope, inBufPtr, length, NULL, 0 );
962 count = popData( cryptEnvelope, outBufPtr, bufSize );
965 if( !destroyEnvelope( cryptEnvelope ) )
969 printf(
"Enveloped data has size %d bytes.\n", count );
970 if( !useLargeBuffer )
971 debugDump( dumpFileName, outBufPtr, count );
975 if( !createDeenvelope( &cryptEnvelope ) )
980 count = pushData( cryptEnvelope, outBufPtr, count, NULL, cryptContext );
983 count = popData( cryptEnvelope, outBufPtr, bufSize );
986 if( !destroyEnvelope( cryptEnvelope ) )
990 if( count != length )
992 puts(
"De-enveloped data length != original length." );
999 for( i = 0; i <
length; i++ )
1000 if( outBufPtr[ i ] != ( i & 0xFF ) )
1002 printf(
"De-enveloped data != original data at byte %d, "
1003 "line %d.\n", i, __LINE__ );
1011 puts(
"De-enveloped data != original data." );
1017 if( useLargeBuffer )
1020 puts(
"Enveloping of raw-session-key-encrypted data succeeded.\n" );
1048 static int envelopeDecrypt(
BYTE *buffer,
const int length,
1056 if( !createDeenvelope( &cryptEnvelope ) )
1058 count = pushData( cryptEnvelope, buffer, length, NULL, cryptContext );
1061 count = popData( cryptEnvelope, buffer,
BUFFER_SIZE );
1064 if( !destroyEnvelope( cryptEnvelope ) )
1069 static int envelopeCrypt(
const char *dumpFileName,
1077 printf(
"Testing encrypted enveloping%s...\n",
1078 useDatasize ?
" with datasize hint" :
"" );
1087 "0123456789ABCDEF", 16 );
1091 if( !createEnvelope( &cryptEnvelope, formatType ) || \
1101 count = popData( cryptEnvelope, globalBuffer,
BUFFER_SIZE );
1104 if( !destroyEnvelope( cryptEnvelope ) )
1108 printf(
"Enveloped data has size %d bytes.\n", count );
1109 debugDump( dumpFileName, globalBuffer, count );
1113 count = envelopeDecrypt( globalBuffer, count, cryptContext );
1119 puts(
"De-enveloped data != original data." );
1125 puts(
"Enveloping of encrypted data succeeded.\n" );
1139 static int envelopePasswordDecrypt(
BYTE *buffer,
const int length )
1146 if( !createDeenvelope( &cryptEnvelope ) )
1148 count = pushData( cryptEnvelope, buffer, length,
TEST_PASSWORD,
1152 count = popData( cryptEnvelope, buffer,
BUFFER_SIZE );
1155 if( !destroyEnvelope( cryptEnvelope ) )
1160 static int envelopePasswordCrypt(
const char *dumpFileName,
1169 printf(
"Testing %s%spassword-encrypted enveloping%s",
1171 multiKeys ?
"multiple-" :
"",
1173 " with datasize hint" :
"" );
1177 " with non-default cipher type" :
" and stream cipher" );
1183 if( !createEnvelope( &cryptEnvelope, formatType ) || \
1199 puts(
"Warning: Couldn't set non-default envelope cipher "
1200 "RC4, this may be disabled\n in this build of "
1202 if( !destroyEnvelope( cryptEnvelope ) )
1212 sessionKeyContext );
1217 printf(
"Couldn't set non-default envelope cipher, error code "
1218 "%d, line %d.\n", status, __LINE__ );
1225 TEXT(
"Password1" ),
1228 TEXT(
"Password2" ),
1231 TEXT(
"Password3" ),
1242 count = popData( cryptEnvelope, globalBuffer,
BUFFER_SIZE );
1245 if( !destroyEnvelope( cryptEnvelope ) )
1249 printf(
"Enveloped data has size %d bytes.\n", count );
1250 debugDump( dumpFileName, globalBuffer, count );
1254 count = envelopePasswordDecrypt( globalBuffer, count );
1260 puts(
"De-enveloped data != original data." );
1265 puts(
"Enveloping of password-encrypted data succeeded.\n" );
1284 static int envelopePKCDecrypt(
BYTE *buffer,
const int length,
1290 const C_STR keysetName;
1300 if( !createDeenvelope( &cryptEnvelope ) )
1314 cryptKeyset = externalCryptKeyset;
1325 count = pushData( cryptEnvelope, buffer, length, password, 0 );
1328 count = popData( cryptEnvelope, buffer,
BUFFER_SIZE );
1331 if( !destroyEnvelope( cryptEnvelope ) )
1336 static int envelopePKCDecryptDirect(
BYTE *buffer,
const int length,
1344 if( !createDeenvelope( &cryptEnvelope ) )
1354 count = pushData( cryptEnvelope, buffer, length, NULL, cryptContext );
1358 count = popData( cryptEnvelope, buffer,
BUFFER_SIZE );
1361 if( !destroyEnvelope( cryptEnvelope ) )
1366 static int envelopePKCCrypt(
const char *dumpFileName,
1370 const BOOLEAN useMultipleKeyex,
1380 const C_STR keysetName =
TEXT(
"<None>" );
1393 puts(
"Couldn't find key files, skipping test of public-key "
1394 "encrypted enveloping..." );
1407 printf(
"Testing %spublic-key encrypted enveloping",
1409 ( ( keyFileType ==
KEYFILE_PGP ) ?
"PGP " :
"OpenPGP " ) :
"" );
1411 !( useRecipient || useMultipleKeyex || useDirectKey ) )
1412 printf(
" with datasize hint" );
1413 printf(
" using " );
1416 "PGP key" :
"raw public key" ) : \
1418 if( useRecipient && !useAltAlgo )
1419 printf(
" and recipient info" );
1420 if( useMultipleKeyex )
1421 printf(
" and additional keying info" );
1423 printf(
" and alt.encr.algo" );
1425 printf(
" and direct key add" );
1438 printf(
"Couldn't open keyset '%s', status %d, line %d.\n",
1439 keysetName, status, __LINE__ );
1449 puts(
"Read of public key from file keyset failed." );
1456 cryptKey = externalCryptContext;
1457 cryptKeyset = externalCryptKeyset;
1462 if( !createEnvelope( &cryptEnvelope, formatType ) )
1507 if( !( useRecipient || useMultipleKeyex || useDirectKey ) )
1512 printf(
"Addition of duplicate key succeeded when it "
1513 "should have failed,\nline %d.\n", __LINE__ );
1516 puts(
" (The above message indicates that the test condition "
1517 "was successfully\n checked)." );
1523 if( useMultipleKeyex && \
1534 count = popData( cryptEnvelope, globalBuffer,
BUFFER_SIZE );
1537 if( !destroyEnvelope( cryptEnvelope ) )
1541 printf(
"Enveloped data has size %d bytes.\n", count );
1542 debugDump( dumpFileName, globalBuffer, count );
1547 count = envelopePKCDecryptDirect( globalBuffer, count, keyFileType );
1549 count = envelopePKCDecrypt( globalBuffer, count, keyFileType, externalCryptKeyset );
1555 puts(
"De-enveloped data != original data." );
1560 puts(
"Enveloping of public-key encrypted data succeeded.\n" );
1568 puts(
"Skipping raw public-key and PGP enveloping, which requires "
1569 "the IDEA cipher to\nbe enabled.\n" );
1611 static int envelopeAlgoCrypt(
const char *dumpFileName,
1621 printf(
"Testing %s public-key encrypted enveloping...\n", algoName );
1637 printf(
"Unknown encryption algorithm %d, line %d.\n",
1638 cryptAlgo, __LINE__ );
1656 count = popData( cryptEnvelope, globalBuffer,
BUFFER_SIZE );
1659 if( !destroyEnvelope( cryptEnvelope ) )
1663 printf(
"%s-enveloped data has size %d bytes.\n", algoName, count );
1664 debugDump( dumpFileName, globalBuffer, count );
1668 if( !createDeenvelope( &cryptEnvelope ) )
1670 count = pushData( cryptEnvelope, globalBuffer, count, NULL,
1675 count = popData( cryptEnvelope, globalBuffer,
BUFFER_SIZE );
1678 if( !destroyEnvelope( cryptEnvelope ) )
1683 puts(
"De-enveloped data != original data." );
1688 puts(
"Enveloping of public-key encrypted data succeeded.\n" );
1710 static int getSigCheckResult(
const CRYPT_ENVELOPE cryptEnvelope,
1730 printf(
"Read of required attribute for signature check "
1731 "returned status %d, line %d.\n", status, __LINE__ );
1736 printf(
"Envelope requires unexpected enveloping information "
1737 "type %d, line %d.\n", value, __LINE__ );
1746 printf(
"Attempt to add signature check key returned status "
1747 "%d, line %d.\n", status, __LINE__ );
1756 printf(
"Signature check returned status %d, line %d.\n", status,
1763 puts(
"Signature is valid." );
1767 puts(
"Cannot find key to check signature." );
1771 puts(
"Signature is invalid." );
1775 puts(
"Warning: Couldn't verify signature due to use of a "
1776 "deprecated/insecure\n signature algorithm.\n" );
1780 printf(
"Signature check failed, result = %d, line %d.\n",
1787 static int envelopeSigCheck(
BYTE *buffer,
const int length,
1799 if( !createDeenvelope( &cryptEnvelope ) )
1810 status = addEnvInfoNumeric( cryptEnvelope,
1825 printf(
"Couldn't add externally-generated hash value to "
1826 "envelope, status %d, line %d.\n", status, __LINE__ );
1832 count = pushData( cryptEnvelope, buffer, length, NULL, 0 );
1842 count = popData( cryptEnvelope, buffer, length );
1848 if( !getSigCheckResult( cryptEnvelope, sigContext,
TRUE,
FALSE ) )
1867 printf(
"Attempt to read signature check key from PGP "
1868 "envelope succeeded when it\nshould have failed, "
1869 "line %d.\n", __LINE__ );
1881 printf(
"Couldn't retrieve signature check key from "
1882 "envelope, status %d, line %d.\n", status,
1895 printf(
"Retrieved signature check key is a private key, not "
1896 "a certificate, line %d.\n", __LINE__ );
1901 puts(
" (The above message indicates that the test "
1902 "condition was successfully\n checked)." );
1904 if( !destroyEnvelope( testEnvelope ) )
1911 if( !destroyEnvelope( cryptEnvelope ) )
1917 const char *dumpFileName,
1931 puts(
"Couldn't find key files, skipping test of signed "
1935 printf(
"Testing %ssigned enveloping%s",
1939 " with datasize hint" :
"" );
1941 printf(
" %s custom hash",
1943 printf(
" using %s",
1945 ( keyFileType ==
KEYFILE_PGP ) ?
"raw public key" : \
1946 useSuppliedKey ?
"supplied X.509 cert" :
"X.509 cert" );
1973 printf(
"Read of private key from key file failed, status %d, "
1974 "line %d, cannot test enveloping.\n", status, __LINE__ );
1981 if( !createEnvelope( &cryptEnvelope, formatType ) )
2005 printf(
"Addition of duplicate hash succeeded when it should "
2006 "have failed, line %d.\n", __LINE__ );
2009 puts(
" (The above message indicates that the test condition was "
2010 "successfully\n checked)." );
2015 if( useDatasize && !useCustomHash && \
2038 puts(
"Addition of duplicate key to envelope wasn't detected." );
2041 if( !useSuppliedKey )
2046 count = pushData( cryptEnvelope, data, dataLength, NULL, 0 );
2049 count = popData( cryptEnvelope, globalBuffer,
BUFFER_SIZE );
2052 if( !destroyEnvelope( cryptEnvelope ) )
2056 printf(
"Enveloped data has size %d bytes.\n", count );
2057 debugDump( dumpFileName, globalBuffer, count );
2061 count = envelopeSigCheck( globalBuffer, count,
CRYPT_UNUSED,
2063 keyFileType,
FALSE, formatType );
2066 if( count != dataLength || memcmp( globalBuffer, data, dataLength ) )
2068 puts(
"De-enveloped data != original data." );
2071 if( useSuppliedKey )
2078 printf(
"Attempt to destroy externally-added sig.check key "
2079 "returned %d, line %d.\n", status, __LINE__ );
2085 puts(
"Enveloping of signed data succeeded.\n" );
2092 puts(
"Skipping raw public-key based signing, which requires the "
2093 "IDEA cipher to\nbe enabled.\n" );
2120 static int envelopeAlgoSign(
const char *dumpFileName,
2125 const char *algoName = \
2131 printf(
"Testing %s signed enveloping...\n", algoName );
2152 printf(
"Unknown signature algorithm %d, line %d.\n",
2153 cryptAlgo, __LINE__ );
2171 count = popData( cryptEnvelope, globalBuffer,
BUFFER_SIZE );
2174 if( !destroyEnvelope( cryptEnvelope ) )
2178 printf(
"%s-signed data has size %d bytes.\n", algoName, count );
2179 debugDump( dumpFileName, globalBuffer, count );
2183 if( !createDeenvelope( &cryptEnvelope ) )
2185 count = pushData( cryptEnvelope, globalBuffer, count, NULL, 0 );
2187 count = popData( cryptEnvelope, globalBuffer,
BUFFER_SIZE );
2190 if( !getSigCheckResult( cryptEnvelope, sigCheckKey,
TRUE,
FALSE ) )
2193 if( !destroyEnvelope( cryptEnvelope ) )
2198 puts(
"De-enveloped data != original data." );
2203 puts(
"Enveloping of signed data succeeded.\n" );
2221 static int envelopeSignOverflow(
const void *data,
const int dataLength,
2222 const char *dumpFileName,
2224 const char *description )
2228 BYTE localBuffer[ 8192 + 4096 ];
2230 int localBufPos, bytesIn, bytesOut,
status;
2234 puts(
"Couldn't find key files, skipping test of signed "
2238 printf(
"Testing %ssigned enveloping with forced overflow in %s...\n",
2248 printf(
"Read of private key from key file failed, cannot test "
2249 "enveloping, line %d.\n", __LINE__ );
2255 if( !createEnvelope( &cryptEnvelope, formatType ) )
2271 printf(
"Couldn't set envelope parameters to force overflow, line "
2272 "%d.\n", __LINE__ );
2279 status =
cryptPushData( cryptEnvelope, data, dataLength, &bytesIn );
2282 printf(
"cryptPushData() failed with status %d, copied %d of %d "
2283 "bytes, line %d.\n", status, bytesIn, dataLength, __LINE__ );
2289 printf(
"cryptFlushData() returned status %d, should have been "
2290 "CRYPT_ERROR_OVERFLOW,\n line %d.\n", status, __LINE__ );
2293 status =
cryptPopData( cryptEnvelope, localBuffer, 8192 + 4096,
2297 printf(
"cryptPopData() #1 failed with status %d, line %d.\n",
2301 localBufPos = bytesOut;
2305 printf(
"cryptFlushData() failed with error code %d, line %d.\n",
2310 status =
cryptPopData( cryptEnvelope, localBuffer + localBufPos,
2311 8192 + 4096 - localBufPos, &bytesOut );
2314 printf(
"cryptPopData() #2 failed with status %d, line %d.\n",
2318 localBufPos += bytesOut;
2319 if( !destroyEnvelope( cryptEnvelope ) )
2323 printf(
"Enveloped data has size %d bytes.\n", localBufPos );
2324 debugDump( dumpFileName, localBuffer, localBufPos );
2328 bytesOut = envelopeSigCheck( localBuffer, localBufPos,
CRYPT_UNUSED,
2333 if( bytesOut != dataLength || memcmp( localBuffer, data, dataLength ) )
2335 puts(
"De-enveloped data != original data." );
2340 puts(
"Enveloping of signed data succeeded.\n" );
2346 BYTE buffer[ 8192 + 1024 ];
2375 memset( buffer,
'*', 8192 + 1024 );
2376 if( !envelopeSignOverflow( buffer, 8192 - 280,
"env_sigo.pgp",
CRYPT_FORMAT_PGP,
"signature" ) )
2378 if( !envelopeSignOverflow( buffer, 8384 - 6,
"env_sigo2.pgp",
CRYPT_FORMAT_PGP,
"seg.boundary" ) )
2380 if( !envelopeSignOverflow( buffer, 8192 - 1152,
"env_csgo1",
CRYPT_FORMAT_SMIME,
"signing certs" ) )
2382 return( envelopeSignOverflow( buffer, 8192 - 1280,
"env_csgo2",
CRYPT_FORMAT_SMIME,
"signature" ) );
2387 static int envelopeAuthent(
const void *data,
const int dataLength,
2390 const int corruptDataLocation )
2394 int count, integrityLevel;
2396 printf(
"Testing authenticated%s enveloping",
2397 useAuthEnc ?
"+encrypted" :
"" );
2399 printf(
" with datasize hint" );
2418 count = pushData( cryptEnvelope, data, dataLength, NULL, 0 );
2421 count = popData( cryptEnvelope, globalBuffer,
BUFFER_SIZE );
2424 if( !destroyEnvelope( cryptEnvelope ) )
2428 printf(
"Enveloped data has size %d bytes.\n", count );
2429 debugDump( useAuthEnc ?
"env_authenc" : \
2430 useDatasize ?
"env_mac" :
"env_macn", globalBuffer, count );
2436 if( corruptDataLocation > 0 )
2437 globalBuffer[ corruptDataLocation ]++;
2440 if( !createDeenvelope( &cryptEnvelope ) )
2444 count = pushData( cryptEnvelope, globalBuffer, count,
2450 puts(
" (This is an expected result since this test verifies "
2451 "handling of\n corrupted authenticated data)." );
2452 corruptionDetected =
TRUE;
2459 count = popData( cryptEnvelope, globalBuffer,
BUFFER_SIZE );
2467 &integrityLevel ) ) || \
2470 printf(
"Integrity-protected envelope is reported as having no "
2471 "integrity protection,\n line %d.\n", __LINE__ );
2477 corruptDataLocation == 0 )
2479 if( !destroyEnvelope( cryptEnvelope ) )
2483 if( corruptDataLocation == 0 )
2485 if( count != dataLength || memcmp( globalBuffer, data, dataLength ) )
2487 puts(
"De-enveloped data != original data." );
2493 if( !corruptionDetected )
2495 puts(
"Corruption of encrypted data wasn't detected." );
2501 puts(
"Enveloping of authenticated data succeeded.\n" );
2535 const BOOLEAN mustHaveAttributes,
2545 sigStatus = getSigCheckResult( cryptEnvelope, sigCheckContext,
2552 return( sigStatus );
2562 printf(
"Couldn't retrieve signer information from CMS signature, "
2563 "status = %d, line %d.\n", status, __LINE__ );
2568 puts(
"Signer information is:" );
2578 printf(
"Couldn't retrieve signature information from CMS signature, "
2579 "status = %d, line %d.\n", status, __LINE__ );
2584 puts(
"Signature information is:" );
2590 return( sigStatus );
2593 static int cmsEnvelopeSigCheck(
const void *signedData,
2594 const int signedDataLength,
2600 const BOOLEAN mustHaveAttributes,
2613 if( !createDeenvelope( &cryptEnvelope ) )
2623 printf(
"Couldn't add externally-generated hash value to "
2624 "envelope, status %d, line %d.\n", status, __LINE__ );
2628 count = pushData( cryptEnvelope, signedData, signedDataLength, NULL, 0 );
2630 !( detachedSig || hasTimestamp || checkData ) )
2635 puts(
"Warning: The hash/signature algorithm required to verify "
2636 "the signed data\n isn't enabled in this build of "
2637 "cryptlib, can't verify the\n signature." );
2638 if( !destroyEnvelope( cryptEnvelope ) )
2651 count = popData( cryptEnvelope, globalBuffer,
BUFFER_SIZE );
2671 printf(
"Use of incorrect key wasn't detected, got %d, should "
2672 "have been %d, line %d.\n", status,
2681 status = displaySigResult( cryptEnvelope, sigCheckContext,
2682 mustHaveAttributes,
TRUE );
2683 if( status ==
TRUE && hasTimestamp )
2693 printf(
"Envelope contains a timestamp..." );
2698 printf(
"\nCouldn't read timestamp from envelope, status %d, "
2699 "line %d.\n", status, __LINE__ );
2707 printf(
"\nTimestamp data envelope doesn't appear to contain a "
2708 "timestamp, line %d.\n", __LINE__ );
2711 printf(
" timestamp data appears OK.\n" );
2719 puts(
"Data has a second signature:" );
2720 status = displaySigResult( cryptEnvelope,
CRYPT_UNUSED,
2721 mustHaveAttributes,
FALSE );
2728 puts(
"Data appears to have (nonexistent) third signature." );
2736 puts(
"De-enveloped data != original data." );
2741 if( !destroyEnvelope( cryptEnvelope ) )
2746 static int cmsEnvelopeSign(
const BOOLEAN useDatasize,
2760 puts(
"Couldn't find key files, skipping test of CMS signed "
2764 printf(
"Testing %s %s%s", isPGP ?
"PGP" :
"CMS",
2765 useExtAttributes ?
"extended " :
"",
2766 detachedSig ?
"detached signature" : \
2767 dualSig ?
"dual signature" :
"signed enveloping" );
2768 if( useNonDataContent )
2769 printf(
" of non-data content" );
2770 if( useExternalHash )
2771 printf(
" with externally-supplied hash" );
2772 if( !useAttributes )
2773 printf(
" without signing attributes" );
2774 if( useDatasize && \
2775 !( useNonDataContent || useAttributes || useExtAttributes || \
2776 detachedSig || useTimestamp ) )
2779 printf(
" with datasize hint" );
2782 printf(
" and timestamp" );
2789 cryptContext = externalSignContext;
2796 puts(
"Read of private key from key file failed, cannot test "
2797 "CMS enveloping." );
2807 puts(
"Read of private key from key file failed, cannot test "
2808 "CMS enveloping." );
2815 if( !createEnvelope( &cryptEnvelope, formatType ) || \
2823 if( ( externalSignContext ==
CRYPT_UNUSED ) && !isPGP )
2827 if( useNonDataContent )
2844 #ifdef USE_CMS_OBSCURE
2855 TEXT(
"1 3 6 1 4 1 9999 1" ),
2864 TEXT(
"1 3 6 1 4 1 9999 2" ),
2869 "\x04\x04\x01\x02\x03\x04", 6 );
2873 "This signature isn't worth the paper it's not "
2902 return(
attrErrorExit( cryptSession,
"cryptSetAttributeString()",
2903 status, __LINE__ ) );
2910 printf(
"cryptSetAttribute() failed with error code %d, line %d.\n",
2916 if( !useAttributes )
2930 puts(
"Envelope timestamping failed due to problems talking to "
2931 "TSA, this is a non-\ncritical problem. Continuing...\n" );
2937 count = popData( cryptEnvelope, globalBuffer,
BUFFER_SIZE );
2940 if( !destroyEnvelope( cryptEnvelope ) )
2944 printf(
"%s %s has size %d bytes.\n", isPGP ?
"PGP" :
"CMS",
2945 ( detachedSig ) ?
"detached signature" :
"signed data",
2949 ( useDatasize ?
"smi_dsg" :
"smi_dsgn" ) : \
2951 useExtAttributes ? \
2952 ( useDatasize ?
"smi_esg" :
"smi_esgn" ) : \
2954 ( useDatasize ?
"smi_tsg" :
"smi_tsgn" ) : \
2955 useNonDataContent ? \
2956 ( useDatasize ?
"smi_ndc" :
"smi_ndcn" ) : \
2958 ( useDatasize ?
"smi_2sg" :
"smi_n2sg" ) : \
2959 useDatasize ?
"smi_sig" :
"smi_sign", globalBuffer, count );
2962 if( useExternalHash )
2973 puts(
"Couldn't create external hash of data." );
2981 status = cmsEnvelopeSigCheck( globalBuffer, count,
2984 useAttributes, useNonDataContent ? \
2995 printf(
"Creation of %s %sdetached signature %ssucceeded.\n\n",
2996 isPGP ?
"PGP" :
"CMS", useExtAttributes ?
"extended " :
"",
2998 "with externally-supplied hash " :
"" );
3002 printf(
"Enveloping of CMS %s%ssigned data succeeded.\n\n",
3003 useExtAttributes ?
"extended " :
"",
3004 useTimestamp ?
"timestamped " :
"" );
3053 static int cmsImportSignedData(
const char *fileName,
const int fileNo )
3055 BYTE *bufPtr = globalBuffer;
3056 char msgBuffer[ 128 ];
3060 count = getFileSize( fileName ) + 10;
3063 if( ( bufPtr = malloc( count ) ) == NULL )
3065 printf(
"Couldn't allocate test buffer of %d bytes, line %d.\n",
3070 sprintf( msgBuffer,
"S/MIME SignedData #%d", fileNo );
3071 count = readFileData( fileName, msgBuffer, bufPtr, count );
3074 if( bufPtr != globalBuffer )
3083 if( bufPtr != globalBuffer )
3086 puts(
"S/MIME SignedData import succeeded.\n" );
3092 puts(
"AuthentiCode SignedData import succeeded but signature "
3093 "couldn't be verified\n due to AuthentiCode special "
3094 "processing requirements.\n" );
3102 static int cmsEnvelopeDecrypt(
const void *envelopedData,
3103 const int envelopedDataLength,
3105 const C_STR externalPassword,
3106 const BOOLEAN checkDataMatch )
3112 if( !createDeenvelope( &cryptEnvelope ) )
3115 status = addEnvInfoNumeric( cryptEnvelope,
3125 status = addEnvInfoNumeric( cryptEnvelope,
3133 count = pushData( cryptEnvelope, envelopedData, envelopedDataLength,
3135 externalPassword, 0 );
3138 count = popData( cryptEnvelope, globalBuffer,
BUFFER_SIZE );
3141 if( !destroyEnvelope( cryptEnvelope ) )
3147 if( !checkDataMatch )
3154 puts(
"De-enveloped data != original data." );
3161 static int cmsEnvelopeCrypt(
const char *dumpFileName,
3163 const BOOLEAN useStreamCipher,
3164 const BOOLEAN useLargeBlockCipher,
3165 const BOOLEAN useExternalRecipientKeyset,
3168 const C_STR externalPassword,
3169 const C_STR recipientName )
3177 puts(
"Couldn't find key files, skipping test of CMS encrypted "
3181 printf(
"Testing CMS public-key encrypted enveloping" );
3182 if( externalKeyset !=
CRYPT_UNUSED && recipientName != NULL )
3184 if( useExternalRecipientKeyset )
3185 printf(
" with recipient keys in device" );
3187 printf(
" with dual encr./signing certs" );
3191 if( useStreamCipher )
3192 printf(
" with stream cipher" );
3195 if( useLargeBlockCipher )
3196 printf(
" with large block size cipher" );
3200 printf(
" with datasize hint" );
3216 puts(
"Couldn't determine algorithm for public key, cannot test "
3217 "CMS enveloping." );
3220 cryptKey = externalCryptContext;
3224 if( recipientName == NULL )
3234 printf(
"Recipient keyset open failed with status %d, "
3235 "line %d.\n", status, __LINE__ );
3244 printf(
"Read of public key from key file failed with "
3245 "status %d, line %d.\n", status, __LINE__ );
3256 if( recipientName != NULL )
3262 if( !useExternalRecipientKeyset )
3270 printf(
"Couldn't open key database, status %d, line %d.\n",
3278 if( !useExternalRecipientKeyset )
3290 if( externalCryptContext ==
CRYPT_UNUSED && recipientName == NULL )
3299 count = popData( cryptEnvelope, globalBuffer,
BUFFER_SIZE );
3302 if( !destroyEnvelope( cryptEnvelope ) )
3306 printf(
"Enveloped data has size %d bytes.\n", count );
3307 debugDump( dumpFileName, globalBuffer, count );
3310 status = cmsEnvelopeDecrypt( globalBuffer, count, externalKeyset,
3311 externalPassword,
TRUE );
3316 puts(
"Enveloping of CMS public-key encrypted data succeeded.\n" );
3320 static int cmsImportEnvelopedData(
const char *fileName,
const int fileNo )
3323 BYTE *bufPtr = globalBuffer;
3324 char msgBuffer[ 128 ];
3325 int count, bytesIn, byteCount = 0,
status;
3328 count = getFileSize( fileName ) + 10;
3331 if( ( bufPtr = malloc( count ) ) == NULL )
3333 printf(
"Couldn't allocate test buffer of %d bytes, lin e%d.\n",
3338 sprintf( msgBuffer,
"S/MIME EnvelopedData #%d", fileNo );
3339 count = readFileData( fileName, msgBuffer, bufPtr, count );
3342 if( bufPtr != globalBuffer )
3348 if( !createDeenvelope( &cryptEnvelope ) )
3350 if( bufPtr != globalBuffer )
3354 status =
cryptPushData( cryptEnvelope, bufPtr, count, &bytesIn );
3357 byteCount += bytesIn;
3359 count - byteCount, &bytesIn );
3361 if( !destroyEnvelope( cryptEnvelope ) )
3363 if( bufPtr != globalBuffer )
3374 printf(
"Couldn't de-envelope data, status = %d, line %d.\n",
3379 puts(
"S/MIME EnvelopedData import succeeded.\n" );
3413 const C_STR password,
const C_STR recipient )
3417 assert( ( encryptContext !=
CRYPT_UNUSED && recipient == NULL ) || \
3418 ( encryptContext ==
CRYPT_UNUSED && recipient != NULL ) );
3425 encryptContext, decryptKeyset, password, \
3429 puts(
" (This is probably because the public key certificate was "
3430 "regenerated after\n the certificate stored with the "
3431 "private key was created, so that the\n private key can't "
3432 "be identified any more using the public key that was\n "
3433 "used for encryption. This can happen when the cryptlib "
3434 "self-test is run\n in separate stages, with one stage "
3435 "re-using data that was created\n earlier during a "
3436 "previous stage)." );
3455 puts(
"The certificate database wasn't updated with dual encryption/"
3456 "signing certs\nduring this test run (either because database "
3457 "keysets aren't enabled in this\nbuild of cryptlib or because "
3458 "only some portions of the self-tests are being\nrun), "
3459 "skipping the test of CMS enveloping with dual certs.\n" );
3471 puts(
"Couldn't find keyset with dual encryption/signature certs "
3472 "for test of dual certificate\nencryption." );
3482 puts(
" (This is probably because the public key certificate was "
3483 "regenerated after\n the certificate stored with the "
3484 "private key was created, so that the\n private key can't "
3485 "be identified any more using the public key that was\n "
3486 "used for encryption. This can happen when the cryptlib "
3487 "self-test is run\n in separate stages, with one stage "
3488 "re-using data that was created\n earlier during a "
3489 "previous stage)." );
3512 if( ( filePtr = fopen( fileName,
"rb" ) ) == NULL )
3514 puts(
"Couldn't find S/MIME SignedData file, skipping test of "
3515 "SignedData import..." );
3523 for( i = 1; i <= 3; i++ )
3526 if( !cmsImportSignedData( fileName, i ) && i != 2 )
3533 puts(
"Import of S/MIME SignedData succeeded.\n" );
3549 if( ( filePtr = fopen( fileName,
"rb" ) ) == NULL )
3551 puts(
"Couldn't find S/MIME EnvelopedData file, skipping test of "
3552 "EnvelopedData import..." );
3560 for( i = 1; i <= 1; i++ )
3563 if( !cmsImportEnvelopedData( fileName, i ) )
3567 puts(
"Import of S/MIME EnvelopedData succeeded.\n" );
3583 if( ( filePtr = fopen( fileName,
"rb" ) ) == NULL )
3585 puts(
"Couldn't find CMS EnvelopedData file, skipping test of "
3586 "EnvelopedData/AuthentcatedData import..." );
3596 for( i = 1; i <= 2; i++ )
3601 count = readFileData( fileName,
"CMS password-encrypted/authd data",
3605 if( !cmsEnvelopeDecrypt( globalBuffer, count,
CRYPT_UNUSED,
3610 puts(
"Import of CMS password-encrypted/authenticated data "
3627 count = readFileData( fileName,
"PGP password-encrypted data",
3631 count = envelopePasswordDecrypt( globalBuffer, count );
3638 puts(
"De-enveloped data != original data." );
3641 puts(
"Import of PGP password-encrypted data succeeded." );
3653 count = readFileData( fileName,
"OpenPGP password-encrypted data",
3657 if( !envelopePasswordDecrypt( globalBuffer, count ) )
3662 puts(
"De-enveloped data != original data." );
3666 count = readFileData( fileName,
"OpenPGP password-encrypted data",
3670 if( !envelopePasswordDecrypt( globalBuffer, count ) )
3675 puts(
"De-enveloped data != original data." );
3678 puts(
"Import of OpenPGP password-encrypted data succeeded.\n" );
3692 count = readFileData( fileName,
"PGP-encrypted data", globalBuffer,
3696 count = envelopePKCDecrypt( globalBuffer, count,
KEYFILE_PGP,
3704 puts(
"De-enveloped data != original data." );
3708 count = readFileData( fileName,
"PGP (NAI)-encrypted data", globalBuffer,
3716 if( globalBuffer[ 0 ] != 0xA3 || globalBuffer[ 1 ] != 0x01 || \
3717 globalBuffer[ 2 ] != 0x5B || globalBuffer[ 3 ] != 0x53 )
3719 puts(
"De-enveloped data != original data." );
3722 puts(
"Import of PGP-encrypted data succeeded." );
3753 count = readFileData( fileName,
"OpenPGP (GPG)-encrypted data",
3757 count = envelopePKCDecrypt( globalBuffer, count,
KEYFILE_PGP,
3765 puts(
"De-enveloped data != original data." );
3769 count = readFileData( fileName,
"OpenPGP (GPG)-encrypted data with "
3781 puts(
"De-enveloped data != original data." );
3785 count = readFileData( fileName,
"OpenPGP (GPG)-encrypted data with "
3797 puts(
"De-enveloped data != original data." );
3802 count = readFileData( fileName,
"OpenPGP (GPG)-encrypted data with "
3810 count = envelopeDecompress( globalBuffer,
BUFFER_SIZE, count );
3813 if( count < 600 || memcmp( globalBuffer,
"\n\n<sect>Vorwort\n", 16 ) )
3815 puts(
"De-enveloped data != original data." );
3819 puts(
"Import of OpenPGP-encrypted data succeeded.\n" );
3836 count = readFileData( fileName,
"PGP-signed data", globalBuffer,
3840 count = envelopeSigCheck( globalBuffer, count,
CRYPT_UNUSED,
3849 puts(
"De-enveloped data != original data." );
3852 puts(
"Import of PGP-signed data succeeded." );
3865 count = readFileData( fileName,
"PGP 2.x/OpenPGP-hybrid-signed data",
3869 count = envelopeSigCheck( globalBuffer, count,
CRYPT_UNUSED,
3878 puts(
"De-enveloped data != original data." );
3881 puts(
"Import of PGP 2.x/OpenPGP-hybrid-signed data succeeded." );
3891 count = readFileData( fileName,
"OpenPGP-signed data",
3895 count = envelopeSigCheck( globalBuffer, count,
CRYPT_UNUSED,
3904 puts(
"De-enveloped data != original data." );
3907 puts(
"Import of OpenPGP-signed data succeeded." );
3927 puts(
"Couldn't create external hash of data." );
3931 count = readFileData( fileName,
"OpenPGP-signed data with "
3932 "externally-supplied hash", globalBuffer,
3936 count = envelopeSigCheck( globalBuffer, count, hashContext,
3942 puts(
"Import of OpenPGP-signed data with externally-supplied hash "
3959 puts(
"Couldn't allocate test buffer." );
3965 count = readFileData( fileName,
"PGP 2.x compressed data",
3976 puts(
"De-enveloped data != original data." );
3985 puts(
"Import of PGP 2.x compressed data succeeded.\n" );
3996 count = readFileData( fileName,
"OpenPGP compressed signed data",
4005 ( bufPtr[ 0 ] != 0x90 || bufPtr[ 1 ] != 0x0D || \
4006 bufPtr[ 2 ] != 0x03 || bufPtr[ 3 ] != 0x00 ) )
4008 puts(
"De-enveloped data != original data." );
4017 memcpy( globalBuffer, bufPtr, count );
4019 count = envelopeSigCheck( globalBuffer, count,
CRYPT_UNUSED,
4027 puts(
"De-enveloped data != original data." );
4030 puts(
"Import of OpenPGP compressed signed data succeeded.\n" );
4039 static void dataImport(
void *buffer,
const int length,
4045 createDeenvelope( &cryptEnvelope );
4046 count = pushData( cryptEnvelope, buffer, length, NULL, 0 );
4053 count = popData( cryptEnvelope, buffer, length );
4055 destroyEnvelope( cryptEnvelope );
4060 BYTE *bufPtr = globalBuffer;
4063 count = getFileSize( fileName ) + 10;
4065 ( bufPtr = malloc( count ) ) == NULL )
4070 count = readFileData( fileName,
"Generic test data", bufPtr, count );
4071 assert( count > 0 );
4072 dataImport( bufPtr, count,
FALSE );
4073 if( bufPtr != globalBuffer )
4079 BYTE *bufPtr = globalBuffer;
4082 count = getFileSize( fileName ) + 10;
4084 ( bufPtr = malloc( count ) ) == NULL )
4089 count = readFileData( fileName,
"S/MIME test data", bufPtr, count );
4090 assert( count > 0 );
4093 assert( status > 0 );
4094 if( bufPtr != globalBuffer )
4102 count = getFileSize( fileName ) + 10;
4105 count = readFileData( fileName,
"S/MIME test data", globalBuffer,
4107 assert( count > 0 );
4108 status = cmsEnvelopeDecrypt( globalBuffer, count,
CRYPT_UNUSED, NULL,
4110 assert( status > 0 );
4113 void xxxEnvelopeTest(
void )