[IRC-Dev CVS] [CVS] Module ircdh: Change committed
Brought to you by:
zolty
From: Toni G. <zo...@us...> - 2002-12-01 00:35:35
|
CVSROOT : /cvsroot/irc-dev Module : ircdh Commit time: 2002-12-01 00:35:34 UTC Added files: include/ircd_tea.h ircd/ircd_tea.c Log message: Ops! Faltaban 2 archivos. ---------------------- diff included ---------------------- Index: ircdh/include/ircd_tea.h diff -u /dev/null ircdh/include/ircd_tea.h:1.1 --- /dev/null Sat Nov 30 16:35:34 2002 +++ ircdh/include/ircd_tea.h Sat Nov 30 16:35:24 2002 @@ -0,0 +1,30 @@ +/* + * IRC - Internet Relay Chat, ircd/ircd_tea.h + * Copyright (C) 1999 IRC-Hispano.org - ESNET - jcea & savage + * + * See file AUTHORS in IRC package for additional names of + * the programmers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: ircd_tea.h,v 1.1 2002/12/01 00:35:24 zolty Exp $ + */ +#ifndef INCLUDED_ircd_tea_h +#define INCLUDED_ircd_tea_h + +extern void ircd_tea(unsigned int v[], unsigned int k[], unsigned int x[]); +extern void ircd_untea(unsigned int v[], unsigned int k[], unsigned int x[]); + +#endif /* INCLUDED_ircd_tea_h */ Index: ircdh/ircd/ircd_tea.c diff -u /dev/null ircdh/ircd/ircd_tea.c:1.1 --- /dev/null Sat Nov 30 16:35:34 2002 +++ ircdh/ircd/ircd_tea.c Sat Nov 30 16:35:24 2002 @@ -0,0 +1,86 @@ +/* + * IRC - Internet Relay Chat, ircd/ircd_tea.c + * Copyright (C) 1999 IRC-Hispano.org - ESNET - jcea & savage + * + * See file AUTHORS in IRC package for additional names of + * the programmers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: ircd_tea.c,v 1.1 2002/12/01 00:35:24 zolty Exp $ + */ + + +/* + * ircd_tea(cifrado) + * + * Cifra 64 bits de datos, usando clave de 64 bits (los 64 bits superiores son cero) + * Se cifra v[0]^x[0], v[1]^x[1], para poder hacer CBC facilmente. + * + */ +void ircd_tea(unsigned int v[], unsigned int k[], unsigned int x[]) +{ + unsigned int y = v[0] ^ x[0]; + unsigned int z = v[1] ^ x[1]; + unsigned int a = k[0]; + unsigned int b = k[1]; + unsigned int c = 0; + unsigned int d = 0; + unsigned int n = 32; + unsigned int sum = 0; + unsigned int delta = 0x9E3779B9; + + while (n-- > 0) + { + sum += delta; + y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); + z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); + } + + x[0] = y; + x[1] = z; +} + +/* + * ircd_untea(descifrado) + * + * Cifra 64 bits de datos, usando clave de 64 bits (los 64 bits superiores son cero) + * Se cifra v[0]^x[0], v[1]^x[1], para poder hacer CBC facilmente. + * + */ +void ircd_untea(unsigned int v[], unsigned int k[], unsigned int x[]) +{ + unsigned int y = v[0]; + unsigned int z = v[1]; + unsigned int a = k[0]; + unsigned int b = k[1]; + unsigned int c = 0; + unsigned int d = 0; + unsigned int n = 32; + unsigned int sum = 0xC6EF3720; + unsigned int delta = 0x9E3779B9; + + /* sum = delta << 5, in general sum = delta * n */ + + while (n-- > 0) + { + z -= ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); + y -= ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); + sum -= delta; + } + + x[0] = y; + x[1] = z; +} ----------------------- End of diff ----------------------- |