// ia32 optimized version
void DES_EDE3::Process(byte* out, const byte* in, word32 sz)
{
    if (!isMMX) {
        Mode_BASE::Process(out, in, sz);
        return;
    }

    word32 blocks = sz / DES_BLOCK_SIZE;

    if (mode_ == CBC)    
        if (dir_ == ENCRYPTION)
            while (blocks--) {
                r_[0] ^= *(word32*)in;
                r_[1] ^= *(word32*)(in + 4);

                AsmProcess((byte*)r_, (byte*)r_, (void*)Spbox);
                
                memcpy(out, r_, DES_BLOCK_SIZE);

                in  += DES_BLOCK_SIZE;
                out += DES_BLOCK_SIZE;
            }
        else
            while (blocks--) {
                AsmProcess(in, out, (void*)Spbox);
               
                *(word32*)out       ^= r_[0];
                *(word32*)(out + 4) ^= r_[1];

                memcpy(r_, in, DES_BLOCK_SIZE);

                out += DES_BLOCK_SIZE;
                in  += DES_BLOCK_SIZE;
            }
    else
        while (blocks--) {
            AsmProcess(in, out, (void*)Spbox);
           
            out += DES_BLOCK_SIZE;
            in  += DES_BLOCK_SIZE;
        }
}
Exemple #2
0
void ARC4::Process(byte* out, const byte* in, word32 length)
{
    if (length == 0) return;

#ifdef DO_ARC4_ASM
    if (isMMX) {
        AsmProcess(out, in, length);
        return;
    } 
#endif

    byte *const s = state_;
    word32 x = x_;
    word32 y = y_;

    if (in == out)
        while (length--)
            *out++ ^= MakeByte(x, y, s);
    else
        while(length--)
            *out++ = *in++ ^ MakeByte(x, y, s);
    x_ = x;
    y_ = y;
}