/****************************************************************************
*																			*
*							cryptlib Test Key Load Code						*
*						Copyright Peter Gutmann 1995-2020					*
*																			*
****************************************************************************/

#include "cryptlib.h"
#include "test/test.h"

/* Various features can be disabled by configuration options, in order to 
   handle this we need to include the cryptlib config file so that we can 
   selectively disable some tests.
   
   The following include is necessary in case CONFIG_PKC_ALLOCSIZE has been
   set in misc/config.h rather than during the build, since it controls
   CRYPT_MAX_PKCSIZE */
#include "misc/config.h"	/* For key size */

#if defined( __MVS__ ) || defined( __VMCMS__ )
  /* Suspend conversion of literals to ASCII */
  #pragma convlit( suspend )
#endif /* IBM big iron */
#if defined( __ILEC400__ )
  #pragma convert( 0 )
#endif /* IBM medium iron */

/****************************************************************************
*																			*
*									Key Data								*
*																			*
****************************************************************************/

/* The keys for testing the RSA, DLP( DSA, DH, and Elgamal), and ECDLP 
   (ECDSA and ECDH) implementations.  The key values can be extracted with 
   the following code pasted into the generateKey() function in 
   ctx_dsa.c/ctx_ecc.c/ctx_rsa.c */

#if 0	/* RSA */
{
#include <stdio.h>

BYTE buffer[ CRYPT_MAX_PKCSIZE ];
int length, i;

printf( "static const RSA_KEY rsa%dKey = {\n", keyBits );
length = BN_bn2bin( &contextInfoPtr->ctxPKC->rsaParam_n, buffer );
printf( "\t/* n */\n\t%d,\n\t{ ", BN_num_bits( &contextInfoPtr->ctxPKC->rsaParam_n ) );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
length = BN_bn2bin( &contextInfoPtr->ctxPKC->rsaParam_e, buffer );
printf( "},\n\t/* e */\n\t%d,\n\t{ ", BN_num_bits( &contextInfoPtr->ctxPKC->rsaParam_e ) );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
length = BN_bn2bin( &contextInfoPtr->ctxPKC->rsaParam_d, buffer );
printf( "},\n\t/* d */\n\t%d,\n\t{ ", BN_num_bits( &contextInfoPtr->ctxPKC->rsaParam_d ) );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
length = BN_bn2bin( &contextInfoPtr->ctxPKC->rsaParam_p, buffer );
printf( "},\n\t/* p */\n\t%d,\n\t{ ", BN_num_bits( &contextInfoPtr->ctxPKC->rsaParam_p ) );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
length = BN_bn2bin( &contextInfoPtr->ctxPKC->rsaParam_q, buffer );
printf( "},\n\t/* q */\n\t%d,\n\t{ ", BN_num_bits( &contextInfoPtr->ctxPKC->rsaParam_q ) );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
length = BN_bn2bin( &contextInfoPtr->ctxPKC->rsaParam_u, buffer );
printf( "},\n\t/* u */\n\t%d,\n\t{ ", BN_num_bits( &contextInfoPtr->ctxPKC->rsaParam_u ) );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
length = BN_bn2bin( &contextInfoPtr->ctxPKC->rsaParam_exponent1, buffer );
printf( "},\n\t/* exponent1 */\n\t%d,\n\t{ ", BN_num_bits( &contextInfoPtr->ctxPKC->rsaParam_exponent1 ) );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
length = BN_bn2bin( &contextInfoPtr->ctxPKC->rsaParam_exponent2, buffer );
printf( "},\n\t/* exponent2 */\n\t%d,\n\t{ ", BN_num_bits( &contextInfoPtr->ctxPKC->rsaParam_exponent2 ) );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
puts( "}\n\t};" );
fflush( stdout );
}
#endif
#if 0	/* DLP */
{
#include <stdio.h>

BYTE buffer[ CRYPT_MAX_PKCSIZE ];
int length, i;

printf( "static const DLP_KEY dlp%dKey = {\n", keyBits );
length = BN_bn2bin( &contextInfoPtr->ctxPKC->dlpParam_p, buffer );
printf( "\t/* p */\n\t%d,\n\t{ ", BN_num_bits( &contextInfoPtr->ctxPKC->dlpParam_p ) );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
length = BN_bn2bin( &contextInfoPtr->ctxPKC->dlpParam_q, buffer );
printf( "},\n\t/* q */\n\t%d,\n\t{ ", BN_num_bits( &contextInfoPtr->ctxPKC->dlpParam_q ) );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
length = BN_bn2bin( &contextInfoPtr->ctxPKC->dlpParam_g, buffer );
printf( "},\n\t/* g */\n\t%d,\n\t{ ", BN_num_bits( &contextInfoPtr->ctxPKC->dlpParam_g ) );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
length = BN_bn2bin( &contextInfoPtr->ctxPKC->dlpParam_x, buffer );
printf( "},\n\t/* x */\n\t%d,\n\t{ ", BN_num_bits( &contextInfoPtr->ctxPKC->dlpParam_x ) );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
length = BN_bn2bin( &contextInfoPtr->ctxPKC->dlpParam_y, buffer );
printf( "},\n\t/* y */\n\t%d,\n\t{ ", BN_num_bits( &contextInfoPtr->ctxPKC->dlpParam_y ) );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
puts( "}\n\t};" );
fflush( stdout );
}
#endif
#if 0	/* ECC */
{
#include <stdio.h>

BYTE buffer[ CRYPT_MAX_PKCSIZE ];
int length, i;

printf( "static const ECC_KEY ecdlpP%dKey = {\n", keySizeBits );
length = BN_bn2bin( &contextInfoPtr->ctxPKC->eccParam_qx, buffer );
printf( "\t/* qx */\n\t%d,\n\t{ ", keySizeBits );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
length = BN_bn2bin( &contextInfoPtr->ctxPKC->eccParam_qy, buffer );
printf( "},\n\t/* qy */\n\t%d,\n\t{ ", keySizeBits );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
length = BN_bn2bin( &contextInfoPtr->ctxPKC->eccParam_d, buffer );
printf( "},\n\t/* d */\n\t%d,\n\t{ ", keySizeBits );
for( i = 0; i < length; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != length - 1 ) ? "0x%02X, " : "0x%02X ", buffer[ i ] ); }
puts( "}\n\t};" );
fflush( stdout );
}
#endif
#if 0	/* ML-KEM */
{
#include <stdio.h>

int i;

printf( "static const MLKEM_KEY mlKemTestKey = {\n" );
printf( "\t/* pub */\n\t%d,\n\t{ ", bytesToBits( MLKEM768_PUBLICKEYBYTES ) );
for( i = 0; i < MLKEM768_PUBLICKEYBYTES; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != MLKEM768_PUBLICKEYBYTES - 1 ) ? "0x%02X, " : "0x%02X ", 
			mlkemKey->pubKey[ i ] ); }
printf( "},\n\t/* priv */\n\t%d,\n\t{ ", bytesToBits( MLKEM768_SECRETKEYBYTES ) );
for( i = 0; i < MLKEM768_SECRETKEYBYTES; i++ )
	{ if( i && !( i % 8 ) ) printf( "\n\t  " );
	printf( ( i != MLKEM768_SECRETKEYBYTES - 1 ) ? "0x%02X, " : "0x%02X ", 
			mlkemKey->privKey[ i ] ); }
puts( "}\n\t};" );
fflush( stdout );
}
#endif

typedef struct {
	const int nLen; const BYTE n[ 256 ];
	const int eLen; const BYTE e[ 3 ];
	const int dLen; const BYTE d[ 256 ];
	const int pLen; const BYTE p[ 128 ];
	const int qLen; const BYTE q[ 128 ];
	const int uLen; const BYTE u[ 128 ];
	const int e1Len; const BYTE e1[ 128 ];
	const int e2Len; const BYTE e2[ 128 ];
	} RSA_KEY;

static const RSA_KEY rsa1024TestKey = {
	/* n */
	1024,
	{ 0x9C, 0x4D, 0x98, 0x18, 0x67, 0xF9, 0x45, 0xBC,
	  0xB6, 0x75, 0x53, 0x5D, 0x2C, 0xFA, 0x55, 0xE4,
	  0x51, 0x54, 0x9F, 0x0C, 0x16, 0xB1, 0xAF, 0x89,
	  0xF6, 0xF3, 0xE7, 0x78, 0xB1, 0x2B, 0x07, 0xFB,
	  0xDC, 0xDE, 0x64, 0x23, 0x34, 0x87, 0xDA, 0x0B,
	  0xE5, 0xB3, 0x17, 0x16, 0xA4, 0xE3, 0x7F, 0x23,
	  0xDF, 0x96, 0x16, 0x28, 0xA6, 0xD2, 0xF0, 0x0A,
	  0x59, 0xEE, 0x06, 0xB3, 0x76, 0x6C, 0x64, 0x19,
	  0xD9, 0x76, 0x41, 0x25, 0x66, 0xD1, 0x93, 0x51,
	  0x52, 0x06, 0x6B, 0x71, 0x50, 0x0E, 0xAB, 0x30,
	  0xA5,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
	  0xA8, 0x58, 0xA7, 0xEB, 0x39, 0x79, 0x56, 0x41 },

	/* p */
	512,
	{ 0xCF, 0xDA, 0xF9, 0x99, 0x6F, 0x05, 0x95, 0x84,
	  0x09, 0x90, 0xB3, 0xAB, 0x39, 0xB7, 0xDD, 0x1D,
	  0x7B, 0xFC, 0xFD, 0x10, 0x35, 0xA0, 0x18, 0x1D,
	  0x9A, 0x11, 0x30, 0x90, 0xD4, 0x3B, 0xF0, 0x5A,
	  0xC1, 0xA6, 0xF4, 0x53, 0xD0, 0x94, 0xA0, 0xED,
	  0xE0, 0xE4, 0xE0, 0x8E, 0x44, 0x18, 0x42, 0x42,
	  0xE1, 0x2C, 0x0D, 0xF7, 0x30, 0xE2, 0xB8, 0x09,
	  0x73, 0x50, 0x28, 0xF6, 0x55, 0x85, 0x57, 0x03 },

	/* q */
	512,
	{ 0xC0, 0x81, 0xC4, 0x82, 0x6E, 0xF6, 0x1C, 0x92,
	  0x83, 0xEC, 0x17, 0xFB, 0x30, 0x98, 0xED, 0x6E,
	  0x89, 0x92, 0xB2, 0xA1, 0x21, 0x0D, 0xC1, 0x95,
	  0x49, 0x99, 0xD3, 0x79, 0xD3, 0xBD, 0x94, 0x93,
	  0xB9, 0x28, 0x68, 0xFF, 0xDE, 0xEB, 0xE8, 0xD2,
	  0x0B, 0xED, 0x7C, 0x08, 0xD0, 0xD5, 0x59, 0xE3,
	  0xC1, 0x76, 0xEA, 0xC1, 0xCD, 0xB6, 0x8B, 0x39,
	  0x4E, 0x29, 0x59, 0x5F, 0xFA, 0xCE, 0x83, 0xA5 },

	/* u */
	511,
	{ 0x4B, 0x87, 0x97, 0x1F, 0x27, 0xED, 0xAA, 0xAF,
	  0x42, 0xF4, 0x57, 0x82, 0x3F, 0xEC, 0x80, 0xED,
	  0x1E, 0x91, 0xF8, 0xB4, 0x33, 0xDA, 0xEF, 0xC3,
	  0x03, 0x53, 0x0F, 0xCE, 0xB9, 0x5F, 0xE4, 0x29,
	  0xCC, 0xEE, 0x6A, 0x5E, 0x11, 0x0E, 0xFA, 0x66,
	  0x85, 0xDC, 0xFC, 0x48, 0x31, 0x0C, 0x00, 0x97,
	  0xC6, 0x0A, 0xF2, 0x34, 0x60, 0x6B, 0xF7, 0x68,
	  0x09, 0x4E, 0xCF, 0xB1, 0x9E, 0x33, 0x9A, 0x41 },

	/* exponent1 */
	511,
	{ 0x6B, 0x2A, 0x0D, 0xF8, 0x22, 0x7A, 0x71, 0x8C,
	  0xE2, 0xD5, 0x9D, 0x1C, 0x91, 0xA4, 0x8F, 0x37,
	  0x0D, 0x5E, 0xF1, 0x26, 0x73, 0x4F, 0x78, 0x3F,
	  0x82, 0xD8, 0x8B, 0xFE, 0x8F, 0xBD, 0xDB, 0x7D,
	  0x1F, 0x4C, 0xB1, 0xB9, 0xA8, 0xD7, 0x88, 0x65,
	  0x3C, 0xC7, 0x24, 0x53, 0x95, 0x1E, 0x20, 0xC3,
	  0x94, 0x8E, 0x7F, 0x20, 0xCC, 0x2E, 0x88, 0x0E,
	  0x2F, 0x4A, 0xCB, 0xE3, 0xBD, 0x52, 0x02, 0xFB },

	/* exponent2 */
	509,
	{ 0x10, 0x27, 0xD3, 0xD2, 0x0E, 0x75, 0xE1, 0x17,
	  0xFA, 0xB2, 0x49, 0xA0, 0xEF, 0x07, 0x26, 0x85,
	  0xEC, 0x4D, 0xBF, 0x67, 0xFE, 0x5A, 0x25, 0x30,
	  0xDE, 0x28, 0x66, 0xB3, 0x06, 0xAE, 0x16, 0x55,
	  0xFF, 0x68, 0x00, 0xC7, 0xD8, 0x71, 0x7B, 0xEC,
	  0x84, 0xCB, 0xBD, 0x69, 0x0F, 0xFD, 0x97, 0xB9,
	  0xA1, 0x76, 0xD5, 0x64, 0xC6, 0x5A, 0xD7, 0x7C,
	  0x4B, 0xAE, 0xF4, 0xAD, 0x35, 0x63, 0x37, 0x71 }
	};

static const RSA_KEY rsa2048TestKey = {
	/* n */
	2048,
	{ 0xBC, 0xB9, 0x69, 0xB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xBB, 
	  0x49, 0x1C, 0x99, 0x4D, 0x63, 0xC3, 0x47, 0xE8, 
	  0xE9, 0x75, 0x08, 0xD0, 0xE2, 0x9D, 0xA6, 0x56, 
	  0x64, 0x7D, 0xCE, 0x62, 0x7B, 0xE9, 0x4E, 0xE5, 
	  0x25, 0xA2, 0xAF, 0x36, 0xC4, 0x95, 0x17, 0xA5, 
	  0xE9, 0x52, 0x0D, 0xF6, 0x29, 0x1E, 0xAE, 0xC5, 
	  0x6C, 0x43, 0x00, 0x02, 0xE3, 0x03, 0xE5, 0x2C, 
	  0x12, 0x63, 0x7E, 0x5E, 0x97, 0x93, 0x7D, 0x35, 
	  0xBB, 0x58, 0xD0, 0xD1, 0x74, 0x3B, 0xC0, 0x2D, 
	  0x86, 0x66, 0x1B, 0x81, 0x45, 0x64, 0xE5, 0xE0, 
	  0xAC, 0x39, 0x22, 0xEA, 0x25, 0x5B, 0x7D, 0x41 }, 

	/* e */
	17,
	{ 0x01, 0x00, 0x01 }, 

	/* d */
	2047,
	{ 0x4A, 0x93, 0x15, 0xD7, 0x06, 0x76, 0xDD, 0x68, 
	  0xBA, 0x33, 0xAF, 0x91, 0x47, 0x51, 0x99, 0x69, 
	  0x86, 0x2E, 0x56, 0x97, 0x5E, 0xB4, 0x73, 0xAB, 
	  0x29, 0x0E, 0xE7, 0xA1, 0x9D, 0xDF, 0x26, 0xF5, 
	  0xC1, 0x60, 0x7B, 0x01, 0x36, 0x32, 0x5F, 0x0C, 
	  0x70, 0x22, 0x71, 0x9E, 0xC9, 0x8C, 0xB0, 0xE2, 
	  0x92, 0xCD, 0x09, 0x3A, 0x50, 0x9C, 0x4C, 0x11, 
	  0x99, 0xE7, 0x6D, 0x7A, 0x5A, 0xFA, 0xAF, 0xD8, 
	  0xAA, 0x41, 0xBA, 0xC2, 0xA3, 0x9F, 0x9E, 0x88, 
	  0xB5, 0x45, 0x58, 0x16, 0x12, 0xEE, 0x50, 0xAF, 
	  0x0F, 0x33, 0x42, 0x55,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0x6C, 0x7D, 0xF6, 0x9D, 0xCC, 
	  0x45, 0x6C, 0x01, 0xE3, 0x1A, 0x7F, 0x01, 0x41 }, 

	/* exponent2 */
	1022,
	{ 0x32, 0x07, 0x93, 0xF4, 0x5C, 0x0A, 0x0D, 0x6E, 
	  0x96, 0x89, 0xB5, 0x98, 0x6C, 0xFF, 0xC5, 0x28, 
	  0x61, 0x0D, 0xCE, 0x5C, 0xB6, 0x60, 0x56, 0xFC, 
	  0xD0, 0x20, 0x30, 0xDD, 0x30, 0x02, 0x1F, 0x6A, 
	  0x7C, 0xFA, 0x07, 0x4E, 0x83, 0x41, 0xAD, 0x3D, 
	  0x72, 0x73, 0x01, 0x14, 0xE9, 0x40, 0x21, 0xAC, 
	  0x57, 0x4F, 0xA6, 0xC0, 0x0E, 0x0F, 0xD5, 0xE8, 
	  0x5F, 0xD6, 0x8E, 0x5B, 0x9C, 0xF0, 0x36, 0x2B, 
	  0x1E, 0xAF, 0xDF, 0x83, 0xF5, 0x7B, 0xC3, 0x9D, 
	  0xBB, 0x37, 0x20, 0xB7, 0x4F, 0x8D, 0xBB, 0xDE, 
	  0x39, 0xD7, 0xC1, 0x77, 0xD4, 0xBE, 0xDA, 0x40, 
	  0x6D, 0xEA, 0x83, 0xB0, 0x5B, 0xE2, 0x1C, 0xDB, 
	  0x1A, 0x97, 0xC0, 0x03, 0xA8, 0xF5, 0x58, 0xC7, 
	  0x91, 0x69, 0x6F, 0xBE, 0x07, 0xD2, 0x42, 0x9C, 
	  0xEE, 0x9E, 0x22, 0x74, 0x2D, 0x1F, 0x1C, 0x5D, 
	  0xCC, 0xFE, 0x40, 0x49, 0x11, 0x5F, 0x5D, 0xC1 }
	};

typedef struct {
	const int pLen; const BYTE p[ 128 ];
	const int qLen; const BYTE q[ 20 ];
	const int gLen; const BYTE g[ 128 ];
	const int xLen; const BYTE x[ 20 ];
	const int yLen; const BYTE y[ 128 ];
	} DLP_KEY;

static const DLP_KEY dlp1024TestKey = {
	/* p */
	1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41, 0x7F, 0xA2, 0xC5, 
	  0x48, 0x26, 0xB7, 0xF6, 0xC2, 0x6F, 0xB2, 0xF8, 
	  0xF9, 0x43, 0x43, 0xF9, 0xDA, 0xAB, 0xA2, 0x59, 
	  0x27, 0xBA, 0xC9, 0x1C, 0x8C, 0xAB, 0xC4, 0x90, 
	  0x27, 0xE1, 0x10, 0x39, 0x6F, 0xD2, 0xCD, 0x7C, 
	  0xD1, 0x0B, 0xFA, 0x28, 0xD2, 0x7A, 0x7B, 0x52, 
	  0x8A, 0xA0, 0x5A, 0x0F, 0x10, 0xF7, 0xBA, 0xFD, 
	  0x33, 0x0C, 0x3C, 0xCE, 0xE5, 0xF2, 0xF6, 0x92, 
	  0xED, 0x04, 0xBF, 0xD3, 0xF8, 0x3D, 0x39, 0xCC, 
	  0xAA, 0xCC, 0x0B, 0xB2, 0x6B, 0xD8, 0xB2, 0x8A, 
	  0x5C, 0xCE, 0xDA, 0xF9, 0xE1, 0xA7, 0x23, 0x50, 
	  0xDC, 0xCE, 0xA4, 0xD5, 0xA5, 0x4F, 0x08, 0x0F } 
	};

/* The DH key uses cryptlib-internal mechanisms, the following data and
   associated test can't be used with an unmodified version of cryptlib */

#ifdef TEST_DH

#define CRYPT_IATTRIBUTE_KEY_SPKI	8015

static const BYTE dh1024SPKI[] = {
	0x30, 0x82, 0x01, 0x21,
		0x30, 0x82, 0x01, 0x17,
			0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3E, 0x02, 0x01,
			0x30, 0x82, 0x01, 0x0A,
				0x02, 0x81, 0x81, 0x00,		/* p */
					0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
					0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34,
					0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1,
					0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74,
					0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22,
					0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD,
					0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B,
					0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37,
					0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45,
					0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6,
					0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B,
					0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED,
					0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5,
					0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6,
					0x49, 0x28, 0x66, 0x51, 0xEC, 0xE6, 0x53, 0x81,
					0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
				0x02, 0x01,					/* g */
					0x02,
				0x02, 0x81, 0x80,			/* q */
					0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
					0xE4, 0x87, 0xED, 0x51, 0x10, 0xB4, 0x61, 0x1A,
					0x62, 0x63, 0x31, 0x45, 0xC0, 0x6E, 0x0E, 0x68,
					0x94, 0x81, 0x27, 0x04, 0x45, 0x33, 0xE6, 0x3A,
					0x01, 0x05, 0xDF, 0x53, 0x1D, 0x89, 0xCD, 0x91,
					0x28, 0xA5, 0x04, 0x3C, 0xC7, 0x1A, 0x02, 0x6E,
					0xF7, 0xCA, 0x8C, 0xD9, 0xE6, 0x9D, 0x21, 0x8D,
					0x98, 0x15, 0x85, 0x36, 0xF9, 0x2F, 0x8A, 0x1B,
					0xA7, 0xF0, 0x9A, 0xB6, 0xB6, 0xA8, 0xE1, 0x22,
					0xF2, 0x42, 0xDA, 0xBB, 0x31, 0x2F, 0x3F, 0x63,
					0x7A, 0x26, 0x21, 0x74, 0xD3, 0x1B, 0xF6, 0xB5,
					0x85, 0xFF, 0xAE, 0x5B, 0x7A, 0x03, 0x5B, 0xF6,
					0xF7, 0x1C, 0x35, 0xFD, 0xAD, 0x44, 0xCF, 0xD2,
					0xD7, 0x4F, 0x92, 0x08, 0xBE, 0x25, 0x8F, 0xF3,
					0x24, 0x94, 0x33, 0x28, 0xF6, 0x73, 0x29, 0xC0,
					0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
		0x03, 0x04, 0x00,
			0x02, 0x01, 0x00				/* y */
	};
#endif /* TEST_DH */

typedef struct {
	const CRYPT_ECCCURVE_TYPE curveType;
	const int pLen; const BYTE p[ 66 ];
	const int aLen; const BYTE a[ 66 ];
	const int bLen; const BYTE b[ 66 ];
	const int gxLen; const BYTE gx[ 66 ];
	const int gyLen; const BYTE gy[ 66 ];
	const int nLen; const BYTE n[ 66 ];
	const int qxLen; const BYTE qx[ 66 ];
	const int qyLen; const BYTE qy[ 66 ];
	const int dLen; const BYTE d[ 66 ];
	} ECC_KEY;

/* NIST curve P-256 */

static const ECC_KEY eccP256TestKey = {
#if 0	/* Explicit parameters for non-named curve */
	CRYPT_ECCCURVE_NONE,
	/* p */
	256,
	{ 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 
	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	  0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 
	  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
	/* a */
	256,
	{ 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 
	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	  0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 
	  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC },
	/* b */
	256,
	{ 0x5A, 0xC6, 0x35, 0xD8, 0xAA, 0x3A, 0x93, 0xE7, 
	  0xB3, 0xEB, 0xBD, 0x55, 0x76, 0x98, 0x86, 0xBC, 
	  0x65, 0x1D, 0x06, 0xB0, 0xCC, 0x53, 0xB0, 0xF6, 
	  0x3B, 0xCE, 0x3C, 0x3E, 0x27, 0xD2, 0x60, 0x4B },
	/* gx */
	256,
	{ 0x6B, 0x17, 0xD1, 0xF2, 0xE1, 0x2C, 0x42, 0x47, 
	  0xF8, 0xBC, 0xE6, 0xE5, 0x63, 0xA4, 0x40, 0xF2, 
	  0x77, 0x03, 0x7D, 0x81, 0x2D, 0xEB, 0x33, 0xA0, 
	  0xF4, 0xA1, 0x39, 0x45, 0xD8, 0x98, 0xC2, 0x96 },
	/* gy */
	256,
	{ 0x4F, 0xE3, 0x42, 0xE2, 0xFE, 0x1A, 0x7F, 0x9B, 
	  0x8E, 0xE7, 0xEB, 0x4A, 0x7C, 0x0F, 0x9E, 0x16, 
	  0x2B, 0xCE, 0x33, 0x57, 0x6B, 0x31, 0x5E, 0xCE, 
	  0xCB, 0xB6, 0x40, 0x68, 0x37, 0xBF, 0x51, 0xF5 },
	/* n */
	256,
	{ 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,  
	  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
	  0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84, 
	  0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51 },
#else	/* Implicit parameters for named curve */
	CRYPT_ECCCURVE_P256,
	0, { 0 },	/* p */
	0, { 0 },	/* a */
	0, { 0 },	/* b */
	0, { 0 },	/* gx */
	0, { 0 },	/* gy */
	0, { 0 },	/* n */
#endif /* 0 */
	/* qx */
	256,
	{ 0x26, 0x0C, 0xAB, 0x1F, 0xF2, 0x5E, 0x8F, 0x54,
	  0x1C, 0x52, 0x66, 0x4A, 0x1B, 0x23, 0x8F, 0x68,
	  0x0D, 0xEB, 0xCB, 0x0B, 0x4A, 0x4E, 0x4C, 0x88,
	  0xCA, 0x53, 0x1F, 0x32, 0xAB, 0x0F, 0x72, 0x56 },
	/* qy */
	256,
	{ 0x94, 0x56, 0xD7, 0x00, 0x6A, 0x50, 0x06, 0xC0,
	  0x87, 0x9B, 0x73, 0x0D, 0x3F, 0x16, 0x37, 0x42,
	  0xE8, 0x8A, 0xA0, 0x7F, 0x9F, 0x87, 0xD5, 0x29,
	  0xCF, 0x3C, 0x83, 0xC7, 0xC3, 0xE3, 0x93, 0x58 },
	/* d */
	256,
	{ 0xC6, 0x91, 0x9E, 0xD5, 0xF2, 0x84, 0xE0, 0x30,
	  0xD5, 0x7B, 0xA8, 0x13, 0x51, 0x0B, 0x50, 0x1C,
	  0x7D, 0x8E, 0x14, 0x66, 0xE2, 0xF1, 0x49, 0x97,
	  0x06, 0x49, 0x61, 0x67, 0xFA, 0xA3, 0xEA, 0x05 }
	};

/* Ed25519/X25519 */

typedef struct {
	const int pubLen; const BYTE pub[ 32 ];
	const int privLen; const BYTE priv[ 32 ];
	} CURVE25519_KEY;

static const CURVE25519_KEY ed25519TestKey = {
	/* pub */
	256,
	{ 0xD7, 0x5A, 0x98, 0x01, 0x82, 0xB1, 0x0A, 0xB7, 
	  0xD5, 0x4B, 0xFE, 0xD3, 0xC9, 0x64, 0x07, 0x3A,
	  0x0E, 0xE1, 0x72, 0xF3, 0xDA, 0xA6, 0x23, 0x25, 
	  0xAF, 0x02, 0x1A, 0x68, 0xF7, 0x07, 0x51, 0x1A },
	/* priv */
	256,
	{ 0x9D, 0x61, 0xB1, 0x9D, 0xEF, 0xFD, 0x5A, 0x60, 
	  0xBA, 0x84, 0x4A, 0xF4, 0x92, 0xEC, 0x2C, 0xC4,
	  0x44, 0x49, 0xC5, 0x69, 0x7B, 0x32, 0x69, 0x19, 
	  0x70, 0x3B, 0xAC, 0x03, 0x1C, 0xAE, 0x7F, 0x60 }
	};

static const CURVE25519_KEY x25519TestKey = {
	/* pub */
	256,
	{ 0x85, 0x20, 0xF0, 0x09, 0x89, 0x30, 0xA7, 0x54,
	  0x74, 0x8B, 0x7D, 0xDC, 0xB4, 0x3E, 0xF7, 0x5A,
	  0x0D, 0xBF, 0x3A, 0x0D, 0x26, 0x38, 0x1A, 0xF4,
	  0xEB, 0xA4, 0xA9, 0x8E, 0xAA, 0x9B, 0x4E, 0x6A },
	/* priv */
	256,
	{ 0x70, 0x07, 0x6D, 0x0A, 0x73, 0x18, 0xA5, 0x7D,
	  0x3C, 0x16, 0xC1, 0x72, 0x51, 0xB2, 0x66, 0x45,
	  0xDF, 0x4C, 0x2F, 0x87, 0xEB, 0xC0, 0x99, 0x2A,
	  0xB1, 0x77, 0xFB, 0xA5, 0x1D, 0xB9, 0x2C, 0x6A }
	};

/* ML-KEM.  

	HELMET: Yes, we're gonna have to go right to ludicrous size.
	SANDURZ: Ludicrous size? Sir, we've never gone that large before.  I 
			 don't know if this code can take it.
	HELMET: What's the matter, Colonel Sandurz, chicken? 
	SANDURZ: Prepare code... prepare code for ludicrous size */

typedef struct {
	const int pubLen; const BYTE pub[ 1184 ];
	const int privLen; const BYTE priv[ 2400 ];
	} MLKEM_KEY;

static const MLKEM_KEY mlKemTestKey = {
	/* pub */
	9472,
	{ 0xB6, 0xF5, 0x71, 0xB9, 0x5C, 0x21, 0xFA, 0x26,
	  0xB9, 0xFF, 0xB7, 0xB7, 0xCF, 0x26, 0xC3, 0xBC,
	  0xF3, 0x95, 0xED, 0x92, 0x54, 0x16, 0x1B, 0x19,
	  0xF7, 0x47, 0x7F, 0x87, 0x40, 0x8B, 0x4C, 0xF2,
	  0x7B, 0xB6, 0x49, 0x9F, 0xA1, 0x02, 0xBC, 0x0D,
	  0x36, 0x5A, 0x06, 0x61, 0x37, 0x6C, 0xE5, 0x86,
	  0x45, 0x72, 0x2E, 0xA1, 0x7C, 0x50, 0x13, 0x03,
	  0x24, 0x1F, 0xC4, 0x2F, 0xCB, 0x3A, 0xAF, 0x46,
	  0x6B, 0x7B, 0x93, 0x34, 0x5E, 0x2C, 0xC1, 0x82,
	  0x25, 0x63, 0x9D, 0xD1, 0x97, 0x78, 0xC2, 0x59,
	  0x9E, 0x30, 0xD2, 0xC0, 0xF0, 0xA5, 0x6F, 0x94,
	  0x68, 0x5A, 0x45, 0x2C, 0x77, 0x2E, 0xA3, 0x1C,
	  0x50, 0x26, 0xB5, 0x3D, 0x55, 0x85, 0x23, 0xE1,
	  0x45, 0x8A, 0x1C, 0xCF, 0xE6, 0x40, 0x0B, 0xE9,
	  0xC6, 0x7B, 0x3C, 0x79, 0x82, 0x0E, 0xDA, 0x40,
	  0xAD, 0x03, 0x56, 0x56, 0x07, 0xA5, 0x11, 0xB5,
	  0x49, 0x6A, 0xAB, 0x8C, 0xFD, 0xEB, 0x53, 0x69,
	  0x43, 0x16, 0x06, 0x4A, 0xB5, 0x62, 0x31, 0x0C,
	  0x9E, 0xAA, 0x09, 0xC9, 0xBA, 0xA0, 0x15, 0x98,
	  0x2E, 0x37, 0xB4, 0x59, 0xB0, 0xF2, 0xB6, 0x90,
	  0xFC, 0x32, 0x03, 0x54, 0x89, 0x2E, 0xF1, 0x42,
	  0x83, 0x3A, 0x2B, 0xBE, 0xE7, 0x78, 0x26, 0x02,
	  0x63, 0x88, 0x9B, 0x8E, 0xEA, 0xF7, 0x69, 0xA9,
	  0xD1, 0x8F, 0x2B, 0x68, 0x77, 0xED, 0xB9, 0x06,
	  0x14, 0xC3, 0xA7, 0x17, 0x77, 0x2F, 0x30, 0xCC,
	  0xA6, 0xC5, 0x79, 0xC0, 0xC8, 0x48, 0x61, 0xFB,
	  0x4C, 0x84, 0x90, 0xCB, 0x18, 0xC1, 0x22, 0x14,
	  0x0A, 0x27, 0x92, 0x4B, 0x61, 0x72, 0x10, 0xB0,
	  0x8A, 0x3D, 0xE9, 0x81, 0xBF, 0xA1, 0x4A, 0x57,
	  0xBC, 0x46, 0xA6, 0x71, 0x2C, 0x73, 0x91, 0x8A,
	  0xC4, 0x34, 0x6E, 0x1F, 0x83, 0x07, 0x80, 0x54,
	  0xAB, 0xDF, 0x43, 0x75, 0x2B, 0x76, 0x13, 0xDC,
	  0x88, 0x05, 0x43, 0xC4, 0x7E, 0xBE, 0x51, 0x90,
	  0x86, 0x83, 0x54, 0xDE, 0x22, 0xBA, 0xC0, 0x34,
	  0x32, 0xF6, 0x16, 0x8D, 0x12, 0x95, 0x70, 0xFF,
	  0x22, 0x90, 0x03, 0x23, 0x9D, 0xA3, 0x02, 0x8B,
	  0xCD, 0xEA, 0x1F, 0xD4, 0xA4, 0x33, 0x18, 0x72,
	  0x4E, 0x11, 0x4C, 0x79, 0x86, 0x99, 0x5C, 0x3E,
	  0x64, 0x44, 0xEE, 0xCA, 0xC5, 0x5C, 0xEC, 0x5C,
	  0xFF, 0x6B, 0x39, 0xDB, 0xAA, 0x57, 0xCE, 0xCA,
	  0x13, 0x4B, 0xB5, 0x14, 0xD3, 0x99, 0x40, 0xB0,
	  0x54, 0x9A, 0x85, 0xEB, 0x40, 0x77, 0x41, 0x1C,
	  0xC3, 0xD9, 0xB2, 0xA7, 0xA5, 0xA8, 0x80, 0xF3,
	  0x9B, 0xA4, 0x70, 0x14, 0x85, 0xB0, 0x12, 0x8D,
	  0x24, 0xB4, 0xCE, 0x89, 0x33, 0xA2, 0x84, 0x92,
	  0x06, 0xEC, 0x88, 0xD1, 0xE4, 0x1D, 0x43, 0x42,
	  0x00, 0x5F, 0x33, 0x77, 0x4B, 0x8B, 0xCE, 0x2F,
	  0x21, 0x4F, 0xAC, 0x85, 0x87, 0x10, 0x89, 0x83,
	  0x13, 0x9C, 0x5B, 0x89, 0x08, 0x58, 0xE7, 0x37,
	  0xB8, 0xAF, 0xCC, 0x6F, 0x29, 0xF2, 0x79, 0x53,
	  0xA6, 0x31, 0x6C, 0x50, 0x65, 0xEB, 0x51,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xBC, 0x72,
	  0x4F, 0xCC, 0x0F, 0x9C, 0xA8, 0x08, 0x6F, 0xB9,
	  0xC0, 0x92, 0x95, 0xA9, 0xA5, 0x8B, 0x80, 0x5E,
	  0xD2, 0x49, 0xF7, 0xA9, 0x07, 0x4F, 0x76, 0x50,
	  0x55, 0x2B, 0x62, 0xCD, 0x40, 0x43, 0x72, 0xC7,
	  0x06, 0xED, 0x33, 0x48, 0x80, 0xAC, 0xA0, 0x62,
	  0x64, 0x93, 0x73, 0xB2, 0x7E, 0xA6, 0xE5, 0x87,
	  0xFC, 0xA4, 0xC2, 0xAE, 0xA1, 0x22, 0xAC, 0x43,
	  0x1B, 0x5C, 0x20, 0x72, 0x05, 0x44, 0x04, 0x93,
	  0x4B, 0x3B, 0x5E, 0x94, 0x9C, 0x4A, 0xD3, 0xB6,
	  0x2F, 0x57, 0x91, 0x43, 0x48, 0x8E, 0x30, 0xF6,
	  0x6B, 0xF9, 0x25, 0x97, 0x1D, 0x5A, 0x09, 0x39,
	  0xD2, 0x1C, 0xB0, 0xD4, 0x0F, 0xD8, 0x27, 0x48,
	  0x23, 0x58, 0x61, 0xAA, 0xCC, 0x91, 0x2E, 0x15,
	  0xA0, 0x74, 0x77, 0x5E, 0xA0, 0xF7, 0x48, 0x2A,
	  0x41, 0x99, 0xAA, 0x50, 0x86, 0x9E, 0x27, 0x92,
	  0xBD, 0xC1, 0x45, 0x47, 0x51, 0x21, 0x76, 0xBA,
	  0x8E, 0x91, 0xE6, 0xCE, 0x30, 0x53, 0xC1, 0x4E,
	  0x74, 0xAC, 0xD2, 0x65, 0xB3, 0xB0, 0x5B, 0x8F,
	  0xCF, 0x4A, 0x10, 0x35, 0x91, 0x85, 0xC9, 0x66,
	  0x57, 0xF8, 0x4A, 0xA9, 0x4B, 0x02, 0xB7, 0x45,
	  0x10, 0x64, 0x42, 0xBA, 0x63, 0xE9, 0x62, 0x83,
	  0x18, 0x86, 0x14, 0xC2, 0x8C, 0xC6, 0xD2, 0x7B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x11, 0xBF, 0xD7, 0x79, 0x94,
	  0xA0, 0x12, 0x80, 0x52, 0x00, 0xFD, 0x71, 0x96,
	  0x31, 0xA3, 0x48, 0xC3, 0xA9, 0xC5, 0x7B, 0xB0,
	  0x73, 0x7F, 0x4A, 0x8D, 0x87, 0xDA, 0x40, 0x9E,
	  0x16, 0x2B, 0x67, 0x48, 0x26, 0x8A, 0xB1, 0x73,
	  0x84, 0xC3, 0xAE, 0x32, 0x69, 0x64, 0xA7, 0x46,
	  0x8A, 0x07, 0xC4, 0x36, 0xC2, 0x58, 0x8C, 0x81,
	  0xF0, 0x55, 0x64, 0xE4, 0xC2, 0x70, 0xF6, 0xAA,
	  0x5A, 0xF9, 0xC1, 0x03, 0x05, 0x1C, 0xAA, 0xCA,
	  0xC0, 0x61, 0xFB, 0x65, 0x66, 0x17, 0x0F, 0xA4,
	  0x4A, 0x81, 0x54, 0xA4, 0xA8, 0x88, 0xDC, 0x89,
	  0xA0, 0x86, 0x3F, 0x9A, 0xD6, 0x50, 0x37, 0x0A,
	  0x47, 0x44, 0xC8, 0x17, 0x3B, 0x13, 0xCC, 0x1B,
	  0x50, 0x73, 0xC9, 0xA8, 0xA2, 0xD6, 0x7B, 0x51,
	  0xA4, 0x36, 0x4F, 0xEF, 0xA3, 0xA4, 0x1E, 0x90,
	  0x25, 0x09, 0x82, 0x6F, 0x13, 0xDC, 0x2A, 0xB5,
	  0x7A, 0x72, 0x83, 0xD6, 0x20, 0x2D, 0xF0, 0x91,
	  0xA0, 0x26, 0x90, 0xA8, 0x83, 0x5E, 0x8C, 0x55,
	  0xCE, 0x37, 0x37, 0xC8, 0xA2, 0x53, 0x56, 0x5E,
	  0x99, 0x25, 0x1C, 0x8A, 0x2D, 0x01, 0x56, 0xB5,
	  0x35, 0x64, 0x6E, 0x7E, 0x58, 0xB8, 0x7A, 0xAB,
	  0x7D, 0x04, 0x13, 0x8E, 0x7A, 0x79, 0x0A, 0x69,
	  0x10, 0x51, 0x10, 0xA0, 0x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 0xEA, 0xF7, 0x69, 0xA9,
	  0xD1, 0x8F, 0x2B, 0x68, 0x77, 0xED, 0xB9, 0x06,
	  0x14, 0xC3, 0xA7, 0x17, 0x77, 0x2F, 0x30, 0xCC,
	  0xA6, 0xC5, 0x79, 0xC0, 0xC8, 0x48, 0x61, 0xFB,
	  0x4C, 0x84, 0x90, 0xCB, 0x18, 0xC1, 0x22, 0x14,
	  0x0A, 0x27, 0x92, 0x4B, 0x61, 0x72, 0x10, 0xB0,
	  0x8A, 0x3D, 0xE9, 0x81, 0xBF, 0xA1, 0x4A, 0x57,
	  0xBC, 0x46, 0xA6, 0x71, 0x2C, 0x73, 0x91, 0x8A,
	  0xC4, 0x34, 0x6E, 0x1F, 0x83, 0x07, 0x80, 0x54,
	  0xAB, 0xDF, 0x43, 0x75, 0x2B, 0x76, 0x13, 0xDC,
	  0x88, 0x05, 0x43, 0xC4, 0x7E, 0xBE, 0x51, 0x90,
	  0x86, 0x83, 0x54, 0xDE, 0x22, 0xBA, 0xC0, 0x34,
	  0x32, 0xF6, 0x16, 0x8D, 0x12, 0x95, 0x70, 0xFF,
	  0x22, 0x90, 0x03, 0x23, 0x9D, 0xA3, 0x02, 0x8B,
	  0xCD, 0xEA, 0x1F, 0xD4, 0xA4, 0x33, 0x18, 0x72,
	  0x4E, 0x11, 0x4C, 0x79, 0x86, 0x99, 0x5C, 0x3E,
	  0x64, 0x44, 0xEE, 0xCA, 0xC5, 0x5C, 0xEC, 0x5C,
	  0xFF, 0x6B, 0x39, 0xDB, 0xAA, 0x57, 0xCE, 0xCA,
	  0x13, 0x4B, 0xB5, 0x14, 0xD3, 0x99, 0x40, 0xB0,
	  0x54, 0x9A, 0x85, 0xEB, 0x40, 0x77, 0x41, 0x1C,
	  0xC3, 0xD9, 0xB2, 0xA7, 0xA5, 0xA8, 0x80, 0xF3,
	  0x9B, 0xA4, 0x70, 0x14, 0x85, 0xB0, 0x12, 0x8D,
	  0x24, 0xB4, 0xCE, 0x89, 0x33, 0xA2, 0x84, 0x92,
	  0x06, 0xEC, 0x88, 0xD1, 0xE4, 0x1D, 0x43, 0x42,
	  0x00, 0x5F, 0x33, 0x77, 0x4B, 0x8B, 0xCE, 0x2F,
	  0x21, 0x4F, 0xAC, 0x85, 0x87, 0x10, 0x89, 0x83,
	  0x13, 0x9C, 0x5B, 0x89, 0x08, 0x58, 0xE7, 0x37,
	  0xB8, 0xAF, 0xCC, 0x6F, 0x29, 0xF2, 0x79, 0x53,
	  0xA6, 0x31, 0x6C, 0x50, 0x65, 0xEB, 0x51, 0xAE,
	  0x5C, 0xE1, 0x3F, 0x07, 0x17, 0x30, 0x51, 0xA1,
	  0x0B, 0x27, 0xD6, 0x6E, 0x5B, 0x18, 0x30, 0xCC,
	  0xB1, 0xB4, 0xDF, 0xF2, 0x5B, 0x86, 0xD9, 0xC3,
	  0xEF, 0x46, 0x3A, 0x4B, 0x00, 0x5C, 0xDB, 0x00,
	  0x70, 0x5D, 0xC7, 0x22, 0xC6, 0x77, 0x8D, 0xC6,
	  0xE1, 0x63, 0xE5, 0x6B, 0x4D, 0x02, 0x84, 0xBF,
	  0x6E, 0xB4, 0x68, 0xA3, 0x37, 0x43, 0x35, 0x55,
	  0x78, 0x82, 0xDC, 0x69, 0x1F, 0x68, 0x99, 0xCC,
	  0x0C, 0x66, 0xCE, 0xD3, 0x66, 0x24, 0x52, 0xC2,
	  0xE8, 0xC5, 0x37, 0xF8, 0xB3, 0x11, 0x4D, 0x3A,
	  0x14, 0xC5, 0x4B, 0x71, 0x82, 0x23, 0x69, 0x20,
	  0x83, 0x4A, 0x26, 0x14, 0x37, 0x62, 0xC6, 0x76,
	  0x55, 0xA1, 0xAD, 0xFA, 0xF9, 0xA9, 0x07, 0x48,
	  0xB6, 0x58, 0xE2, 0x0C, 0x22, 0xC9, 0xC0, 0xCF,
	  0x25, 0xA8, 0xC3, 0xD3, 0x32, 0xDC, 0xA0, 0x47,
	  0xF9, 0x89, 0x75, 0x19, 0x6C, 0x9E, 0xC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A, 0x82, 0x5D,
	  0x06, 0x13, 0xBE, 0x06, 0xFC, 0x60, 0xCF, 0xFB,
	  0x7F, 0x45, 0x76, 0x0D, 0x9C, 0x04, 0x78, 0xAD,
	  0x2C, 0x17, 0xBB, 0xE0, 0x42, 0x24, 0xA2, 0x72,
	  0x0E, 0x31, 0x3D, 0xA7, 0xBC, 0x2B, 0xA8, 0x31,
	  0xAF, 0x54, 0x90, 0x6D, 0x58, 0xB9, 0x1F, 0xB2,
	  0x35, 0x22, 0x53, 0xDC, 0x01, 0xA5, 0xBC, 0x72,
	  0x4F, 0xCC, 0x0F, 0x9C, 0xA8, 0x08, 0x6F, 0xB9,
	  0xC0, 0x92, 0x95, 0xA9, 0xA5, 0x8B, 0x80, 0x5E,
	  0xD2, 0x49, 0xF7, 0xA9, 0x07, 0x4F, 0x76, 0x50,
	  0x55, 0x2B, 0x62, 0xCD, 0x40, 0x43, 0x72, 0xC7,
	  0x06, 0xED, 0x33, 0x48, 0x80, 0xAC, 0xA0, 0x62,
	  0x64, 0x93, 0x73, 0xB2, 0x7E, 0xA6, 0xE5, 0x87,
	  0xFC, 0xA4, 0xC2, 0xAE, 0xA1, 0x22, 0xAC, 0x43,
	  0x1B, 0x5C, 0x20, 0x72, 0x05, 0x44, 0x04, 0x93,
	  0x4B, 0x3B, 0x5E, 0x94, 0x9C, 0x4A, 0xD3, 0xB6,
	  0x2F, 0x57, 0x91, 0x43, 0x48, 0x8E, 0x30, 0xF6,
	  0x6B, 0xF9, 0x25, 0x97, 0x1D, 0x5A, 0x09, 0x39,
	  0xD2, 0x1C, 0xB0, 0xD4, 0x0F, 0xD8, 0x27, 0x48,
	  0x23, 0x58, 0x61, 0xAA, 0xCC, 0x91, 0x2E, 0x15,
	  0xA0, 0x74, 0x77, 0x5E, 0xA0, 0xF7, 0x48, 0x2A,
	  0x41, 0x99, 0xAA, 0x50, 0x86, 0x9E, 0x27, 0x92,
	  0xBD, 0xC1, 0x45, 0x47, 0x51, 0x21, 0x76, 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x2A, 0x2A, 0x2A,
	  0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A }
	};

/****************************************************************************
*																			*
*								Key Load Routines							*
*																			*
****************************************************************************/

/* Set the label for a device object */

static BOOLEAN setLabel( const CRYPT_CONTEXT cryptContext, const C_STR label )
	{
	int status;

	status = cryptSetAttributeString( cryptContext, CRYPT_CTXINFO_LABEL,
									  label, paramStrlen( label ) );
	if( status == CRYPT_ERROR_DUPLICATE )
		{
		printf( "A key object with the label '%s' already exists inside the\n"
				"device.  To perform this test, you need to delete the "
				"existing object so\nthat cryptlib can create a new one, "
				"line %d.\n", label, __LINE__ );
		return( FALSE );
		}
	if( cryptStatusError( status ) )
		{
		printf( "Attempt to set object label failed with status %d, "
				"line %d.\n", status, __LINE__ );
		return( FALSE );
		}

	return( TRUE );
	}

/* Load DH, RSA, DSA, and Elgamal PKC encryption contexts */

#ifdef TEST_DH

typedef struct {
	void *data;							/* Data */
	int length;							/* Length */
	} xMESSAGE_DATA;

#define xsetMessageData( msgDataPtr, dataPtr, dataLength ) \
	{ \
	( msgDataPtr )->data = ( dataPtr ); \
	( msgDataPtr )->length = ( dataLength ); \
	}

BOOLEAN loadDHKey( const CRYPT_DEVICE cryptDevice,
				   CRYPT_CONTEXT *cryptContext )
	{
	const BOOLEAN isDevice = ( cryptDevice != CRYPT_UNUSED ) ? TRUE : FALSE;
	int status;

	if( isDevice )
		{
		status = cryptDeviceCreateContext( cryptDevice, cryptContext,
										   CRYPT_ALGO_DH );
		}
	else
		{
		status = cryptCreateContext( cryptContext, CRYPT_UNUSED,
									 CRYPT_ALGO_DH );
		}
	if( cryptStatusError( status ) )
		{
		fprintf( outputStream, "crypt%sCreateContext() failed with error "
				 "code %d, line %d.\n", isDevice ? "Device" : "", status, 
				 __LINE__ );
		return( FALSE );
		}
	if( !setLabel( *cryptContext, "DH key" ) )
		{
		cryptDestroyContext( *cryptContext );
		return( FALSE );
		}
	if( cryptStatusOK( status ) )
		{
		xMESSAGE_DATA msgData;

		xsetMessageData( &msgData, ( void * ) dh1024SPKI,
						 sizeof( dh1024SPKI ) );
		status = krnlSendMessage( *cryptContext, IMESSAGE_SETATTRIBUTE_S,
								  &msgData, CRYPT_IATTRIBUTE_KEY_SPKI );
		}
	if( cryptStatusError( status ) )
		{
		printf( "DH key load failed, status = %d, line %d.\n", status,
				__LINE__ );
		cryptDestroyContext( *cryptContext );
		return( FALSE );
		}
	return( TRUE );
	}
#endif /* TEST_DH */

static int loadRSAPublicKey( const CRYPT_DEVICE cryptDevice,
							 CRYPT_CONTEXT *cryptContext,
							 const C_STR cryptContextLabel,
							 CRYPT_PKCINFO_RSA *rsaKey,
							 const BOOLEAN isDevice,
							 const BOOLEAN useLargeKey )
	{
	const RSA_KEY *rsaKeyTemplate = useLargeKey ? \
								&rsa2048TestKey : &rsa1024TestKey;
	CRYPT_PKCINFO_RSA rsaTestStructure;
	int status;

	/* Perform a check for CONFIG_PKC_ALLOCSIZE overriding 
	   CRYPT_MAX_PKCSIZE.  If this is set in misc/config.h via something
	   like CONFIG_CONSERVE_MEMORY then it'll have a different value inside
	   cryptlib than outside it, since cryptlib.h will define it to its
	   original value while misc/config.h will override it to match
	   CONFIG_PKC_ALLOCSIZE.  We can't detect this via the preprocessor
	   since the inclusion of misc/config.h to detect the override also
	   overrides the value from cryptlib.h, so we have to check the size
	   of a value typedef'd before the override happened.
	   
	   Some compilers will produce an unused-variable warning for 
	   rsaTestStructure since it's not used in anything except the sizeof()
	   compile-time evaluation.  We also need to cast the sizeof() in the
	   fprintf() to int for pedantic compilers that know that sizeof()
	   is potentially a large unsigned value even though it's actually not 
	   even a 16-bit int value */
	if( sizeof( rsaTestStructure.n ) < CRYPT_MAX_PKCSIZE - 8 || \
		sizeof( rsaTestStructure.n ) > CRYPT_MAX_PKCSIZE + 8 )
		{
		fprintf( outputStream, "CRYPT_MAX_PKCSIZE appears to be %d in "
				 "cryptlib but %d in the test code,\n"
				 "has CONFIG_PKC_ALLOCSIZE been used inconsistently?\n", 
				 CRYPT_MAX_PKCSIZE, ( int ) sizeof( rsaTestStructure.n ) );
		return( CRYPT_ERROR_FAILED );
		}

	if( isDevice )
		{
		status = cryptDeviceCreateContext( cryptDevice, cryptContext,
										   CRYPT_ALGO_RSA );
		}
	else
		{
		status = cryptCreateContext( cryptContext, CRYPT_UNUSED,
									 CRYPT_ALGO_RSA );
		}
	if( cryptStatusError( status ) )
		{
		fprintf( outputStream, "crypt%sCreateContext() failed with error "
				 "code %d, line %d.\n", isDevice ? "Device" : "", status, 
				 __LINE__ );
		return( status );
		}
	if( isDevice && !setLabel( *cryptContext, cryptContextLabel ) )
		{
		cryptDestroyContext( *cryptContext );
		return( CRYPT_ERROR_FAILED );
		}
	cryptInitComponents( rsaKey, CRYPT_KEYTYPE_PUBLIC );
	cryptSetComponent( rsaKey->n, rsaKeyTemplate->n, rsaKeyTemplate->nLen );
	cryptSetComponent( rsaKey->e, rsaKeyTemplate->e, rsaKeyTemplate->eLen );
	status = cryptSetAttributeString( *cryptContext,
								CRYPT_CTXINFO_KEY_COMPONENTS, rsaKey,
								sizeof( CRYPT_PKCINFO_RSA ) );
	cryptDestroyComponents( rsaKey );
	if( cryptStatusError( status ) )
		cryptDestroyContext( *cryptContext );
	return( status );
	}

BOOLEAN loadRSAContextsEx( const CRYPT_DEVICE cryptDevice,
						   CRYPT_CONTEXT *cryptContext,
						   CRYPT_CONTEXT *decryptContext,
						   const C_STR cryptContextLabel,
						   const C_STR decryptContextLabel,
						   const BOOLEAN useLargeKey,
						   const BOOLEAN useMinimalKey )
	{
	CRYPT_PKCINFO_RSA *rsaKey;
	const RSA_KEY *rsaKeyTemplate = useLargeKey ? \
									&rsa2048TestKey : &rsa1024TestKey;
	const BOOLEAN isDevice = ( cryptDevice != CRYPT_UNUSED ) ? TRUE : FALSE;
	BOOLEAN loadLargeKey = useLargeKey;
	int status;

	/* Allocate room for the public-key components */
	if( ( rsaKey = ( CRYPT_PKCINFO_RSA * ) malloc( sizeof( CRYPT_PKCINFO_RSA ) ) ) == NULL )
		return( FALSE );

	/* Some devices only support a single key size that isn't the same as
	   the built-in one so we adjust the key size being used if necessary */
	if( isDevice )
		{
		CRYPT_QUERY_INFO cryptQueryInfo;

		status = cryptDeviceQueryCapability( cryptDevice, CRYPT_ALGO_RSA,
											 &cryptQueryInfo );
		if( cryptStatusError( status ) )
			{
			free( rsaKey );
			return( FALSE );
			}
		if( cryptQueryInfo.minKeySize == cryptQueryInfo.keySize && \
			cryptQueryInfo.maxKeySize == cryptQueryInfo.keySize && \
			cryptQueryInfo.keySize != ( rsa1024TestKey.nLen / 8 ) )
			{
			if( cryptQueryInfo.keySize != ( rsa2048TestKey.nLen / 8 ) )
				{
				printf( "Device requires a %d-bit key, which doesn't "
						"correspond to any built-in\ncryptlib key.\n",
						cryptQueryInfo.keySize * 8 );
				free( rsaKey );
				return( FALSE );
				}
			rsaKeyTemplate = &rsa2048TestKey;
			loadLargeKey = TRUE;
			}
		}

	/* Create the encryption context */
	if( cryptContext != NULL )
		{
		status = loadRSAPublicKey( cryptDevice, cryptContext,
								   cryptContextLabel, rsaKey, isDevice,
								   loadLargeKey );
		if( status == CRYPT_ERROR_NOTAVAIL && isDevice )
			{
			/* The device doesn't support public-key ops, use a native
			   context for the public key */
			puts( "  Warning: Device doesn't support public-key operations, "
				  "using a cryptlib\n  native context instead." );
			status = loadRSAPublicKey( CRYPT_UNUSED, cryptContext,
									   cryptContextLabel, rsaKey, FALSE,
									   loadLargeKey );
			}
		if( cryptStatusError( status ) )
			{
			free( rsaKey );
			fprintf( outputStream, "Public key load failed with error "
					 "code %d, line %d.\n", status, __LINE__ );
			return( FALSE );
			}
		if( decryptContext == NULL )
			{
			/* We're only using a public-key context, return */
			free( rsaKey );
			return( TRUE );
			}
		}

	/* Create the decryption context */
	if( isDevice )
		{
		status = cryptDeviceCreateContext( cryptDevice, decryptContext,
										   CRYPT_ALGO_RSA );
		}
	else
		{
		status = cryptCreateContext( decryptContext, CRYPT_UNUSED,
									 CRYPT_ALGO_RSA );
		}
	if( cryptStatusError( status ) )
		{
		free( rsaKey );
		if( cryptContext != NULL )
			{
			cryptDestroyContext( *cryptContext );
			if( isDevice )
				{
				cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
								cryptContextLabel );
				}
			}
		fprintf( outputStream, "crypt%sCreateContext() failed with error "
				 "code %d, line %d.\n", isDevice ? "Device" : "", status, 
				 __LINE__ );
		return( FALSE );
		}
	if( !setLabel( *decryptContext, decryptContextLabel ) )
		{
		free( rsaKey );
		cryptDestroyContext( *decryptContext );
		if( cryptContext != NULL )
			{
			cryptDestroyContext( *cryptContext );
			if( isDevice )
				{
				cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
								cryptContextLabel );
				}
			}
		return( FALSE );
		}
	cryptInitComponents( rsaKey, CRYPT_KEYTYPE_PRIVATE );
	cryptSetComponent( rsaKey->n, rsaKeyTemplate->n, rsaKeyTemplate->nLen );
	cryptSetComponent( rsaKey->e, rsaKeyTemplate->e, rsaKeyTemplate->eLen );
	cryptSetComponent( rsaKey->d, rsaKeyTemplate->d, rsaKeyTemplate->dLen );
	cryptSetComponent( rsaKey->p, rsaKeyTemplate->p, rsaKeyTemplate->pLen );
	cryptSetComponent( rsaKey->q, rsaKeyTemplate->q, rsaKeyTemplate->qLen );
	if( !useMinimalKey )
		{
		cryptSetComponent( rsaKey->u, rsaKeyTemplate->u, rsaKeyTemplate->uLen );
		cryptSetComponent( rsaKey->e1, rsaKeyTemplate->e1, rsaKeyTemplate->e1Len );
		cryptSetComponent( rsaKey->e2, rsaKeyTemplate->e2, rsaKeyTemplate->e2Len );
		}
	status = cryptSetAttributeString( *decryptContext,
									  CRYPT_CTXINFO_KEY_COMPONENTS, rsaKey,
									  sizeof( CRYPT_PKCINFO_RSA ) );
	cryptDestroyComponents( rsaKey );
	free( rsaKey );
	if( cryptStatusError( status ) )
		{
		if( cryptContext != NULL )
			{
			cryptDestroyContext( *cryptContext );
			if( isDevice )
				{
				cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
								cryptContextLabel );
				}
			}
		cryptDestroyContext( *decryptContext );
		if( isDevice )
			{
			cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
							decryptContextLabel );
			}
		printf( "Private key load failed with error code %d, line %d.\n", 
				status, __LINE__ );
		return( FALSE );
		}

	return( TRUE );
	}

BOOLEAN loadRSAContexts( const CRYPT_DEVICE cryptDevice,
						 CRYPT_CONTEXT *cryptContext,
						 CRYPT_CONTEXT *decryptContext )
	{
	return( loadRSAContextsEx( cryptDevice, cryptContext, decryptContext,
							   RSA_PUBKEY_LABEL, RSA_PRIVKEY_LABEL, FALSE, 
							   FALSE ) );
	}
BOOLEAN loadRSAContextsLarge( const CRYPT_DEVICE cryptDevice,
							  CRYPT_CONTEXT *cryptContext,
							  CRYPT_CONTEXT *decryptContext )
	{
	return( loadRSAContextsEx( cryptDevice, cryptContext, decryptContext,
							   RSA_PUBKEY_LABEL, RSA_PRIVKEY_LABEL, TRUE, 
							   FALSE ) );
	}

BOOLEAN loadDSAContextsEx( const CRYPT_DEVICE cryptDevice,
						   CRYPT_CONTEXT *sigCheckContext,
						   CRYPT_CONTEXT *signContext,
						   const C_STR sigCheckContextLabel,
						   const C_STR signContextLabel )
	{
	CRYPT_PKCINFO_DLP *dsaKey;
	const BOOLEAN isDevice = ( cryptDevice != CRYPT_UNUSED ) ? TRUE : FALSE;
	int status;

	/* Allocate room for the public-key components */
	if( ( dsaKey = ( CRYPT_PKCINFO_DLP * ) malloc( sizeof( CRYPT_PKCINFO_DLP ) ) ) == NULL )
		return( FALSE );

	/* Create the signature context */
	if( signContext != NULL )
		{
		if( isDevice )
			{
			status = cryptDeviceCreateContext( cryptDevice, signContext,
											   CRYPT_ALGO_DSA );
			}
		else
			{
			status = cryptCreateContext( signContext, CRYPT_UNUSED,
										 CRYPT_ALGO_DSA );
			}
		if( cryptStatusError( status ) )
			{
			free( dsaKey );
			if( status == CRYPT_ERROR_NOTAVAIL )
				{
				/* DSA support isn't always enabled, in which case we tell 
				   the caller to skip the test */
				return( status );
				}
			fprintf( outputStream, "cryptCreateContext() failed with error "
					 "code %d, line %d.\n", status, __LINE__ );
			return( FALSE );
			}
		if( !setLabel( *signContext, signContextLabel ) )
			{
			free( dsaKey );
			cryptDestroyContext( *signContext );
			return( FALSE );
			}
		cryptInitComponents( dsaKey, CRYPT_KEYTYPE_PRIVATE );
		cryptSetComponent( dsaKey->p, dlp1024TestKey.p, dlp1024TestKey.pLen );
		cryptSetComponent( dsaKey->q, dlp1024TestKey.q, dlp1024TestKey.qLen );
		cryptSetComponent( dsaKey->g, dlp1024TestKey.g, dlp1024TestKey.gLen );
		cryptSetComponent( dsaKey->x, dlp1024TestKey.x, dlp1024TestKey.xLen );
		cryptSetComponent( dsaKey->y, dlp1024TestKey.y, dlp1024TestKey.yLen );
		status = cryptSetAttributeString( *signContext,
									CRYPT_CTXINFO_KEY_COMPONENTS, dsaKey,
									sizeof( CRYPT_PKCINFO_DLP ) );
		cryptDestroyComponents( dsaKey );
		if( cryptStatusError( status ) )
			{
			free( dsaKey );
			cryptDestroyContext( *signContext );
			printf( "Private key load failed with error code %d, line %d.\n", 
					status, __LINE__ );
			return( FALSE );
			}
		if( sigCheckContext == NULL )
			{
			free( dsaKey );
			return( TRUE );
			}
		}

	/* Create the sig.check context */
	if( isDevice )
		{
		status = cryptDeviceCreateContext( cryptDevice, sigCheckContext,
										   CRYPT_ALGO_DSA );
		}
	else
		{
		status = cryptCreateContext( sigCheckContext, CRYPT_UNUSED,
									 CRYPT_ALGO_DSA );
		}
	if( cryptStatusError( status ) )
		{
		free( dsaKey );
		if( signContext != NULL )
			{
			cryptDestroyContext( *signContext );
			if( isDevice )
				{
				cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
								signContextLabel );
				}
			}
		fprintf( outputStream, "cryptCreateContext() failed with error "
				 "code %d, line %d.\n", status, __LINE__ );
		return( FALSE );
		}
	if( !setLabel( *sigCheckContext, sigCheckContextLabel ) )
		{
		free( dsaKey );
		if( signContext != NULL )
			{
			cryptDestroyContext( *signContext );
			if( isDevice )
				{
				cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
								signContextLabel );
				}
			}
		cryptDestroyContext( *sigCheckContext );
		return( FALSE );
		}
	cryptInitComponents( dsaKey, CRYPT_KEYTYPE_PUBLIC );
	cryptSetComponent( dsaKey->p, dlp1024TestKey.p, dlp1024TestKey.pLen );
	cryptSetComponent( dsaKey->q, dlp1024TestKey.q, dlp1024TestKey.qLen );
	cryptSetComponent( dsaKey->g, dlp1024TestKey.g, dlp1024TestKey.gLen );
	cryptSetComponent( dsaKey->y, dlp1024TestKey.y, dlp1024TestKey.yLen );
	status = cryptSetAttributeString( *sigCheckContext,
									  CRYPT_CTXINFO_KEY_COMPONENTS, dsaKey,
									  sizeof( CRYPT_PKCINFO_DLP ) );
	cryptDestroyComponents( dsaKey );
	free( dsaKey );
	if( cryptStatusError( status ) )
		{
		if( signContext != NULL )
			{
			cryptDestroyContext( *signContext );
			if( isDevice )
				{
				cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
								signContextLabel );
				}
			}
		cryptDestroyContext( *sigCheckContext );
		if( isDevice )
			{
			cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
							sigCheckContextLabel );
			}
		printf( "Public key load failed with error code %d, line %d.\n", 
				status, __LINE__ );
		return( FALSE );
		}

	return( TRUE );
	}

BOOLEAN loadDSAContexts( const CRYPT_DEVICE cryptDevice,
						 CRYPT_CONTEXT *sigCheckContext,
						 CRYPT_CONTEXT *signContext )
	{
	return( loadDSAContextsEx( cryptDevice, sigCheckContext, signContext, 
							   DSA_PUBKEY_LABEL, DSA_PRIVKEY_LABEL ) );
	}

BOOLEAN loadElgamalContexts( CRYPT_CONTEXT *cryptContext,
							 CRYPT_CONTEXT *decryptContext )
	{
	CRYPT_PKCINFO_DLP *elgamalKey;
	int status;

	/* Allocate room for the public-key components */
	if( ( elgamalKey = ( CRYPT_PKCINFO_DLP * ) malloc( sizeof( CRYPT_PKCINFO_DLP ) ) ) == NULL )
		return( FALSE );

	/* Create the encryption context */
	if( cryptContext != NULL )
		{
		status = cryptCreateContext( cryptContext, CRYPT_UNUSED,
									 CRYPT_ALGO_ELGAMAL );
		if( cryptStatusError( status ) )
			{
			free( elgamalKey );
			if( status == CRYPT_ERROR_NOTAVAIL )
				{
				/* Elgamal support isn't always enabled, in which case we 
				   tell the caller to skip the test */
				return( status );
				}
			fprintf( outputStream, "cryptCreateContext() failed with error "
					 "code %d, line %d.\n", status, __LINE__ );
			return( FALSE );
			}
		if( !setLabel( *cryptContext, ELGAMAL_PUBKEY_LABEL ) )
			{
			free( elgamalKey );
			cryptDestroyContext( *cryptContext );
			return( FALSE );
			}
		cryptInitComponents( elgamalKey, CRYPT_KEYTYPE_PUBLIC );
		cryptSetComponent( elgamalKey->p, dlp1024TestKey.p, dlp1024TestKey.pLen );
		cryptSetComponent( elgamalKey->g, dlp1024TestKey.g, dlp1024TestKey.gLen );
		cryptSetComponent( elgamalKey->q, dlp1024TestKey.q, dlp1024TestKey.qLen );
		cryptSetComponent( elgamalKey->y, dlp1024TestKey.y, dlp1024TestKey.yLen );
		status = cryptSetAttributeString( *cryptContext,
									CRYPT_CTXINFO_KEY_COMPONENTS, elgamalKey,
									sizeof( CRYPT_PKCINFO_DLP ) );
		cryptDestroyComponents( elgamalKey );
		if( cryptStatusError( status ) )
			{
			free( elgamalKey );
			cryptDestroyContext( *cryptContext );
			printf( "Public key load failed with error code %d, line %d.\n", 
					status, __LINE__ );
			return( FALSE );
			}
		if( decryptContext == NULL )
			{
			free( elgamalKey );
			return( TRUE );
			}
		}

	/* Create the decryption context */
	status = cryptCreateContext( decryptContext, CRYPT_UNUSED,
								 CRYPT_ALGO_ELGAMAL );
	if( cryptStatusError( status ) )
		{
		free( elgamalKey );
		if( cryptContext != NULL )
			cryptDestroyContext( *cryptContext );
		fprintf( outputStream, "cryptCreateContext() failed with error "
				 "code %d, line %d.\n", status, __LINE__ );
		return( FALSE );
		}
	if( !setLabel( *decryptContext, ELGAMAL_PRIVKEY_LABEL ) )
		{
		free( elgamalKey );
		if( cryptContext != NULL )
			cryptDestroyContext( *cryptContext );
		cryptDestroyContext( *decryptContext );
		return( FALSE );
		}
	cryptInitComponents( elgamalKey, CRYPT_KEYTYPE_PRIVATE );
	cryptSetComponent( elgamalKey->p, dlp1024TestKey.p, dlp1024TestKey.pLen );
	cryptSetComponent( elgamalKey->g, dlp1024TestKey.g, dlp1024TestKey.gLen );
	cryptSetComponent( elgamalKey->q, dlp1024TestKey.q, dlp1024TestKey.qLen );
	cryptSetComponent( elgamalKey->y, dlp1024TestKey.y, dlp1024TestKey.yLen );
	cryptSetComponent( elgamalKey->x, dlp1024TestKey.x, dlp1024TestKey.xLen );
	status = cryptSetAttributeString( *decryptContext,
									  CRYPT_CTXINFO_KEY_COMPONENTS, elgamalKey,
									  sizeof( CRYPT_PKCINFO_DLP ) );
	cryptDestroyComponents( elgamalKey );
	free( elgamalKey );
	if( cryptStatusError( status ) )
		{
		if( cryptContext != NULL )
			cryptDestroyContext( *cryptContext );
		cryptDestroyContext( *decryptContext );
		printf( "Private key load failed with error code %d, line %d.\n", 
				status, __LINE__ );
		return( FALSE );
		}

	return( TRUE );
	}

/* Load Diffie-Hellman encryption contexts */

BOOLEAN loadDHContexts( const CRYPT_DEVICE cryptDevice,
						CRYPT_CONTEXT *cryptContext,
						CRYPT_CONTEXT *decryptContext )
	{
	CRYPT_PKCINFO_DLP *dhKey;
	const BOOLEAN isDevice = ( cryptDevice != CRYPT_UNUSED ) ? TRUE : FALSE;
	int status;

	/* Allocate room for the public-key components */
	if( ( dhKey = ( CRYPT_PKCINFO_DLP * ) malloc( sizeof( CRYPT_PKCINFO_DLP ) ) ) == NULL )
		return( FALSE );

	/* Create the first encryption context */
	if( isDevice )
		{
		status = cryptDeviceCreateContext( cryptDevice, cryptContext,
										   CRYPT_ALGO_DH );
		}
	else
		{
		status = cryptCreateContext( cryptContext, CRYPT_UNUSED, 
									 CRYPT_ALGO_DH );
		}
	if( cryptStatusError( status ) )
		{
		free( dhKey );
		if( status == CRYPT_ERROR_NOTAVAIL )
			{
			/* DH support isn't always enabled, in which case we tell the 
			   caller to skip the test */
			return( status );
			}
		fprintf( outputStream, "cryptCreateContext() failed with error "
				 "code %d, line %d.\n", status, __LINE__ );
		return( FALSE );
		}
	if( !setLabel( *cryptContext, DH_KEY1_LABEL ) )
		{
		free( dhKey );
		cryptDestroyContext( *cryptContext );
		return( FALSE );
		}
	cryptInitComponents( dhKey, CRYPT_KEYTYPE_PUBLIC );
	cryptSetComponent( dhKey->p, dlp1024TestKey.p, dlp1024TestKey.pLen );
	cryptSetComponent( dhKey->q, dlp1024TestKey.q, dlp1024TestKey.qLen );
	cryptSetComponent( dhKey->g, dlp1024TestKey.g, dlp1024TestKey.gLen );
	cryptSetComponent( dhKey->y, dlp1024TestKey.y, dlp1024TestKey.yLen );
	status = cryptSetAttributeString( *cryptContext,
									  CRYPT_CTXINFO_KEY_COMPONENTS, dhKey,
									  sizeof( CRYPT_PKCINFO_DLP ) );
	cryptDestroyComponents( dhKey );
	if( cryptStatusError( status ) )
		{
		free( dhKey );
		printf( "DH #1 key load failed with error code %d, line %d.\n", 
				status, __LINE__ );
		return( FALSE );
		}
	if( decryptContext == NULL )
		{
		free( dhKey );
		return( TRUE );
		}

	/* Create the second encryption context */
	status = cryptCreateContext( decryptContext, CRYPT_UNUSED, CRYPT_ALGO_DH );
	if( cryptStatusError( status ) )
		{
		free( dhKey );
		fprintf( outputStream, "cryptCreateContext() failed with error "
				 "code %d, line %d.\n", status, __LINE__ );
		return( FALSE );
		}
	if( !setLabel( *decryptContext, DH_KEY2_LABEL ) )
		{
		free( dhKey );
		if( isDevice )
			{
			cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
							DH_KEY1_LABEL );
			}
		cryptDestroyContext( *cryptContext );
		cryptDestroyContext( *decryptContext );
		return( FALSE );
		}
	cryptInitComponents( dhKey, CRYPT_KEYTYPE_PUBLIC );
	cryptSetComponent( dhKey->p, dlp1024TestKey.p, dlp1024TestKey.pLen );
	cryptSetComponent( dhKey->q, dlp1024TestKey.q, dlp1024TestKey.qLen );
	cryptSetComponent( dhKey->g, dlp1024TestKey.g, dlp1024TestKey.gLen );
	cryptSetComponent( dhKey->x, dlp1024TestKey.x, dlp1024TestKey.xLen );
	cryptSetComponent( dhKey->y, dlp1024TestKey.y, dlp1024TestKey.yLen );
	status = cryptSetAttributeString( *decryptContext,
									  CRYPT_CTXINFO_KEY_COMPONENTS, dhKey,
									  sizeof( CRYPT_PKCINFO_DLP ) );
	cryptDestroyComponents( dhKey );
	free( dhKey );
	if( cryptStatusError( status ) )
		{
		if( isDevice )
			{
			cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
							DH_KEY1_LABEL );
			cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
							DH_KEY2_LABEL );
			}
		printf( "DH #2 key load failed with error code %d, line %d.\n", 
				status, __LINE__ );
		return( FALSE );
		}

	return( TRUE );
	}

/* Load ECDSA/ECDH encryption contexts */

BOOLEAN loadECDSAContextsEx( const CRYPT_DEVICE cryptDevice,
							 CRYPT_CONTEXT *sigCheckContext,
							 CRYPT_CONTEXT *signContext,
							 const C_STR sigCheckContextLabel,
							 const C_STR signContextLabel )
	{
	CRYPT_PKCINFO_ECC *eccKey;
	const BOOLEAN isDevice = ( cryptDevice != CRYPT_UNUSED ) ? TRUE : FALSE;
	const ECC_KEY *eccKeyData = &eccP256TestKey;
	int status;

	/* Allocate room for the public-key components */
	if( ( eccKey = ( CRYPT_PKCINFO_ECC * ) malloc( sizeof( CRYPT_PKCINFO_ECC ) ) ) == NULL )
		return( FALSE );

	/* Create the signature context */
	if( signContext != NULL )
		{
		if( isDevice )
			{
			status = cryptDeviceCreateContext( cryptDevice, signContext,
											   CRYPT_ALGO_ECDSA );
			}
		else
			{
			status = cryptCreateContext( signContext, CRYPT_UNUSED,
										 CRYPT_ALGO_ECDSA );
			}
		if( cryptStatusError( status ) )
			{
			free( eccKey );
			if( status == CRYPT_ERROR_NOTAVAIL )
				{
				/* ECDSA support isn't always enabled, in which case we tell 
				   the caller to skip the test */
				return( status );
				}
			fprintf( outputStream, "cryptCreateContext() failed with error "
					 "code %d, line %d.\n", status, __LINE__ );
			return( FALSE );
			}
		if( !setLabel( *signContext, signContextLabel ) )
			{
			free( eccKey );
			cryptDestroyContext( *signContext );
			return( FALSE );
			}
		cryptInitComponents( eccKey, CRYPT_KEYTYPE_PRIVATE );
		eccKey->curveType = CRYPT_ECCCURVE_P256;
		if( eccKeyData->pLen > 0 )
			{
			cryptSetComponent( eccKey->p, eccKeyData->p, eccKeyData->pLen );
			cryptSetComponent( eccKey->a, eccKeyData->a, eccKeyData->aLen );
			cryptSetComponent( eccKey->b, eccKeyData->b, eccKeyData->bLen );
			cryptSetComponent( eccKey->gx, eccKeyData->gx, eccKeyData->gxLen );
			cryptSetComponent( eccKey->gy, eccKeyData->gy, eccKeyData->gyLen );
			cryptSetComponent( eccKey->n, eccKeyData->n, eccKeyData->nLen );
			}
		cryptSetComponent( eccKey->qx, eccKeyData->qx, eccKeyData->qxLen );
		cryptSetComponent( eccKey->qy, eccKeyData->qy, eccKeyData->qyLen );
		cryptSetComponent( eccKey->d, eccKeyData->d, eccKeyData->dLen );
		status = cryptSetAttributeString( *signContext,
									CRYPT_CTXINFO_KEY_COMPONENTS, eccKey,
									sizeof( CRYPT_PKCINFO_ECC ) );
		cryptDestroyComponents( eccKey );
		if( cryptStatusError( status ) )
			{
			free( eccKey );
			cryptDestroyContext( *signContext );
			printf( "Private key load failed with error code %d, line %d.\n", 
					status, __LINE__ );
			return( FALSE );
			}
		if( sigCheckContext == NULL )
			{
			free( eccKey );
			return( TRUE );
			}
		}

	/* Create the sig.check context */
	if( isDevice )
		{
		status = cryptDeviceCreateContext( cryptDevice, sigCheckContext,
										   CRYPT_ALGO_ECDSA );
		}
	else
		{
		status = cryptCreateContext( sigCheckContext, CRYPT_UNUSED,
									 CRYPT_ALGO_ECDSA );
		}
	if( cryptStatusError( status ) )
		{
		free( eccKey );
		if( signContext != NULL )
			{
			cryptDestroyContext( *signContext );
			if( isDevice )
				{
				cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
								signContextLabel );
				}
			}
		fprintf( outputStream, "cryptCreateContext() failed with error "
				 "code %d, line %d.\n", status, __LINE__ );
		return( FALSE );
		}
	if( !setLabel( *sigCheckContext, sigCheckContextLabel ) )
		{
		free( eccKey );
		if( signContext != NULL )
			{
			cryptDestroyContext( *signContext );
			if( isDevice )
				{
				cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
								signContextLabel );
				}
			}
		cryptDestroyContext( *sigCheckContext );
		return( FALSE );
		}
	cryptInitComponents( eccKey, CRYPT_KEYTYPE_PUBLIC );
	eccKey->curveType = CRYPT_ECCCURVE_P256;
	if( eccKeyData->pLen > 0 )
		{
		cryptSetComponent( eccKey->p, eccKeyData->p, eccKeyData->pLen );
		cryptSetComponent( eccKey->a, eccKeyData->a, eccKeyData->aLen );
		cryptSetComponent( eccKey->b, eccKeyData->b, eccKeyData->bLen );
		cryptSetComponent( eccKey->gx, eccKeyData->gx, eccKeyData->gxLen );
		cryptSetComponent( eccKey->gy, eccKeyData->gy, eccKeyData->gyLen );
		cryptSetComponent( eccKey->n, eccKeyData->n, eccKeyData->nLen );
		}
	cryptSetComponent( eccKey->qx, eccKeyData->qx, eccKeyData->qxLen );
	cryptSetComponent( eccKey->qy, eccKeyData->qy, eccKeyData->qyLen );
	status = cryptSetAttributeString( *sigCheckContext,
									  CRYPT_CTXINFO_KEY_COMPONENTS, eccKey,
									  sizeof( CRYPT_PKCINFO_ECC ) );
	cryptDestroyComponents( eccKey );
	free( eccKey );
	if( cryptStatusError( status ) )
		{
		if( signContext != NULL )
			{
			cryptDestroyContext( *signContext );
			if( isDevice )
				{
				cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
								signContextLabel );
				}
			}
		cryptDestroyContext( *sigCheckContext );
		printf( "Public key load failed with error code %d, line %d.\n", 
				status, __LINE__ );
		return( FALSE );
		}

	return( TRUE );
	}

BOOLEAN loadECDSAContexts( const CRYPT_DEVICE cryptDevice,
						   CRYPT_CONTEXT *sigCheckContext,
						   CRYPT_CONTEXT *signContext )
	{
	return( loadECDSAContextsEx( cryptDevice, sigCheckContext, signContext, 
								 ECDSA_PUBKEY_LABEL, ECDSA_PRIVKEY_LABEL ) );
	}

BOOLEAN loadECDHContexts( const CRYPT_DEVICE cryptDevice,
						  CRYPT_CONTEXT *cryptContext,
						  CRYPT_CONTEXT *decryptContext )
	{
	return( loadECDSAContextsEx( cryptDevice, cryptContext, decryptContext, 
								 ECDSA_PUBKEY_LABEL, ECDSA_PRIVKEY_LABEL ) );
	}

/* Load 25519 encryption contexts */

static BOOLEAN load25519Contexts( const CRYPT_DEVICE cryptDevice,
								  CRYPT_CONTEXT *sigCheckContext,
								  CRYPT_CONTEXT *signContext,
								  const BOOLEAN isX25519 )
	{
	CRYPT_PKCINFO_DJB *curve25519Key;
	const CRYPT_ALGO_TYPE cryptAlgo = isX25519 ? CRYPT_ALGO_25519 : \
												 CRYPT_ALGO_ED25519;
	const BOOLEAN isDevice = ( cryptDevice != CRYPT_UNUSED ) ? TRUE : FALSE;
	const CURVE25519_KEY *curve25519KeyData = isX25519 ? &x25519TestKey : \
														 &ed25519TestKey;
	int status;

	/* Allocate room for the public-key components */
	if( ( curve25519Key = ( CRYPT_PKCINFO_DJB * ) malloc( sizeof( CRYPT_PKCINFO_DJB ) ) ) == NULL )
		return( FALSE );

	/* Create the signature context */
	if( signContext != NULL )
		{
		if( isDevice )
			{
			status = cryptDeviceCreateContext( cryptDevice, signContext,
											   cryptAlgo );
			}
		else
			{
			status = cryptCreateContext( signContext, CRYPT_UNUSED,
										 cryptAlgo );
			}
		if( cryptStatusError( status ) )
			{
			free( curve25519Key );
			if( status == CRYPT_ERROR_NOTAVAIL )
				{
				/* ECDSA support isn't always enabled, in which case we tell 
				   the caller to skip the test */
				return( status );
				}
			fprintf( outputStream, "cryptCreateContext() failed with error "
					 "code %d, line %d.\n", status, __LINE__ );
			return( FALSE );
			}
		if( !setLabel( *signContext, ED25519_PRIVKEY_LABEL ) )
			{
			free( curve25519Key );
			cryptDestroyContext( *signContext );
			return( FALSE );
			}
		cryptInitComponents( curve25519Key, CRYPT_KEYTYPE_PRIVATE );
		cryptSetComponent( curve25519Key->priv, curve25519KeyData->priv, curve25519KeyData->privLen );
		cryptSetComponent( curve25519Key->pub, curve25519KeyData->pub, curve25519KeyData->pubLen );
		status = cryptSetAttributeString( *signContext,
									CRYPT_CTXINFO_KEY_COMPONENTS, curve25519Key,
									sizeof( CRYPT_PKCINFO_DJB ) );
		cryptDestroyComponents( curve25519Key );
		if( cryptStatusError( status ) )
			{
			free( curve25519Key );
			cryptDestroyContext( *signContext );
			printf( "Private key load failed with error code %d, line %d.\n", 
					status, __LINE__ );
			return( FALSE );
			}
		if( sigCheckContext == NULL )
			{
			free( curve25519Key );
			return( TRUE );
			}
		}

	/* Create the sig.check context */
	if( isDevice )
		{
		status = cryptDeviceCreateContext( cryptDevice, sigCheckContext,
										   cryptAlgo );
		}
	else
		{
		status = cryptCreateContext( sigCheckContext, CRYPT_UNUSED,
									 cryptAlgo );
		}
	if( cryptStatusError( status ) )
		{
		free( curve25519Key );
		if( signContext != NULL )
			{
			cryptDestroyContext( *signContext );
			if( isDevice )
				{
				cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
								ED25519_PRIVKEY_LABEL );
				}
			}
		fprintf( outputStream, "cryptCreateContext() failed with error "
				 "code %d, line %d.\n", status, __LINE__ );
		return( FALSE );
		}
	if( !setLabel( *sigCheckContext, ED25519_PUBKEY_LABEL ) )
		{
		free( curve25519Key );
		if( signContext != NULL )
			{
			cryptDestroyContext( *signContext );
			if( isDevice )
				{
				cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
								ED25519_PRIVKEY_LABEL );
				}
			}
		cryptDestroyContext( *sigCheckContext );
		return( FALSE );
		}
	cryptInitComponents( curve25519Key, CRYPT_KEYTYPE_PUBLIC );
	cryptSetComponent( curve25519Key->pub, curve25519KeyData->pub, curve25519KeyData->pubLen );
	status = cryptSetAttributeString( *sigCheckContext,
									  CRYPT_CTXINFO_KEY_COMPONENTS, 
									  curve25519Key,
									  sizeof( CRYPT_PKCINFO_DJB ) );
	cryptDestroyComponents( curve25519Key );
	free( curve25519Key );
	if( cryptStatusError( status ) )
		{
		if( signContext != NULL )
			{
			cryptDestroyContext( *signContext );
			if( isDevice )
				{
				cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
								ECDSA_PRIVKEY_LABEL );
				}
			}
		cryptDestroyContext( *sigCheckContext );
		printf( "Public key load failed with error code %d, line %d.\n", 
				status, __LINE__ );
		return( FALSE );
		}

	return( TRUE );
	}

BOOLEAN loadX25519Contexts( const CRYPT_DEVICE cryptDevice,
							CRYPT_CONTEXT *cryptContext,
							CRYPT_CONTEXT *decryptContext )
	{
	return( load25519Contexts( cryptDevice, cryptContext,
							   decryptContext, TRUE ) );
	}

BOOLEAN loadEd25519Contexts( const CRYPT_DEVICE cryptDevice,
							 CRYPT_CONTEXT *sigCheckContext,
							 CRYPT_CONTEXT *signContext )
	{
	return( load25519Contexts( cryptDevice, sigCheckContext,
							   signContext, FALSE ) );
	}

/* Load ML-KEM encryption contexts */

BOOLEAN loadMLKEMContexts( const CRYPT_DEVICE cryptDevice,
						   CRYPT_CONTEXT *encContext,
						   CRYPT_CONTEXT *decContext )
	{
	CRYPT_PKCINFO_PQC *pqcKey;
	const BOOLEAN isDevice = ( cryptDevice != CRYPT_UNUSED ) ? TRUE : FALSE;
	const MLKEM_KEY *mlkemKeyData = &mlKemTestKey;
	int status;

	/* Allocate room for the public-key components */
	if( ( pqcKey = ( CRYPT_PKCINFO_PQC * ) malloc( sizeof( CRYPT_PKCINFO_PQC ) ) ) == NULL )
		return( FALSE );

	/* Create the decapsulation context */
	if( decContext != NULL )
		{
		if( isDevice )
			{
			status = cryptDeviceCreateContext( cryptDevice, decContext,
											   CRYPT_ALGO_MLKEM );
			}
		else
			{
			status = cryptCreateContext( decContext, CRYPT_UNUSED,
										 CRYPT_ALGO_MLKEM );
			}
		if( cryptStatusError( status ) )
			{
			free( pqcKey );
			if( status == CRYPT_ERROR_NOTAVAIL )
				{
				/* ML-KEM support isn't always enabled, in which case we tell 
				   the caller to skip the test */
				return( status );
				}
			fprintf( outputStream, "cryptCreateContext() failed with error "
					 "code %d, line %d.\n", status, __LINE__ );
			return( FALSE );
			}
		if( !setLabel( *decContext, MLKEM_PRIVKEY_LABEL ) )
			{
			free( pqcKey );
			cryptDestroyContext( *decContext );
			return( FALSE );
			}
		cryptInitComponents( pqcKey, CRYPT_KEYTYPE_PRIVATE );
		cryptSetComponent( pqcKey->priv, mlkemKeyData->priv, mlkemKeyData->privLen );
		cryptSetComponent( pqcKey->pub, mlkemKeyData->pub, mlkemKeyData->pubLen );
		status = cryptSetAttributeString( *decContext,
									CRYPT_CTXINFO_KEY_COMPONENTS, pqcKey,
									sizeof( CRYPT_PKCINFO_PQC ) );
		cryptDestroyComponents( pqcKey );
		if( cryptStatusError( status ) )
			{
			free( pqcKey );
			cryptDestroyContext( *decContext );
			printf( "Private key load failed with error code %d, line %d.\n", 
					status, __LINE__ );
			return( FALSE );
			}
		if( encContext == NULL )
			{
			free( pqcKey );
			return( TRUE );
			}
		}

	/* Create the sig.check context */
	if( isDevice )
		{
		status = cryptDeviceCreateContext( cryptDevice, encContext,
										   CRYPT_ALGO_MLKEM );
		}
	else
		{
		status = cryptCreateContext( encContext, CRYPT_UNUSED,
									 CRYPT_ALGO_MLKEM );
		}
	if( cryptStatusError( status ) )
		{
		free( pqcKey );
		if( decContext != NULL )
			{
			cryptDestroyContext( *decContext );
			if( isDevice )
				{
				cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
								MLKEM_PRIVKEY_LABEL );
				}
			}
		fprintf( outputStream, "cryptCreateContext() failed with error "
				 "code %d, line %d.\n", status, __LINE__ );
		return( FALSE );
		}
	if( !setLabel( *encContext, MLKEM_PUBKEY_LABEL ) )
		{
		free( pqcKey );
		if( decContext != NULL )
			{
			cryptDestroyContext( *decContext );
			if( isDevice )
				{
				cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
								MLKEM_PRIVKEY_LABEL );
				}
			}
		cryptDestroyContext( *encContext );
		return( FALSE );
		}
	cryptInitComponents( pqcKey, CRYPT_KEYTYPE_PUBLIC );
	cryptSetComponent( pqcKey->pub, mlkemKeyData->pub, mlkemKeyData->pubLen );
	status = cryptSetAttributeString( *encContext,
									  CRYPT_CTXINFO_KEY_COMPONENTS, pqcKey,
									  sizeof( CRYPT_PKCINFO_PQC ) );
	cryptDestroyComponents( pqcKey );
	free( pqcKey );
	if( cryptStatusError( status ) )
		{
		if( decContext != NULL )
			{
			cryptDestroyContext( *decContext );
			if( isDevice )
				{
				cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME,
								MLKEM_PRIVKEY_LABEL );
				}
			}
		cryptDestroyContext( *encContext );
		printf( "Public key load failed with error code %d, line %d.\n", 
				status, __LINE__ );
		return( FALSE );
		}

	return( TRUE );
	}

/* Destroy the encryption contexts */

void destroyContexts( const CRYPT_DEVICE cryptDevice,
					  const CRYPT_CONTEXT cryptContext,
					  const CRYPT_CONTEXT decryptContext )
	{
	int cryptAlgo, status;

	status = cryptGetAttribute( cryptContext, CRYPT_CTXINFO_ALGO, 
								&cryptAlgo );
	if( cryptStatusError( status ) )
		cryptAlgo = CRYPT_ALGO_RSA;
	status = cryptDestroyContext( cryptContext );
	if( cryptStatusError( status ) )
		{
		printf( "cryptDestroyContext() failed with error code %d, "
				"line %d.\n", status, __LINE__ );
		}
	status = cryptDestroyContext( decryptContext );
	if( cryptStatusError( status ) )
		{
		printf( "cryptDestroyContext() failed with error code %d, "
				"line %d.\n", status, __LINE__ );
		}
	if( cryptDevice == CRYPT_UNUSED )
		return;

	/* If the context is associated with a device then creating the object
	   will generally also create a persistent object in the device, after
	   performing the tests we have to explicitly delete the persistent
	   object */
	switch( cryptAlgo )
		{
		case CRYPT_ALGO_RSA:
			cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME, RSA_PUBKEY_LABEL );
			cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME, RSA_PRIVKEY_LABEL );
			break;

		case CRYPT_ALGO_DSA:
			cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME, DSA_PUBKEY_LABEL );
			cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME, DSA_PRIVKEY_LABEL );
			break;

		case CRYPT_ALGO_ECDSA:
			cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME, ECDSA_PUBKEY_LABEL );
			cryptDeleteKey( cryptDevice, CRYPT_KEYID_NAME, ECDSA_PRIVKEY_LABEL );
			break;

		default:
			/* No special-case handling */
			break;
		}
	}
