예제 #1
0
void serpent256_decrypt(const unsigned char *in, unsigned char *out, serpent256_key *key)
{
	unsigned long b[4]; 
	int           i;
	
	__movsb((unsigned char*)&b, in, SERPENT_BLOCK_SIZE);

	for (i = 31; i >= 0; i--) {
		if (i == 31) KXf(key->expkey, 32, b); else ITf(b); 
		sd_tab[i % 8](b); KXf(key->expkey, i, b);
	}
	__movsb(out, (const unsigned char*)&b, SERPENT_BLOCK_SIZE);
}
예제 #2
0
void serpent256_encrypt(const unsigned char *in, unsigned char *out, serpent256_key *key)
{
	unsigned long b[4];
	int           i;
	
	__movsb((unsigned char*)&b, in, SERPENT_BLOCK_SIZE);

	for (i = 0; i < 32; i++) {
		KXf(key->expkey, i, b); se_tab[i % 8](b);	
		if (i == 31) KXf(key->expkey, 32, b); else LTf(b);
	}
	__movsb(out, (const unsigned char*)&b, SERPENT_BLOCK_SIZE);
}
예제 #3
0
void serpent256_decrypt(const unsigned char *in, unsigned char *out, serpent256_key *key)
{
	u32 b[4]; 
	int i;
	
	mincpy(b, in, SERPENT_BLOCK_SIZE);

	for (i = 31; i >= 0; i--) {
		if (i == 31) KXf(key->expkey, 32, b); else ITf(b); 
		sd_tab[i % 8](b); KXf(key->expkey, i, b);
	}
	mincpy(out, b, SERPENT_BLOCK_SIZE);
}
예제 #4
0
void serpent256_encrypt(const unsigned char *in, unsigned char *out, serpent256_key *key)
{
	u32 b[4];
	int i;
	
	mincpy(b, in, SERPENT_BLOCK_SIZE);

	for (i = 0; i < 32; i++) {
		KXf(key->expkey, i, b); se_tab[i % 8](b);	
		if (i == 31) KXf(key->expkey, 32, b); else LTf(b);
	}
	mincpy(out, b, SERPENT_BLOCK_SIZE);
}
예제 #5
0
void serpent_encrypt(const unsigned __int8 *inBlock, unsigned __int8 *outBlock, unsigned __int8 *ks)
{
	unsigned __int32 a, b, c, d, e;
	unsigned int i=1;
	const unsigned __int32 *k = (unsigned __int32 *)ks + 8;
	unsigned __int32 *in = (unsigned __int32 *) inBlock;
	unsigned __int32 *out = (unsigned __int32 *) outBlock;

    a = LE32(in[0]);
	b = LE32(in[1]);
	c = LE32(in[2]);
	d = LE32(in[3]);

	do
	{
		KXf (k,  0, &a, &b, &c, &d); S0f (&a, &b, &c, &d, &e); LTf (&b, &e, &c, &a);
		KXf (k,  4, &b, &e, &c, &a); S1f (&b, &e, &c, &a, &d); LTf (&c, &b, &a, &e);
		KXf (k,  8, &c, &b, &a, &e); S2f (&c, &b, &a, &e, &d); LTf (&a, &e, &b, &d);
		KXf (k, 12, &a, &e, &b, &d); S3f (&a, &e, &b, &d, &c); LTf (&e, &b, &d, &c);
		KXf (k, 16, &e, &b, &d, &c); S4f (&e, &b, &d, &c, &a); LTf (&b, &a, &e, &c);
		KXf (k, 20, &b, &a, &e, &c); S5f (&b, &a, &e, &c, &d); LTf (&a, &c, &b, &e);
		KXf (k, 24, &a, &c, &b, &e); S6f (&a, &c, &b, &e, &d); LTf (&a, &c, &d, &b);
		KXf (k, 28, &a, &c, &d, &b); S7f (&a, &c, &d, &b, &e);

		if (i == 4)
			break;

		++i;
		c = b;
		b = e;
		e = d;
		d = a;
		a = e;
		k += 32;
		LTf (&a,&b,&c,&d);
	}
	while (1);

	KXf (k, 32, &d, &e, &b, &a);
	
    out[0] = LE32(d);
	out[1] = LE32(e);
	out[2] = LE32(b);
	out[3] = LE32(a);
}
예제 #6
0
void serpent_decrypt(const unsigned __int8 *inBlock, unsigned __int8 *outBlock, unsigned __int8 *ks)
{
	unsigned __int32 a, b, c, d, e;
	const unsigned __int32 *k = (unsigned __int32 *)ks + 104;
	unsigned int i=4;
	unsigned __int32 *in = (unsigned __int32 *) inBlock;
	unsigned __int32 *out = (unsigned __int32 *) outBlock;

    a = LE32(in[0]);
	b = LE32(in[1]);
	c = LE32(in[2]);
	d = LE32(in[3]);

	KXf (k, 32, &a, &b, &c, &d);
	goto start;

	do
	{
		c = b;
		b = d;
		d = e;
		k -= 32;
		beforeI7(ILT);
start:
		beforeI7(I7); KXf (k, 28, &d, &a, &b, &e);
		ILTf (&d, &a, &b, &e); afterI7(I6); KXf (k, 24, &a, &b, &c, &e); 
		ILTf (&a, &b, &c, &e); afterI6(I5); KXf (k, 20, &b, &d, &e, &c); 
		ILTf (&b, &d, &e, &c); afterI5(I4); KXf (k, 16, &b, &c, &e, &a); 
		ILTf (&b, &c, &e, &a); afterI4(I3); KXf (k, 12, &a, &b, &e, &c);
		ILTf (&a, &b, &e, &c); afterI3(I2); KXf (k, 8,  &b, &d, &e, &c);
		ILTf (&b, &d, &e, &c); afterI2(I1); KXf (k, 4,  &a, &b, &c, &e);
		ILTf (&a, &b, &c, &e); afterI1(I0); KXf (k, 0,  &a, &d, &b, &e);
	}
	while (--i != 0);
	
    out[0] = LE32(a);
	out[1] = LE32(d);
	out[2] = LE32(b);
	out[3] = LE32(e);
}