int _mcrypt( CTR_BUFFER* buf,void *plaintext, int len, int blocksize, void* akey, void (*func)(void*,void*), void (*func2)(void*,void*)) { /* plaintext can be any size */ byte *plain; word32 *fplain = plaintext; int i, j=0; int modlen; plain = plaintext; for (j = 0; j < len / blocksize; j++) { xor_stuff( buf, akey, func, plain, blocksize, blocksize); plain += blocksize; /* Put the new register */ } modlen = len % blocksize; if (modlen > 0) { /* This is only usefull if encrypting the * final block. Otherwise you'll not be * able to decrypt it. */ xor_stuff( buf, akey, func, plain, blocksize, modlen); } return 0; }
GF_Err _mcrypt(void * buf,void *plaintext, int len, int blocksize, void* akey, void (*func)(void*,void*), void (*func2)(void*,void*)) { /* plaintext can be any size */ u8 *plain; int dlen, j=0; int modlen; dlen = len / blocksize; plain = (u8 *)plaintext; for (j = 0; j < dlen; j++) { xor_stuff((CTR_BUFFER*) buf, akey, func, plain, blocksize, blocksize); plain += blocksize; /* Put the new register */ } modlen = len % blocksize; if (modlen > 0) { /* This is only usefull if encrypting the * final block. Otherwise you'll not be * able to decrypt it. */ xor_stuff( (CTR_BUFFER*)buf, akey, func, plain, blocksize, modlen); } return GF_OK; }
static GF_Err _mcrypt( nOFB_BUFFER* buf,void *plaintext, int len, int blocksize, void* akey, void (*func)(void*,void*), void (*func2)(void*,void*)) { /* plaintext is n*blocksize bytes (nbit cfb) */ u8* plain; int dlen, j=0; void (*_mcrypt_block_encrypt) (void *, void *); int modlen; _mcrypt_block_encrypt = func; dlen = len / blocksize; plain = plaintext; for (j = 0; j < dlen; j++) { xor_stuff( buf, akey, func, plain, blocksize, blocksize); plain += blocksize; } modlen = len % blocksize; if (modlen > 0) { xor_stuff( buf, akey, func, plain, blocksize, modlen); } return GF_OK; }