Crypto/DesX.cpp
//---------------------------------------------------------------------------
// DESX-CBC block update operation. Continues a DESX-CBC encryption
//   operation, processing eight-byte message blocks, and updating
//   the context.  This is the RSADSI special DES implementation.
//   Requires len to a multiple of 8.
DESX-CBC block update operation. Continues a DESX-CBC encryption
operation, processing eight-byte message blocks, and updating
the context.  This is the RSADSI special DES implementation.
Requires len to a multiple of 8.
DESX - CBC block update operation . Continues a DESX - CBC encryption operation processing eight - byte message blocks and updating the context . This is the RSADSI special DES implementation . Requires len to a multiple of 8 .
int DESX_CBCUpdate (DESX_CBC_CTX *context, UINT8 *output, UINT8 *input, size_t len, int encrypt){
	UINT32 inputBlock[2], work[2];
    unsigned int i;
    if(len % 8)
        return(RE_LEN);
    for(i = 0; i < len/8; i++)  {
		scrunch(inputBlock, &input[8*i]);
        if(encrypt == 0) {
            *work = *inputBlock ^ *context->outputWhitener;
			*(work+1) = *(inputBlock+1) ^ *(context->outputWhitener+1);
			desfunc(work, context->subkeys_dec);
		}else{
			*work = *inputBlock ^ *context->iv ^ *context->inputWhitener;
			*(work+1) = *(inputBlock+1) ^ *(context->iv+1) ^ *(context->inputWhitener+1);
			desfunc(work, context->subkeys_enc);
		}
		if(encrypt == 0) {
            *work ^= *context->iv ^ *context->inputWhitener;
            *(work+1) ^= *(context->iv+1) ^ *(context->inputWhitener+1);
            *(context->iv) = *inputBlock;
			*(context->iv+1) = *(inputBlock+1);
			desfunc(work, context->subkeys_dec);
		}else{
            *work ^= *context->outputWhitener;
            *(work+1) ^= *(context->outputWhitener+1);
            *context->iv = *work;
			*(context->iv+1) = *(work+1);
            desfunc(work, context->subkeys_enc);
		}
		unscrunch(&output[8*i], work);
    }
    memset(inputBlock, 0, sizeof(inputBlock));
    memset(work, 0, sizeof(work));
    return(ID_OK);
}
int DESX_CBCUpdate ( DESX_CBC_CTX * context , UINT8 * output , UINT8 * input , size_t len , int encrypt ) { UINT32 inputBlock [ 2 ] , work [ 2 ] ; unsigned int i ; if ( len % 8 ) return ( RE_LEN ) ; for ( i = 0 ; i < len / 8 ; i ++ ) { scrunch ( inputBlock , & input [ 8 * i ] ) ; if ( encrypt == 0 ) { * work = * inputBlock ^ * context -> outputWhitener ; * ( work + 1 ) = * ( inputBlock + 1 ) ^ * ( context -> outputWhitener + 1 ) ; desfunc ( work , context -> subkeys_dec ) ; } else { * work = * inputBlock ^ * context -> iv ^ * context -> inputWhitener ; * ( work + 1 ) = * ( inputBlock + 1 ) ^ * ( context -> iv + 1 ) ^ * ( context -> inputWhitener + 1 ) ; desfunc ( work , context -> subkeys_enc ) ; } if ( encrypt == 0 ) { * work ^= * context -> iv ^ * context -> inputWhitener ; * ( work + 1 ) ^= * ( context -> iv + 1 ) ^ * ( context -> inputWhitener + 1 ) ; * ( context -> iv ) = * inputBlock ; * ( context -> iv + 1 ) = * ( inputBlock + 1 ) ; desfunc ( work , context -> subkeys_dec ) ; } else { * work ^= * context -> outputWhitener ; * ( work + 1 ) ^= * ( context -> outputWhitener + 1 ) ; * context -> iv = * work ; * ( context -> iv + 1 ) = * ( work + 1 ) ; desfunc ( work , context -> subkeys_enc ) ; } unscrunch ( & output [ 8 * i ] , work ) ; } memset ( inputBlock , 0 , sizeof ( inputBlock ) ) ; memset ( work , 0 , sizeof ( work ) ) ; return ( ID_OK ) ; }
DESX-CBC block update operation.
DESX - CBC block update operation .
/* Chain if encrypting, and xor with whitener. */ /* Xor with whitener, chain if decrypting, then update IV. */