void DES::ProcessAndXorBlock(const byte* in, const byte* xOr, byte* out) const { word32 l,r; Block::Get(in)(l)(r); IPERM(l,r); RawProcessBlock(l, r); FPERM(l,r); Block::Put(xOr, out)(r)(l); }
void DES_EDE3_Decryption::ProcessBlock(const byte *inBlock, byte *outBlock) const { word32 l,r; GetBlockBigEndian(inBlock, l, r); IPERM(l,r); d3.RawProcessBlock(l, r); e2.RawProcessBlock(r, l); d1.RawProcessBlock(l, r); FPERM(l,r); PutBlockBigEndian(outBlock, r, l); }
void DES_EDE3::ProcessAndXorBlock(const byte* in, const byte* xOr, byte* out) const { word32 l,r; Block::Get(in)(l)(r); IPERM(l,r); des1_.RawProcessBlock(l, r); des2_.RawProcessBlock(r, l); des3_.RawProcessBlock(l, r); FPERM(l,r); Block::Put(xOr, out)(r)(l); }
static void DesProcessBlock(Des* des, const byte* in, byte* out) { word32 l, r; XMEMCPY(&l, in, sizeof(l)); XMEMCPY(&r, in + sizeof(l), sizeof(r)); #ifdef LITTLE_ENDIAN_ORDER l = ByteReverseWord32(l); r = ByteReverseWord32(r); #endif IPERM(&l,&r); DesRawProcessBlock(&l, &r, des->key); FPERM(&l,&r); #ifdef LITTLE_ENDIAN_ORDER l = ByteReverseWord32(l); r = ByteReverseWord32(r); #endif XMEMCPY(out, &r, sizeof(r)); XMEMCPY(out + sizeof(r), &l, sizeof(l)); }
static void Des3ProcessBlock(Des3* des, const byte* in, byte* out) { word32 l, r; memcpy(&l, in, sizeof(l)); memcpy(&r, in + sizeof(l), sizeof(r)); #ifdef LITTLE_ENDIAN_ORDER l = ByteReverseWord32(l); r = ByteReverseWord32(r); #endif IPERM(&l,&r); DesRawProcessBlock(&l, &r, des->key[0]); DesRawProcessBlock(&r, &l, des->key[1]); DesRawProcessBlock(&l, &r, des->key[2]); FPERM(&l,&r); #ifdef LITTLE_ENDIAN_ORDER l = ByteReverseWord32(l); r = ByteReverseWord32(r); #endif memcpy(out, &r, sizeof(r)); memcpy(out + sizeof(r), &l, sizeof(l)); }
// Encrypt or decrypt a block of data in ECB mode void DES::ProcessBlock(const byte *inBlock, byte * outBlock) const { word32 l,r; GetBlockBigEndian(inBlock, l, r); IPERM(l,r); const word32 *kptr=k; for (unsigned i=0; i<8; i++) { word32 work = rotrFixed(r, 4U) ^ kptr[4*i+0]; l ^= Spbox[6][(work) & 0x3f] ^ Spbox[4][(work >> 8) & 0x3f] ^ Spbox[2][(work >> 16) & 0x3f] ^ Spbox[0][(work >> 24) & 0x3f]; work = r ^ kptr[4*i+1]; l ^= Spbox[7][(work) & 0x3f] ^ Spbox[5][(work >> 8) & 0x3f] ^ Spbox[3][(work >> 16) & 0x3f] ^ Spbox[1][(work >> 24) & 0x3f]; work = rotrFixed(l, 4U) ^ kptr[4*i+2]; r ^= Spbox[6][(work) & 0x3f] ^ Spbox[4][(work >> 8) & 0x3f] ^ Spbox[2][(work >> 16) & 0x3f] ^ Spbox[0][(work >> 24) & 0x3f]; work = l ^ kptr[4*i+3]; r ^= Spbox[7][(work) & 0x3f] ^ Spbox[5][(work >> 8) & 0x3f] ^ Spbox[3][(work >> 16) & 0x3f] ^ Spbox[1][(work >> 24) & 0x3f]; } FPERM(l,r); PutBlockBigEndian(outBlock, r, l); }