54 0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A,
55 0xBA, 0x3E, 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C,
56 0x9C, 0xD0, 0xD8, 0x9D
60 0x35, 0x8D, 0xAD, 0x57, 0x14, 0x62, 0x71, 0x0F,
61 0x50, 0xE2, 0x54, 0xCF, 0x1A, 0x37, 0x6B, 0x2B,
62 0xDE, 0xAA, 0xDF, 0xBF
80 status = capabilityInfoPtr->signFunction( contextInfoPtr,
86 sigSize = dlpParams.
outLen;
88 dlpParams.inParam2 =
buffer;
89 dlpParams.
inLen2 = sigSize;
90 status = capabilityInfoPtr->sigCheckFunction( contextInfoPtr,
95 #ifndef CONFIG_NO_SELFTEST
105 const int pLen;
const BYTE p[ 128 ];
106 const int qLen;
const BYTE q[ 20 ];
107 const int gLen;
const BYTE g[ 128 ];
108 const int xLen;
const BYTE x[ 20 ];
109 const int yLen;
const BYTE y[ 128 ];
114 static const DLP_PRIVKEY
FAR_BSS dlpTestKey = {
117 { 0x8D, 0xF2, 0xA4, 0x94, 0x49, 0x22, 0x76, 0xAA,
118 0x3D, 0x25, 0x75, 0x9B, 0xB0, 0x68, 0x69, 0xCB,
119 0xEA, 0xC0, 0xD8, 0x3A, 0xFB, 0x8D, 0x0C, 0xF7,
120 0xCB, 0xB8, 0x32, 0x4F, 0x0D, 0x78, 0x82, 0xE5,
121 0xD0, 0x76, 0x2F, 0xC5, 0xB7, 0x21, 0x0E, 0xAF,
122 0xC2, 0xE9, 0xAD, 0xAC, 0x32, 0xAB, 0x7A, 0xAC,
123 0x49, 0x69, 0x3D, 0xFB, 0xF8, 0x37, 0x24, 0xC2,
124 0xEC, 0x07, 0x36, 0xEE, 0x31, 0xC8, 0x02, 0x91 },
127 { 0xC7, 0x73, 0x21, 0x8C, 0x73, 0x7E, 0xC8, 0xEE,
128 0x99, 0x3B, 0x4F, 0x2D, 0xED, 0x30, 0xF4, 0x8E,
129 0xDA, 0xCE, 0x91, 0x5F },
132 { 0x62, 0x6D, 0x02, 0x78, 0x39, 0xEA, 0x0A, 0x13,
133 0x41, 0x31, 0x63, 0xA5, 0x5B, 0x4C, 0xB5, 0x00,
134 0x29, 0x9D, 0x55, 0x22, 0x95, 0x6C, 0xEF, 0xCB,
135 0x3B, 0xFF, 0x10, 0xF3, 0x99, 0xCE, 0x2C, 0x2E,
136 0x71, 0xCB, 0x9D, 0xE5, 0xFA, 0x24, 0xBA, 0xBF,
137 0x58, 0xE5, 0xB7, 0x95, 0x21, 0x92, 0x5C, 0x9C,
138 0xC4, 0x2E, 0x9F, 0x6F, 0x46, 0x4B, 0x08, 0x8C,
139 0xC5, 0x72, 0xAF, 0x53, 0xE6, 0xD7, 0x88, 0x02 },
142 { 0x20, 0x70, 0xB3, 0x22, 0x3D, 0xBA, 0x37, 0x2F,
143 0xDE, 0x1C, 0x0F, 0xFC, 0x7B, 0x2E, 0x3B, 0x49,
144 0x8B, 0x26, 0x06, 0x14 },
147 { 0x19, 0x13, 0x18, 0x71, 0xD7, 0x5B, 0x16, 0x12,
148 0xA8, 0x19, 0xF2, 0x9D, 0x78, 0xD1, 0xB0, 0xD7,
149 0x34, 0x6F, 0x7A, 0xA7, 0x7B, 0xB6, 0x2A, 0x85,
150 0x9B, 0xFD, 0x6C, 0x56, 0x75, 0xDA, 0x9D, 0x21,
151 0x2D, 0x3A, 0x36, 0xEF, 0x16, 0x72, 0xEF, 0x66,
152 0x0B, 0x8C, 0x7C, 0x25, 0x5C, 0xC0, 0xEC, 0x74,
153 0x85, 0x8F, 0xBA, 0x33, 0xF4, 0x4C, 0x06, 0x69,
154 0x96, 0x30, 0xA7, 0x6B, 0x03, 0x0E, 0xE3, 0x33 }
161 { 0x04, 0x4C, 0xDD, 0x5D, 0xB6, 0xED, 0x23, 0xAE,
162 0xB2, 0xA7, 0x59, 0xE6, 0xF8, 0x3D, 0xA6, 0x27,
163 0x85, 0xF2, 0xFE, 0xE2, 0xE8, 0xF3, 0xDA, 0xA3,
164 0x7B, 0xD6, 0x48, 0xD4, 0x44, 0xCA, 0x6E, 0x10,
165 0x97, 0x6C, 0x1D, 0x6C, 0x39, 0xA7, 0x0C, 0x88,
166 0x8E, 0x1F, 0xDD, 0xF7, 0x59, 0x69, 0xDA, 0x36,
167 0xDD, 0xB8, 0x3E, 0x1A, 0xD2, 0x91, 0x3E, 0x30,
168 0xB1, 0xB5, 0xC2, 0xBC, 0xA9, 0xA3, 0xA5, 0xDE,
169 0xC7, 0xCF, 0x51, 0x2C, 0x1B, 0x89, 0xD0, 0x71,
170 0xE3, 0x71, 0xBB, 0x50, 0x86, 0x26, 0x32, 0x9F,
171 0xF5, 0x4A, 0x9C, 0xB1, 0x78, 0x7B, 0x47, 0x1F,
172 0x19, 0xC7, 0x26, 0x22, 0x15, 0x62, 0x71, 0xAB,
173 0xD7, 0x25, 0xA5, 0xE4, 0x68, 0x71, 0x93, 0x5D,
174 0x1F, 0x29, 0x01, 0x05, 0x9C, 0x57, 0x3A, 0x09,
175 0xB0, 0xB8, 0xE4, 0xD2, 0x37, 0x90, 0x36, 0x2F,
176 0xBF, 0x1E, 0x74, 0xB4, 0x6B, 0xE4, 0x66, 0x07 },
180 { 0xFD, 0xD9, 0xC8, 0x5F, 0x73, 0x62, 0xC9, 0x79,
181 0xEF, 0xD5, 0x09, 0x07, 0x02, 0xE7, 0xF2, 0x90,
182 0x97, 0x13, 0x26, 0x1D },
186 { 0x02, 0x4E, 0xDD, 0x0D, 0x7F, 0x4D, 0xB1, 0x42,
187 0x01, 0x50, 0xE7, 0x9A, 0x65, 0x73, 0x8B, 0x31,
188 0x24, 0x6B, 0xC6, 0x74, 0xA7, 0x68, 0x26, 0x11,
189 0x06, 0x3C, 0x96, 0xA9, 0xA6, 0x23, 0x12, 0x79,
190 0xC4, 0xEE, 0x21, 0x88, 0xDD, 0xE3, 0xF0, 0x37,
191 0xCE, 0x3E, 0x54, 0x53, 0x57, 0x03, 0x30, 0xE4,
192 0xD3, 0xAB, 0x39, 0x4E, 0x39, 0xDC, 0xA2, 0x88,
193 0x82, 0xF6, 0xE8, 0xBA, 0xAC, 0xF5, 0x7D, 0x2F,
194 0x23, 0x9A, 0x09, 0x94, 0xB2, 0x89, 0xA2, 0xC9,
195 0x7C, 0xBE, 0x4D, 0x48, 0x0E, 0x59, 0x51, 0xB8,
196 0x7D, 0x99, 0x88, 0x79, 0xA8, 0x13, 0x0E, 0x12,
197 0x56, 0x9D, 0x4B, 0x2E, 0xE0, 0xE1, 0x37, 0x78,
198 0x6F, 0xCC, 0x4D, 0x97, 0xA9, 0x02, 0x0E, 0xD2,
199 0x43, 0x83, 0xEC, 0x4F, 0xC2, 0x70, 0xEF, 0x16,
200 0xDE, 0xBF, 0xBA, 0xD1, 0x6C, 0x8A, 0x36, 0xEE,
201 0x42, 0x41, 0xE9, 0xE7, 0x66, 0xAE, 0x46, 0x3B },
205 { 0xD9, 0x41, 0x29, 0xF7, 0x40, 0x32, 0x09, 0x71,
206 0xB8, 0xE2, 0xB8, 0xCB, 0x74, 0x46, 0x0B, 0xD4,
207 0xF2, 0xAB, 0x54, 0xA1 },
211 { 0x01, 0x7E, 0x16, 0x5B, 0x65, 0x51, 0x0A, 0xDA,
212 0x82, 0x1A, 0xD9, 0xF4, 0x1E, 0x66, 0x6D, 0x7D,
213 0x23, 0xA6, 0x28, 0x2F, 0xE6, 0xC2, 0x03, 0x8E,
214 0x8C, 0xAB, 0xC2, 0x08, 0x87, 0xC9, 0xE8, 0x51,
215 0x0A, 0x37, 0x1E, 0xD4, 0x41, 0x7F, 0xA2, 0xC5,
216 0x48, 0x26, 0xB7, 0xF6, 0xC2, 0x6F, 0xB2, 0xF8,
217 0xF9, 0x43, 0x43, 0xF9, 0xDA, 0xAB, 0xA2, 0x59,
218 0x27, 0xBA, 0xC9, 0x1C, 0x8C, 0xAB, 0xC4, 0x90,
219 0x27, 0xE1, 0x10, 0x39, 0x6F, 0xD2, 0xCD, 0x7C,
220 0xD1, 0x0B, 0xFA, 0x28, 0xD2, 0x7A, 0x7B, 0x52,
221 0x8A, 0xA0, 0x5A, 0x0F, 0x10, 0xF7, 0xBA, 0xFD,
222 0x33, 0x0C, 0x3C, 0xCE, 0xE5, 0xF2, 0xF6, 0x92,
223 0xED, 0x04, 0xBF, 0xD3, 0xF8, 0x3D, 0x39, 0xCC,
224 0xAA, 0xCC, 0x0B, 0xB2, 0x6B, 0xD8, 0xB2, 0x8A,
225 0x5C, 0xCE, 0xDA, 0xF9, 0xE1, 0xA7, 0x23, 0x50,
226 0xDC, 0xCE, 0xA4, 0xD5, 0xA5, 0x4F, 0x08, 0x0F }
230 static
int selfTest(
void )
233 PKC_INFO contextData, *pkcInfo = &contextData;
237 status = staticInitContext( &contextInfo,
CONTEXT_PKC,
239 sizeof( PKC_INFO ), NULL );
242 status = importBignum( &pkcInfo->dlpParam_p, dlpTestKey.p,
246 status = importBignum( &pkcInfo->dlpParam_q, dlpTestKey.q,
251 status = importBignum( &pkcInfo->dlpParam_g, dlpTestKey.g,
256 status = importBignum( &pkcInfo->dlpParam_y, dlpTestKey.y,
261 status = importBignum( &pkcInfo->dlpParam_x, dlpTestKey.x,
269 status = contextInfo.
capabilityInfo->initKeyFunction( &contextInfo, NULL, 0 );
271 !pairwiseConsistencyTest( &contextInfo ) )
275 staticDestroyContext( &contextInfo );
280 #define selfTest NULL
304 #define DSA_SIGPART_SIZE 20
313 PKC_INFO *pkcInfo = contextInfoPtr->ctxPKC;
315 BIGNUM *
p = &pkcInfo->dlpParam_p, *q = &pkcInfo->dlpParam_q;
316 BIGNUM *g = &pkcInfo->dlpParam_g, *x = &pkcInfo->dlpParam_x;
317 BIGNUM *hash = &pkcInfo->tmp1, *k = &pkcInfo->tmp2, *kInv = &pkcInfo->tmp3;
318 BIGNUM *r = &pkcInfo->dlpTmp1, *
s = &pkcInfo->dlpTmp2;
328 REQUIRES( dlpParams->inParam2 == NULL && \
329 ( dlpParams->
inLen2 == 0 || dlpParams->
inLen2 == -999 ) );
344 if( dlpParams->
inLen2 == -999 )
346 status = importBignum( k, (
BYTE * ) kVal, DSA_SIGPART_SIZE,
347 DSA_SIGPART_SIZE, DSA_SIGPART_SIZE, NULL,
380 status = generateBignum( k,
bytesToBits( DSA_SIGPART_SIZE + \
411 status = importBignum( hash, (
BYTE * ) dlpParams->inParam1,
412 DSA_SIGPART_SIZE, DSA_SIGPART_SIZE / 2,
419 &pkcInfo->dlpParam_mont_p ) );
420 CK(
BN_mod( r, r, q, pkcInfo->bnCTX ) );
442 status = pkcInfo->encodeDLValuesFunction( dlpParams->outParam,
465 PKC_INFO *pkcInfo = contextInfoPtr->ctxPKC;
467 BIGNUM *p = &pkcInfo->dlpParam_p, *q = &pkcInfo->dlpParam_q;
468 BIGNUM *g = &pkcInfo->dlpParam_g, *y = &pkcInfo->dlpParam_y;
469 BIGNUM *r = &pkcInfo->tmp1, *
s = &pkcInfo->tmp2;
470 BIGNUM *u1 = &pkcInfo->tmp3, *u2 = &pkcInfo->dlpTmp1;
480 ( dlpParams->
inLen2 >= 42 && dlpParams->
inLen2 <= 128 ) ) || \
482 ( dlpParams->
inLen2 >= 42 && dlpParams->
inLen2 <= 44 ) ) || \
483 ( dlpParams->
formatType == CRYPT_IFORMAT_SSH && \
484 dlpParams->
inLen2 == 40 ) );
486 REQUIRES( dlpParams->outParam == NULL && dlpParams->
outLen == 0 );
490 status = pkcInfo->decodeDLValuesFunction( dlpParams->inParam2,
502 status = importBignum( u1, (
BYTE * ) dlpParams->inParam1,
503 DSA_SIGPART_SIZE, DSA_SIGPART_SIZE / 2,
528 &pkcInfo->dlpParam_mont_p ) );
529 CK(
BN_mod(
s, u2, q, pkcInfo->bnCTX ) );
561 assert( ( key == NULL && keyLength == 0 ) || \
565 REQUIRES( ( key == NULL && keyLength == 0 ) || \
573 PKC_INFO *pkcInfo = contextInfoPtr->ctxPKC;
577 contextInfoPtr->flags |= ( dsaKey->
isPublicKey ) ? \
579 status = importBignum( &pkcInfo->dlpParam_p, dsaKey->
p,
584 status = importBignum( &pkcInfo->dlpParam_q, dsaKey->
q,
587 &pkcInfo->dlpParam_p,
590 status = importBignum( &pkcInfo->dlpParam_g, dsaKey->
g,
593 &pkcInfo->dlpParam_p,
596 status = importBignum( &pkcInfo->dlpParam_y, dsaKey->
y,
599 &pkcInfo->dlpParam_p,
602 status = importBignum( &pkcInfo->dlpParam_x, dsaKey->
x,
605 &pkcInfo->dlpParam_p,
607 contextInfoPtr->flags |= CONTEXT_FLAG_PBO;
614 return( initCheckDLPkey( contextInfoPtr,
FALSE,
FALSE ) );
622 const int keySizeBits )
631 status = generateDLPkey( contextInfoPtr, ( keySizeBits / 64 ) * 64 );
636 !pairwiseConsistencyTest( contextInfoPtr ) )
638 DEBUG_DIAG((
"Consistency check of freshly-generated DSA key "
655 selfTest, getDefaultInfo, NULL, NULL, initKey, generateKey,
656 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
662 return( &capabilityInfo );