Exemple #1
0
WIN32DLL_DEFINE void _mcrypt_decrypt(cast256_key * key, word32 * blk)
{
	word32 t, u;

#ifdef WORDS_BIGENDIAN
	blk[0] = byteswap32(blk[0]);
	blk[1] = byteswap32(blk[1]);
	blk[2] = byteswap32(blk[2]);
	blk[3] = byteswap32(blk[3]);
#endif
	f_rnd(blk, 88);
	f_rnd(blk, 80);
	f_rnd(blk, 72);
	f_rnd(blk, 64);
	f_rnd(blk, 56);
	f_rnd(blk, 48);
	i_rnd(blk, 40);
	i_rnd(blk, 32);
	i_rnd(blk, 24);
	i_rnd(blk, 16);
	i_rnd(blk, 8);
	i_rnd(blk, 0);

#ifdef WORDS_BIGENDIAN
	blk[0] = byteswap32(blk[0]);
	blk[1] = byteswap32(blk[1]);
	blk[2] = byteswap32(blk[2]);
	blk[3] = byteswap32(blk[3]);
#endif

}
Exemple #2
0
void decrypt (const u4byte in_blk[4], u4byte out_blk[4]) {
    u4byte t, u, blk[4];

    blk[0] = io_swap (in_blk[0]);
    blk[1] = io_swap (in_blk[1]);
    blk[2] = io_swap (in_blk[2]);
    blk[3] = io_swap (in_blk[3]);

    f_rnd (blk, 88);
    f_rnd (blk, 80);
    f_rnd (blk, 72);
    f_rnd (blk, 64);
    f_rnd (blk, 56);
    f_rnd (blk, 48);
    i_rnd (blk, 40);
    i_rnd (blk, 32);
    i_rnd (blk, 24);
    i_rnd (blk, 16);
    i_rnd (blk, 8);
    i_rnd (blk, 0);

    out_blk[0] = io_swap (blk[0]);
    out_blk[1] = io_swap (blk[1]);
    out_blk[2] = io_swap (blk[2]);
    out_blk[3] = io_swap (blk[3]);
}
Exemple #3
0
static qbool NET_PacketQueueAdd(packet_queue_t* queue, byte* data, int size, netadr_t addr)
{
	cl_delayed_packet_t* next = &queue->packets[queue->tail];
	double time = Sys_DoubleTime();
	float deviation = f_rnd(-bound(0, cl_delay_packet_dev.value, 12), bound(0, cl_delay_packet_dev.value, 12));

	// If buffer is full, can't prevent packet loss - drop this packet
	if (next->time && queue->head == queue->tail)
		return false;

	memmove(next->data, data, size);
	next->length = size;
	next->addr = addr;
	next->time = time + 0.001 * bound(0, 0.5 * cl_delay_packet.value + deviation, CL_MAX_PACKET_DELAY);

	NET_PacketQueueSetNextIndex(&queue->tail);
	return true;
}
Exemple #4
0
int rc6_encrypt(struct cipher_context *cx, 
		const u8 *in, u8 *out, int size, int atomic)
{       u32 *l_key = cx->keyinfo;
	u32 *in_blk = (u32 *)in;
	u32 *out_blk = (u32 *)out;
	u32	a,b,c,d,t,u;

	a = in_blk[0]; b = in_blk[1] + l_key[0];
	c = in_blk[2]; d = in_blk[3] + l_key[1];

	f_rnd( 2,a,b,c,d); f_rnd( 4,b,c,d,a);
	f_rnd( 6,c,d,a,b); f_rnd( 8,d,a,b,c);
	f_rnd(10,a,b,c,d); f_rnd(12,b,c,d,a);
	f_rnd(14,c,d,a,b); f_rnd(16,d,a,b,c);
	f_rnd(18,a,b,c,d); f_rnd(20,b,c,d,a);
	f_rnd(22,c,d,a,b); f_rnd(24,d,a,b,c);
	f_rnd(26,a,b,c,d); f_rnd(28,b,c,d,a);
	f_rnd(30,c,d,a,b); f_rnd(32,d,a,b,c);
	f_rnd(34,a,b,c,d); f_rnd(36,b,c,d,a);
	f_rnd(38,c,d,a,b); f_rnd(40,d,a,b,c);

	out_blk[0] = a + l_key[42]; out_blk[1] = b;
	out_blk[2] = c + l_key[43]; out_blk[3] = d;
	return 0;
};
Exemple #5
0
void encrypt(const u4byte in_blk[4], u4byte out_blk[4])
{   u4byte  i, k;
    u1byte  blk[16], *xp, *sp, *pp;
    
    get_block(blk);
    
    for(i = 0; i < 8; ++i)
    {
        xp = lkp->f_key[i].k_xbu;
        sp = lkp->f_key[i].k_spu;
        pp = lkp->f_key[i].k_bpu;

        f_rnd( 0); f_rnd( 1); f_rnd( 2); f_rnd( 3);
        f_rnd( 4); f_rnd( 5); f_rnd( 6); f_rnd( 7);
        f_rnd( 8); f_rnd( 9); f_rnd(10); f_rnd(11);
        f_rnd(12); f_rnd(13); f_rnd(14); f_rnd(15);
    }

    put_block(blk);
};
Exemple #6
0
void enc(const u4byte in_blk[4], u4byte out_blk[4])
{   u4byte  i, k;
    u1byte  blk[16], *xp, *sp, *pp;
    
    *(u4byte*)(blk +  0) = in_blk[0]; *(u4byte*)(blk +  4) = in_blk[1];
    *(u4byte*)(blk +  8) = in_blk[2]; *(u4byte*)(blk + 12) = in_blk[3];
    
    for(i = 0; i < 8; ++i)
    {
        xp = lkp->f_key[i].k_xbu;
        sp = lkp->f_key[i].k_spu;
        pp = lkp->f_key[i].k_bpu;

        f_rnd( 0); f_rnd( 1); f_rnd( 2); f_rnd( 3);
        f_rnd( 4); f_rnd( 5); f_rnd( 6); f_rnd( 7);
        f_rnd( 8); f_rnd( 9); f_rnd(10); f_rnd(11);
        f_rnd(12); f_rnd(13); f_rnd(14); f_rnd(15);
    }

    out_blk[0] = *(u4byte*)(blk +  0); out_blk[1] = *(u4byte*)(blk +  4);
    out_blk[2] = *(u4byte*)(blk +  8); out_blk[3] = *(u4byte*)(blk + 12);
};