58 PKC_INFO contextData, *pkcInfo = &contextData;
59 PKC_INFO *sourcePkcInfo = contextInfoPtr->ctxPKC;
70 status = staticInitContext( &checkContextInfo,
CONTEXT_PKC,
72 sizeof( PKC_INFO ), NULL );
76 CKPTR(
BN_copy( &pkcInfo->eccParam_qx, &sourcePkcInfo->eccParam_qx ) );
77 CKPTR(
BN_copy( &pkcInfo->eccParam_qy, &sourcePkcInfo->eccParam_qy ) );
78 CKPTR(
BN_copy( &pkcInfo->eccParam_d, &sourcePkcInfo->eccParam_d ) );
81 staticDestroyContext( &checkContextInfo );
89 status = capabilityInfoPtr->initKeyFunction( &checkContextInfo, NULL, 0 );
91 status = capabilityInfoPtr->encryptFunction( contextInfoPtr,
94 status = capabilityInfoPtr->encryptFunction( &checkContextInfo,
97 status = capabilityInfoPtr->decryptFunction( contextInfoPtr,
100 status = capabilityInfoPtr->decryptFunction( &checkContextInfo,
104 memcmp( keyAgreeParams1.wrappedKey, keyAgreeParams2.wrappedKey,
109 staticDestroyContext( &checkContextInfo );
114 #ifndef CONFIG_NO_SELFTEST
123 const int qxLen;
const BYTE qx[ 32 ];
124 const int qyLen;
const BYTE qy[ 32 ];
125 const int dLen;
const BYTE d[ 32 ];
131 { 0x59, 0x63, 0x75, 0xE6, 0xCE, 0x57, 0xE0, 0xF2,
132 0x02, 0x94, 0xFC, 0x46, 0xBD, 0xFC, 0xFD, 0x19,
133 0xA3, 0x9F, 0x81, 0x61, 0xB5, 0x86, 0x95, 0xB3,
134 0xEC, 0x5B, 0x3D, 0x16, 0x42, 0x7C, 0x27, 0x4D },
137 { 0x42, 0x75, 0x4D, 0xFD, 0x25, 0xC5, 0x6F, 0x93,
138 0x9A, 0x79, 0xF2, 0xB2, 0x04, 0x87, 0x6B, 0x3A,
139 0x3A, 0xB1, 0xCE, 0xB2, 0xE4, 0xFF, 0x57, 0x1A,
140 0xBF, 0x4F, 0xBF, 0x36, 0x32, 0x6C, 0x8B, 0x27 },
143 { 0x2C, 0xA1, 0x41, 0x1A, 0x41, 0xB1, 0x7B, 0x24,
144 0xCC, 0x8C, 0x3B, 0x08, 0x9C, 0xFD, 0x03, 0x3F,
145 0x19, 0x20, 0x20, 0x2A, 0x6C, 0x0D, 0xE8, 0xAB,
146 0xB9, 0x7D, 0xF1, 0x49, 0x8D, 0x50, 0xD2, 0xC8 }
150 static
int selfTest(
void )
153 PKC_INFO contextData, *pkcInfo = &contextData;
157 status = staticInitContext( &contextInfo,
CONTEXT_PKC,
159 sizeof( PKC_INFO ), NULL );
163 status = importBignum( &pkcInfo->eccParam_qx, ecdhTestKey.qx,
167 status = importBignum( &pkcInfo->eccParam_qy, ecdhTestKey.qy,
171 status = importBignum( &pkcInfo->eccParam_d, ecdhTestKey.d,
176 staticDestroyContext( &contextInfo );
181 status = contextInfo.
capabilityInfo->initKeyFunction( &contextInfo, NULL, 0 );
183 !pairwiseConsistencyTest( &contextInfo ) )
187 staticDestroyContext( &contextInfo );
192 #define selfTest NULL
210 PKC_INFO *pkcInfo = contextInfoPtr->ctxPKC;
226 &pkcInfo->eccParam_qx, &pkcInfo->eccParam_qy,
249 PKC_INFO *pkcInfo = contextInfoPtr->ctxPKC;
252 BIGNUM *x = &pkcInfo->tmp1, *y = &pkcInfo->tmp2;
257 assert(
isReadPtr( keyAgreeParams->publicValue,
267 status = importECCPoint( &pkcInfo->eccParam_qx, &pkcInfo->eccParam_qy,
268 keyAgreeParams->publicValue,
279 &pkcInfo->eccParam_qx,
280 &pkcInfo->eccParam_qy,
333 assert( ( key == NULL && keyLength == 0 ) || \
337 REQUIRES( ( key == NULL && keyLength == 0 ) || \
345 PKC_INFO *pkcInfo = contextInfoPtr->ctxPKC;
349 contextInfoPtr->flags |= ( eccKey->
isPublicKey ) ? \
353 status = importBignum( &pkcInfo->eccParam_p, eccKey->
p,
358 status = importBignum( &pkcInfo->eccParam_a, eccKey->
a,
363 status = importBignum( &pkcInfo->eccParam_b, eccKey->
b,
368 status = importBignum( &pkcInfo->eccParam_gx, eccKey->
gx,
373 status = importBignum( &pkcInfo->eccParam_gy, eccKey->
gy,
378 status = importBignum( &pkcInfo->eccParam_n, eccKey->
n,
392 status = importBignum( &pkcInfo->eccParam_qx, eccKey->
qx,
397 status = importBignum( &pkcInfo->eccParam_qy, eccKey->
qy,
402 status = importBignum( &pkcInfo->eccParam_d, eccKey->
d,
406 contextInfoPtr->flags |= CONTEXT_FLAG_PBO;
413 return( initCheckECCkey( contextInfoPtr,
TRUE ) );
421 const int keySizeBits )
430 status = generateECCkey( contextInfoPtr, keySizeBits );
435 !pairwiseConsistencyTest( contextInfoPtr ) )
437 DEBUG_DIAG((
"Consistency check of freshly-generated ECDH key "
454 selfTest, getDefaultInfo, NULL, NULL, initKey, generateKey, encryptFn, decryptFn
459 return( &capabilityInfo );