20 #define DES_BLOCKSIZE 8
22 #if defined( INC_ALL )
38 #define DES_KEYSIZE sizeof( Key_schedule )
39 #define DES3_KEYSIZE sizeof( DES3_KEY )
47 #ifndef CONFIG_NO_SELFTEST
76 status = testCipher( capabilityInfo, keyData, desKeyData,
87 static int selfTest(
void )
91 if( ( testLoop( testIP,
sizeof( testIP ) /
sizeof(
DES_TEST ) ) !=
CRYPT_OK ) || \
92 ( testLoop( testVP,
sizeof( testVP ) /
sizeof(
DES_TEST ) ) !=
CRYPT_OK ) || \
93 ( testLoop( testKP,
sizeof( testKP ) /
sizeof(
DES_TEST ) ) !=
CRYPT_OK ) || \
94 ( testLoop( testDP,
sizeof( testDP ) /
sizeof(
DES_TEST ) ) !=
CRYPT_OK ) || \
101 #define selfTest NULL
118 assert( contextInfoPtr == NULL || \
120 assert( ( length == 0 &&
isWritePtr( data,
sizeof(
int ) ) ) || \
121 ( length > 0 &&
isWritePtr( data, length ) ) );
134 return( getDefaultInfo( type, contextInfoPtr, data, length ) );
148 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
152 while( blockCount-- > 0 )
169 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
173 while( blockCount-- > 0 )
192 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
205 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
220 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
222 int i, ivCount = convInfo->
ivCount;
231 if( noBytes < bytesToUse )
232 bytesToUse = noBytes;
235 for( i = 0; i < bytesToUse; i++ )
236 buffer[ i ] ^= convInfo->currentIV[ i + ivCount ];
237 memcpy( convInfo->currentIV + ivCount, buffer, bytesToUse );
240 noBytes -= bytesToUse;
241 buffer += bytesToUse;
242 ivCount += bytesToUse;
251 (
C_Block * ) convInfo->currentIV,
256 for( i = 0; i < ivCount; i++ )
257 buffer[ i ] ^= convInfo->currentIV[ i ];
260 memcpy( convInfo->currentIV, buffer, ivCount );
280 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
283 int i, ivCount = convInfo->
ivCount;
292 if( noBytes < bytesToUse )
293 bytesToUse = noBytes;
296 memcpy( temp, buffer, bytesToUse );
297 for( i = 0; i < bytesToUse; i++ )
298 buffer[ i ] ^= convInfo->currentIV[ i + ivCount ];
299 memcpy( convInfo->currentIV + ivCount, temp,
303 noBytes -= bytesToUse;
304 buffer += bytesToUse;
305 ivCount += bytesToUse;
314 (
C_Block * ) convInfo->currentIV,
319 memcpy( temp, buffer, ivCount );
322 for( i = 0; i < ivCount; i++ )
323 buffer[ i ] ^= convInfo->currentIV[ i ];
326 memcpy( convInfo->currentIV, temp, ivCount );
347 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
349 int i, ivCount = convInfo->
ivCount;
358 if( noBytes < bytesToUse )
359 bytesToUse = noBytes;
362 for( i = 0; i < bytesToUse; i++ )
363 buffer[ i ] ^= convInfo->currentIV[ i + ivCount ];
366 noBytes -= bytesToUse;
367 buffer += bytesToUse;
368 ivCount += bytesToUse;
377 (
C_Block * ) convInfo->currentIV,
382 for( i = 0; i < ivCount; i++ )
383 buffer[ i ] ^= convInfo->currentIV[ i ];
401 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
403 int i, ivCount = convInfo->
ivCount;
412 if( noBytes < bytesToUse )
413 bytesToUse = noBytes;
416 for( i = 0; i < bytesToUse; i++ )
417 buffer[ i ] ^= convInfo->currentIV[ i + ivCount ];
420 noBytes -= bytesToUse;
421 buffer += bytesToUse;
422 ivCount += bytesToUse;
431 (
C_Block * ) convInfo->currentIV,
436 for( i = 0; i < ivCount; i++ )
437 buffer[ i ] ^= convInfo->currentIV[ i ];
461 CONV_INFO *convInfo = contextInfoPtr->ctxConv;
468 if( convInfo->userKey != key )
469 memcpy( convInfo->userKey, key, keyLength );
531 selfTest, getInfo, NULL, initGenericParams, initKey, NULL,
532 encryptECB, decryptECB, encryptCBC, decryptCBC,
533 encryptCFB, decryptCFB, encryptOFB, decryptOFB
538 return( &capabilityInfo );