|
|
1.1.1.9 root 1: /*
1.1.1.11 root 2: Legal Notice: Some portions of the source code contained in this file were
3: derived from the source code of Encryption for the Masses 2.02a, which is
4: Copyright (c) 1998-2000 Paul Le Roux and which is governed by the 'License
5: Agreement for Encryption for the Masses'. Modifications and additions to
1.1.1.17! root 6: the original source code (contained in this file) and all other portions
! 7: of this file are Copyright (c) 2003-2009 TrueCrypt Developers Association
! 8: and are governed by the TrueCrypt License 2.8 the full text of which is
! 9: contained in the file License.txt included in TrueCrypt binary and source
! 10: code distribution packages. */
1.1.1.6 root 11:
12: #include "Tcdefs.h"
1.1.1.9 root 13: #include "Common/Endian.h"
14:
15:
16: unsigned __int16 MirrorBytes16 (unsigned __int16 x)
17: {
18: return (x << 8) | (x >> 8);
19: }
1.1.1.6 root 20:
21:
22: unsigned __int32 MirrorBytes32 (unsigned __int32 x)
23: {
24: unsigned __int32 n = (unsigned __int8) x;
25: n <<= 8; n |= (unsigned __int8) (x >> 8);
26: n <<= 8; n |= (unsigned __int8) (x >> 16);
27: return (n << 8) | (unsigned __int8) (x >> 24);
28: }
29:
1.1.1.11 root 30: #ifndef TC_NO_COMPILER_INT64
1.1.1.14 root 31: uint64 MirrorBytes64 (uint64 x)
1.1.1.6 root 32: {
1.1.1.14 root 33: uint64 n = (unsigned __int8) x;
1.1.1.6 root 34: n <<= 8; n |= (unsigned __int8) (x >> 8);
35: n <<= 8; n |= (unsigned __int8) (x >> 16);
36: n <<= 8; n |= (unsigned __int8) (x >> 24);
37: n <<= 8; n |= (unsigned __int8) (x >> 32);
38: n <<= 8; n |= (unsigned __int8) (x >> 40);
39: n <<= 8; n |= (unsigned __int8) (x >> 48);
40: return (n << 8) | (unsigned __int8) (x >> 56);
41: }
1.1.1.11 root 42: #endif
1.1 root 43:
44: void
1.1.1.6 root 45: LongReverse (unsigned __int32 *buffer, unsigned byteCount)
1.1 root 46: {
1.1.1.6 root 47: unsigned __int32 value;
1.1 root 48:
1.1.1.6 root 49: byteCount /= sizeof (unsigned __int32);
1.1 root 50: while (byteCount--)
51: {
52: value = *buffer;
53: value = ((value & 0xFF00FF00L) >> 8) | \
54: ((value & 0x00FF00FFL) << 8);
55: *buffer++ = (value << 16) | (value >> 16);
56: }
57: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.