void Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz) { word32 blocks = sz / DES_BLOCK_SIZE; while (blocks--) { xorbuf((byte*)des->reg, in, DES_BLOCK_SIZE); Des3ProcessBlock(des, (byte*)des->reg, (byte*)des->reg); XMEMCPY(out, des->reg, DES_BLOCK_SIZE); out += DES_BLOCK_SIZE; in += DES_BLOCK_SIZE; } }
void Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32 sz) { word32 blocks = sz / DES_BLOCK_SIZE; byte hold[16]; while (blocks--) { memcpy(des->tmp, in, DES_BLOCK_SIZE); Des3ProcessBlock(des, (byte*)des->tmp, out); xorbuf(out, (byte*)des->reg, DES_BLOCK_SIZE); memcpy(hold, des->reg, DES_BLOCK_SIZE); memcpy(des->reg, des->tmp, DES_BLOCK_SIZE); memcpy(des->tmp, hold, DES_BLOCK_SIZE); out += DES_BLOCK_SIZE; in += DES_BLOCK_SIZE; } }
void Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz) { word32 blocks; #ifdef HAVE_CAVIUM if (des->magic == CYASSL_3DES_CAVIUM_MAGIC) return Des3_CaviumCbcEncrypt(des, out, in, sz); #endif blocks = sz / DES_BLOCK_SIZE; while (blocks--) { xorbuf((byte*)des->reg, in, DES_BLOCK_SIZE); Des3ProcessBlock(des, (byte*)des->reg, (byte*)des->reg); XMEMCPY(out, des->reg, DES_BLOCK_SIZE); out += DES_BLOCK_SIZE; in += DES_BLOCK_SIZE; } }
int wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32 sz) { word32 blocks; #ifdef HAVE_CAVIUM if (des->magic == WOLFSSL_3DES_CAVIUM_MAGIC) return wc_Des3_CaviumCbcDecrypt(des, out, in, sz); #endif blocks = sz / DES_BLOCK_SIZE; while (blocks--) { XMEMCPY(des->tmp, in, DES_BLOCK_SIZE); Des3ProcessBlock(des, (byte*)des->tmp, out); xorbuf(out, (byte*)des->reg, DES_BLOCK_SIZE); XMEMCPY(des->reg, des->tmp, DES_BLOCK_SIZE); out += DES_BLOCK_SIZE; in += DES_BLOCK_SIZE; } return 0; }