Annotation of truecrypt/common/endian.c, revision 1.1.1.9

1.1.1.9 ! root        1: /*
        !             2:  Legal Notice: The source code contained in this file has been derived from
        !             3:  the source code of Encryption for the Masses 2.02a, which is Copyright (c)
        !             4:  Paul Le Roux and which is covered by the 'License Agreement for Encryption
        !             5:  for the Masses'. Modifications and additions to that source code contained
        !             6:  in this file are Copyright (c) TrueCrypt Foundation and are covered by the
        !             7:  TrueCrypt License 2.2 the full text of which is contained in the file
        !             8:  License.txt included in TrueCrypt binary and source code distribution
        !             9:  packages. */
1.1.1.6   root       10: 
                     11: #include "Tcdefs.h"
1.1.1.9 ! root       12: #include "Common/Endian.h"
        !            13: 
        !            14: 
        !            15: unsigned __int16 MirrorBytes16 (unsigned __int16 x)
        !            16: {
        !            17:        return (x << 8) | (x >> 8);
        !            18: }
1.1.1.6   root       19: 
                     20: 
                     21: unsigned __int32 MirrorBytes32 (unsigned __int32 x)
                     22: {
                     23:        unsigned __int32 n = (unsigned __int8) x;
                     24:        n <<= 8; n |= (unsigned __int8) (x >> 8);
                     25:        n <<= 8; n |= (unsigned __int8) (x >> 16);
                     26:        return (n << 8) | (unsigned __int8) (x >> 24);
                     27: }
                     28: 
                     29: 
                     30: unsigned __int64 MirrorBytes64 (unsigned __int64 x)
                     31: {
                     32:        unsigned __int64 n = (unsigned __int8) x;
                     33:        n <<= 8; n |= (unsigned __int8) (x >> 8);
                     34:        n <<= 8; n |= (unsigned __int8) (x >> 16);
                     35:        n <<= 8; n |= (unsigned __int8) (x >> 24);
                     36:        n <<= 8; n |= (unsigned __int8) (x >> 32);
                     37:        n <<= 8; n |= (unsigned __int8) (x >> 40);
                     38:        n <<= 8; n |= (unsigned __int8) (x >> 48);
                     39:        return (n << 8) | (unsigned __int8) (x >> 56);
                     40: }
1.1       root       41: 
                     42: 
                     43: void
1.1.1.6   root       44: LongReverse (unsigned __int32 *buffer, unsigned byteCount)
1.1       root       45: {
1.1.1.6   root       46:        unsigned __int32 value;
1.1       root       47: 
1.1.1.6   root       48:        byteCount /= sizeof (unsigned __int32);
1.1       root       49:        while (byteCount--)
                     50:        {
                     51:                value = *buffer;
                     52:                value = ((value & 0xFF00FF00L) >> 8) | \
                     53:                    ((value & 0x00FF00FFL) << 8);
                     54:                *buffer++ = (value << 16) | (value >> 16);
                     55:        }
                     56: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.