Crypto/DesX.cpp
//---------------------------------------------------------------------------
// Initialize context.  Caller should clear the context when finished.
//   The key has the DES key, input whitener and output whitener concatenated.
//   This is the RSADSI special DES implementation.
Initialize context.  Caller should clear the context when finished.
The key has the DES key, input whitener and output whitener concatenated.
This is the RSADSI special DES implementation.
Initialize context . Caller should clear the context when finished . The key has the DES key input whitener and output whitener concatenated . This is the RSADSI special DES implementation .
void DESX_CBCInit(DESX_CBC_CTX *context, UINT8 *key, UINT8 *iv){
    UINT8 inw[8] = {0};
    UINT8 i=0,j=0;
    UINT8 clorox_i;
    UINT8 *v11, *v12;
    scrunch(context->iv, iv);
    scrunch(context->inputWhitener, key + 8);
    for (i=0; i<8; i++) {
        clorox_i = inw[0] ^ inw[1];
        v11 = &inw[0];
        v12 = &inw[1];
        for (j=0; j<7; j++) {
            *v11++ = *v12++;
        }
        *v11 = clorox[clorox_i] ^ key[i];
    }
    for (i=0; i<8; i++) {
        clorox_i = inw[0] ^ inw[1];
		v11 = &inw[0];
        v12 = &inw[1];
        for (j=0; j<7; j++) {
            *v11++ = *v12++;
        }
        *v11 = clorox[clorox_i] ^ key[i+8];
    }
    scrunch(context->outputWhitener, inw);
    scrunch(context->originalIV, iv);
	deskey(context->subkeys_enc, key, TRUE);
	deskey(context->subkeys_dec, key, FALSE);
}
void DESX_CBCInit ( DESX_CBC_CTX * context , UINT8 * key , UINT8 * iv ) { UINT8 inw [ 8 ] = { 0 } ; UINT8 i = 0 , j = 0 ; UINT8 clorox_i ; UINT8 * v11 , * v12 ; scrunch ( context -> iv , iv ) ; scrunch ( context -> inputWhitener , key + 8 ) ; for ( i = 0 ; i < 8 ; i ++ ) { clorox_i = inw [ 0 ] ^ inw [ 1 ] ; v11 = & inw [ 0 ] ; v12 = & inw [ 1 ] ; for ( j = 0 ; j < 7 ; j ++ ) { * v11 ++ = * v12 ++ ; } * v11 = clorox [ clorox_i ] ^ key [ i ] ; } for ( i = 0 ; i < 8 ; i ++ ) { clorox_i = inw [ 0 ] ^ inw [ 1 ] ; v11 = & inw [ 0 ] ; v12 = & inw [ 1 ] ; for ( j = 0 ; j < 7 ; j ++ ) { * v11 ++ = * v12 ++ ; } * v11 = clorox [ clorox_i ] ^ key [ i + 8 ] ; } scrunch ( context -> outputWhitener , inw ) ; scrunch ( context -> originalIV , iv ) ; deskey ( context -> subkeys_enc , key , TRUE ) ; deskey ( context -> subkeys_dec , key , FALSE ) ; }
Initialize context.
Initialize context .
/* Save encrypt flag to context. */ //    context->encrypt = encrypt; /* Pack initializing vector and whiteners into context. */ /* special for output whitening */ /* Save the IV for use in Restart */ /* Precompute key schedule. */