20 #define DES_BLOCKSIZE 8
22 #if defined( INC_ALL )
30 #define DES_KEY Key_schedule
31 #define DES_KEYSIZE sizeof( Key_schedule )
39 #ifndef CONFIG_NO_SELFTEST
58 status = testCipher( capabilityInfo, keyData, testDES[ i ].
key,
69 static int selfTest(
void )
74 if( ( testLoop( testIP,
sizeof( testIP ) /
sizeof(
DES_TEST ),
76 ( testLoop( testVP,
sizeof( testVP ) /
sizeof(
DES_TEST ),
78 ( testLoop( testKP,
sizeof( testKP ) /
sizeof(
DES_TEST ),
80 ( testLoop( testDP,
sizeof( testDP ) /
sizeof(
DES_TEST ),
82 ( testLoop( testSB,
sizeof( testSB ) /
sizeof(
DES_TEST ),
106 assert( contextInfoPtr == NULL || \
108 assert( ( length == 0 &&
isWritePtr( data,
sizeof(
int ) ) ) || \
109 ( length > 0 &&
isWritePtr( data, length ) ) );
122 return( getDefaultInfo( type, contextInfoPtr, data, length ) );
136 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
139 while( blockCount-- > 0 )
155 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
158 while( blockCount-- > 0 )
176 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
187 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
200 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
201 int i, ivCount = convInfo->
ivCount;
210 if( noBytes < bytesToUse )
211 bytesToUse = noBytes;
214 for( i = 0; i < bytesToUse; i++ )
215 buffer[ i ] ^= convInfo->currentIV[ i + ivCount ];
216 memcpy( convInfo->currentIV + ivCount, buffer, bytesToUse );
219 noBytes -= bytesToUse;
220 buffer += bytesToUse;
221 ivCount += bytesToUse;
230 (
C_Block * ) convInfo->currentIV,
234 for( i = 0; i < ivCount; i++ )
235 buffer[ i ] ^= convInfo->currentIV[ i ];
238 memcpy( convInfo->currentIV, buffer, ivCount );
254 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
256 int i, ivCount = convInfo->
ivCount;
265 if( noBytes < bytesToUse )
266 bytesToUse = noBytes;
269 memcpy( temp, buffer, bytesToUse );
270 for( i = 0; i < bytesToUse; i++ )
271 buffer[ i ] ^= convInfo->currentIV[ i + ivCount ];
272 memcpy( convInfo->currentIV + ivCount, temp, bytesToUse );
275 noBytes -= bytesToUse;
276 buffer += bytesToUse;
277 ivCount += bytesToUse;
286 (
C_Block * ) convInfo->currentIV,
290 memcpy( temp, buffer, ivCount );
293 for( i = 0; i < ivCount; i++ )
294 buffer[ i ] ^= convInfo->currentIV[ i ];
297 memcpy( convInfo->currentIV, temp, ivCount );
318 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
319 int i, ivCount = convInfo->
ivCount;
328 if( noBytes < bytesToUse )
329 bytesToUse = noBytes;
332 for( i = 0; i < bytesToUse; i++ )
333 buffer[ i ] ^= convInfo->currentIV[ i + ivCount ];
336 noBytes -= bytesToUse;
337 buffer += bytesToUse;
338 ivCount += bytesToUse;
347 (
C_Block * ) convInfo->currentIV,
351 for( i = 0; i < ivCount; i++ )
352 buffer[ i ] ^= convInfo->currentIV[ i ];
368 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
369 int i, ivCount = convInfo->
ivCount;
378 if( noBytes < bytesToUse )
379 bytesToUse = noBytes;
382 for( i = 0; i < bytesToUse; i++ )
383 buffer[ i ] ^= convInfo->currentIV[ i + ivCount ];
386 noBytes -= bytesToUse;
387 buffer += bytesToUse;
388 ivCount += bytesToUse;
397 (
C_Block * ) convInfo->currentIV,
401 for( i = 0; i < ivCount; i++ )
402 buffer[ i ] ^= convInfo->currentIV[ i ];
426 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
429 if( convInfo->userKey != key )
430 memcpy( convInfo->userKey, key, keyLength );
457 selfTest, getInfo, NULL, initGenericParams, initKey, NULL,
458 encryptECB, decryptECB, encryptCBC, decryptCBC,
459 encryptCFB, decryptCFB, encryptOFB, decryptOFB
464 return( &capabilityInfo );