58 PKC_INFO *sourcePkcInfo = contextInfoPtr->ctxPKC;
59 PKC_INFO contextData, *pkcInfo = &contextData;
70 status = staticInitContext( &checkContextInfo,
CONTEXT_PKC,
72 sizeof( PKC_INFO ), NULL );
75 CKPTR(
BN_copy( &pkcInfo->dlpParam_p, &sourcePkcInfo->dlpParam_p ) );
76 CKPTR(
BN_copy( &pkcInfo->dlpParam_g, &sourcePkcInfo->dlpParam_g ) );
77 CKPTR(
BN_copy( &pkcInfo->dlpParam_q, &sourcePkcInfo->dlpParam_q ) );
78 CKPTR(
BN_copy( &pkcInfo->dlpParam_y, &sourcePkcInfo->dlpParam_y ) );
79 CKPTR(
BN_copy( &pkcInfo->dlpParam_x, &sourcePkcInfo->dlpParam_x ) );
82 staticDestroyContext( &checkContextInfo );
90 status = capabilityInfoPtr->initKeyFunction( &checkContextInfo, NULL, 0 );
92 status = capabilityInfoPtr->encryptFunction( contextInfoPtr,
95 status = capabilityInfoPtr->encryptFunction( &checkContextInfo,
98 status = capabilityInfoPtr->decryptFunction( contextInfoPtr,
101 status = capabilityInfoPtr->decryptFunction( &checkContextInfo,
105 memcmp( keyAgreeParams1.wrappedKey, keyAgreeParams2.wrappedKey,
110 staticDestroyContext( &checkContextInfo );
115 #ifndef CONFIG_NO_SELFTEST
123 const int pLen;
const BYTE p[ 128 ];
124 const int qLen;
const BYTE q[ 20 ];
125 const int gLen;
const BYTE g[ 128 ];
126 const int xLen;
const BYTE x[ 20 ];
127 const int yLen;
const BYTE y[ 128 ];
133 { 0x04, 0x4C, 0xDD, 0x5D, 0xB6, 0xED, 0x23, 0xAE,
134 0xB2, 0xA7, 0x59, 0xE6, 0xF8, 0x3D, 0xA6, 0x27,
135 0x85, 0xF2, 0xFE, 0xE2, 0xE8, 0xF3, 0xDA, 0xA3,
136 0x7B, 0xD6, 0x48, 0xD4, 0x44, 0xCA, 0x6E, 0x10,
137 0x97, 0x6C, 0x1D, 0x6C, 0x39, 0xA7, 0x0C, 0x88,
138 0x8E, 0x1F, 0xDD, 0xF7, 0x59, 0x69, 0xDA, 0x36,
139 0xDD, 0xB8, 0x3E, 0x1A, 0xD2, 0x91, 0x3E, 0x30,
140 0xB1, 0xB5, 0xC2, 0xBC, 0xA9, 0xA3, 0xA5, 0xDE,
141 0xC7, 0xCF, 0x51, 0x2C, 0x1B, 0x89, 0xD0, 0x71,
142 0xE3, 0x71, 0xBB, 0x50, 0x86, 0x26, 0x32, 0x9F,
143 0xF5, 0x4A, 0x9C, 0xB1, 0x78, 0x7B, 0x47, 0x1F,
144 0x19, 0xC7, 0x26, 0x22, 0x15, 0x62, 0x71, 0xAB,
145 0xD7, 0x25, 0xA5, 0xE4, 0x68, 0x71, 0x93, 0x5D,
146 0x1F, 0x29, 0x01, 0x05, 0x9C, 0x57, 0x3A, 0x09,
147 0xB0, 0xB8, 0xE4, 0xD2, 0x37, 0x90, 0x36, 0x2F,
148 0xBF, 0x1E, 0x74, 0xB4, 0x6B, 0xE4, 0x66, 0x07 },
152 { 0xFD, 0xD9, 0xC8, 0x5F, 0x73, 0x62, 0xC9, 0x79,
153 0xEF, 0xD5, 0x09, 0x07, 0x02, 0xE7, 0xF2, 0x90,
154 0x97, 0x13, 0x26, 0x1D },
158 { 0x02, 0x4E, 0xDD, 0x0D, 0x7F, 0x4D, 0xB1, 0x42,
159 0x01, 0x50, 0xE7, 0x9A, 0x65, 0x73, 0x8B, 0x31,
160 0x24, 0x6B, 0xC6, 0x74, 0xA7, 0x68, 0x26, 0x11,
161 0x06, 0x3C, 0x96, 0xA9, 0xA6, 0x23, 0x12, 0x79,
162 0xC4, 0xEE, 0x21, 0x88, 0xDD, 0xE3, 0xF0, 0x37,
163 0xCE, 0x3E, 0x54, 0x53, 0x57, 0x03, 0x30, 0xE4,
164 0xD3, 0xAB, 0x39, 0x4E, 0x39, 0xDC, 0xA2, 0x88,
165 0x82, 0xF6, 0xE8, 0xBA, 0xAC, 0xF5, 0x7D, 0x2F,
166 0x23, 0x9A, 0x09, 0x94, 0xB2, 0x89, 0xA2, 0xC9,
167 0x7C, 0xBE, 0x4D, 0x48, 0x0E, 0x59, 0x51, 0xB8,
168 0x7D, 0x99, 0x88, 0x79, 0xA8, 0x13, 0x0E, 0x12,
169 0x56, 0x9D, 0x4B, 0x2E, 0xE0, 0xE1, 0x37, 0x78,
170 0x6F, 0xCC, 0x4D, 0x97, 0xA9, 0x02, 0x0E, 0xD2,
171 0x43, 0x83, 0xEC, 0x4F, 0xC2, 0x70, 0xEF, 0x16,
172 0xDE, 0xBF, 0xBA, 0xD1, 0x6C, 0x8A, 0x36, 0xEE,
173 0x42, 0x41, 0xE9, 0xE7, 0x66, 0xAE, 0x46, 0x3B },
177 { 0xD9, 0x41, 0x29, 0xF7, 0x40, 0x32, 0x09, 0x71,
178 0xB8, 0xE2, 0xB8, 0xCB, 0x74, 0x46, 0x0B, 0xD4,
179 0xF2, 0xAB, 0x54, 0xA1 },
183 { 0x01, 0x7E, 0x16, 0x5B, 0x65, 0x51, 0x0A, 0xDA,
184 0x82, 0x1A, 0xD9, 0xF4, 0x1E, 0x66, 0x6D, 0x7D,
185 0x23, 0xA6, 0x28, 0x2F, 0xE6, 0xC2, 0x03, 0x8E,
186 0x8C, 0xAB, 0xC2, 0x08, 0x87, 0xC9, 0xE8, 0x51,
187 0x0A, 0x37, 0x1E, 0xD4, 0x41, 0x7F, 0xA2, 0xC5,
188 0x48, 0x26, 0xB7, 0xF6, 0xC2, 0x6F, 0xB2, 0xF8,
189 0xF9, 0x43, 0x43, 0xF9, 0xDA, 0xAB, 0xA2, 0x59,
190 0x27, 0xBA, 0xC9, 0x1C, 0x8C, 0xAB, 0xC4, 0x90,
191 0x27, 0xE1, 0x10, 0x39, 0x6F, 0xD2, 0xCD, 0x7C,
192 0xD1, 0x0B, 0xFA, 0x28, 0xD2, 0x7A, 0x7B, 0x52,
193 0x8A, 0xA0, 0x5A, 0x0F, 0x10, 0xF7, 0xBA, 0xFD,
194 0x33, 0x0C, 0x3C, 0xCE, 0xE5, 0xF2, 0xF6, 0x92,
195 0xED, 0x04, 0xBF, 0xD3, 0xF8, 0x3D, 0x39, 0xCC,
196 0xAA, 0xCC, 0x0B, 0xB2, 0x6B, 0xD8, 0xB2, 0x8A,
197 0x5C, 0xCE, 0xDA, 0xF9, 0xE1, 0xA7, 0x23, 0x50,
198 0xDC, 0xCE, 0xA4, 0xD5, 0xA5, 0x4F, 0x08, 0x0F }
202 static
int selfTest(
void )
205 PKC_INFO contextData, *pkcInfo = &contextData;
209 status = staticInitContext( &contextInfo,
CONTEXT_PKC,
211 sizeof( PKC_INFO ), NULL );
214 status = importBignum( &pkcInfo->dlpParam_p, dlpTestKey.p,
218 status = importBignum( &pkcInfo->dlpParam_g, dlpTestKey.g,
223 status = importBignum( &pkcInfo->dlpParam_q, dlpTestKey.q,
228 status = importBignum( &pkcInfo->dlpParam_y, dlpTestKey.y,
233 status = importBignum( &pkcInfo->dlpParam_x, dlpTestKey.x,
239 staticDestroyContext( &contextInfo );
244 status = contextInfo.
capabilityInfo->initKeyFunction( &contextInfo, NULL, 0 );
246 !pairwiseConsistencyTest( &contextInfo ) )
250 staticDestroyContext( &contextInfo );
255 #define selfTest NULL
273 PKC_INFO *pkcInfo = contextInfoPtr->ctxPKC;
288 &pkcInfo->dlpParam_y );
310 PKC_INFO *pkcInfo = contextInfoPtr->ctxPKC;
311 BIGNUM *z = &pkcInfo->tmp1;
316 assert(
isReadPtr( keyAgreeParams->publicValue,
325 status = importBignum( &pkcInfo->dhParam_yPrime,
326 keyAgreeParams->publicValue,
337 &pkcInfo->dlpParam_p, pkcInfo->bnCTX,
338 &pkcInfo->dlpParam_mont_p ) );
369 PKC_INFO *pkcInfo = contextInfoPtr->ctxPKC;
372 assert( ( key == NULL && keyLength == 0 ) || \
376 REQUIRES( ( key == NULL && keyLength == 0 ) || \
387 contextInfoPtr->flags |= ( dhKey->
isPublicKey ) ? \
389 status = importBignum( &pkcInfo->dlpParam_p, dhKey->
p,
394 status = importBignum( &pkcInfo->dlpParam_g, dhKey->
g,
397 &pkcInfo->dlpParam_p,
400 status = importBignum( &pkcInfo->dlpParam_q, dhKey->
q,
403 &pkcInfo->dlpParam_p,
406 status = importBignum( &pkcInfo->dlpParam_y, dhKey->
y,
409 &pkcInfo->dlpParam_p,
412 status = importBignum( &pkcInfo->dlpParam_x, dhKey->
x,
415 &pkcInfo->dlpParam_p,
417 contextInfoPtr->flags |= CONTEXT_FLAG_PBO;
428 return( initCheckDLPkey( contextInfoPtr,
TRUE,
438 const int keySizeBits )
447 status = generateDLPkey( contextInfoPtr, keySizeBits );
452 !pairwiseConsistencyTest( contextInfoPtr ) )
454 DEBUG_DIAG((
"Consistency check of freshly-generated DH key "
471 selfTest, getDefaultInfo, NULL, NULL, initKey, generateKey, encryptFn, decryptFn
476 return( &capabilityInfo );