Logo Search packages:      
Sourcecode: uif2iso version File versions  Download package

void des_crypt_cbc ( des_context ctx,
int  mode,
int  length,
unsigned char  iv[8],
unsigned char *  input,
unsigned char *  output 
)

DES-CBC buffer encryption/decryption.

Parameters:
ctx DES context
mode DES_ENCRYPT or DES_DECRYPT
length length of the input data
iv initialization vector (updated after use)
input buffer holding the input data
output buffer holding the output data

Definition at line 505 of file des.c.

{
    int i;
    unsigned char temp[8];

    if( mode == DES_ENCRYPT )
    {
        while( length > 0 )
        {
            for( i = 0; i < 8; i++ )
                output[i] = (unsigned char)( input[i] ^ iv[i] );

            des_crypt_ecb( ctx, output, output );
            memcpy( iv, output, 8 );

            input  += 8;
            output += 8;
            length -= 8;
        }
    }
    else /* DES_DECRYPT */
    {
        while( length > 0 )
        {
            memcpy( temp, input, 8 );
            des_crypt_ecb( ctx, input, output );

            for( i = 0; i < 8; i++ )
                output[i] = (unsigned char)( output[i] ^ iv[i] );

            memcpy( iv, temp, 8 );

            input  += 8;
            output += 8;
            length -= 8;
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index