/[mcrypt]/libmcrypt/lib/mcrypt_modules.h
ViewVC logotype

Contents of /libmcrypt/lib/mcrypt_modules.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Sat Mar 9 10:43:41 2002 UTC (22 years ago) by nmav
Branch: MAIN
CVS Tags: libmcrypt_2_5_3, libmcrypt_2_5_2, libmcrypt_2_5_0, libmcrypt_2_5_7, libmcrypt_2_5_6, libmcrypt_2_5_5, libmcrypt_2_5_4, libmcrypt_2_5_5rc1, HEAD
Changes since 1.2: +13 -2 lines
File MIME type: text/plain
A block cipher in CTR mode now behaves as a real stream cipher.
(nCFB and nOFB have to be fixed too).

1 #define rotl32(x,n) (((x) << ((word32)(n))) | ((x) >> (32 - (word32)(n))))
2 #define rotr32(x,n) (((x) >> ((word32)(n))) | ((x) << (32 - (word32)(n))))
3 #define rotl16(x,n) (((x) << ((word16)(n))) | ((x) >> (16 - (word16)(n))))
4 #define rotr16(x,n) (((x) >> ((word16)(n))) | ((x) << (16 - (word16)(n))))
5
6 /* Use hardware rotations.. when available */
7 #ifdef swap32
8 # define byteswap32(x) swap32(x)
9 #else
10 # ifdef swap_32
11 # define byteswap32(x) swap_32(x)
12 # else
13 # ifdef bswap_32
14 # define byteswap32(x) bswap_32(x)
15 # else
16 # define byteswap32(x) ((rotl32(x, 8) & 0x00ff00ff) | (rotr32(x, 8) & 0xff00ff00))
17 # endif
18 # endif
19 #endif
20
21 #ifdef swap16
22 # define byteswap16(x) swap16(x)
23 #else
24 # ifdef swap_16
25 # define byteswap16(x) swap_16(x)
26 # else
27 # ifdef bswap_16
28 # define byteswap16(x) bswap_16(x)
29 # else
30 # define byteswap16(x) ((rotl16(x, 8) & 0x00ff) | (rotr16(x, 8) & 0xff00))
31 # endif
32 # endif
33 #endif
34
35 inline static
36 void memxor(unsigned char *o1, unsigned char *o2, int length)
37 {
38 int i;
39
40 for (i = 0; i < length; i++) {
41 o1[i] ^= o2[i];
42 }
43 return;
44 }
45
46
47 #define Bzero(x, y) memset(x, 0, y)

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26