"Fossies" - the Fresh Open Source Software Archive

Member "src/Common/Xts.h" (10 Oct 2018, 2733 Bytes) of package /windows/misc/VeraCrypt_1.23-Hotfix-2_Source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Xts.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  Derived from source code of TrueCrypt 7.1a, which is
    3  Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
    4  by the TrueCrypt License 3.0.
    5 
    6  Modifications and additions to the original source code (contained in this file)
    7  and all other portions of this file are Copyright (c) 2013-2017 IDRIX
    8  and are governed by the Apache License 2.0 the full text of which is
    9  contained in the file License.txt included in VeraCrypt binary and source
   10  code distribution packages.
   11 */
   12 
   13 #ifndef XTS_H
   14 #define XTS_H
   15 
   16 // Header files (optional)
   17 
   18 #include "Tcdefs.h"
   19 #include "Common/Endian.h"
   20 #include "Crypto.h"
   21 
   22 #ifdef __cplusplus
   23 extern "C" {
   24 #endif
   25 
   26 // Macros
   27 
   28 #ifndef LITTLE_ENDIAN
   29 #   define LITTLE_ENDIAN    1
   30 #endif
   31 
   32 #ifndef BIG_ENDIAN
   33 #   define BIG_ENDIAN       2
   34 #endif
   35 
   36 #ifndef BYTE_ORDER
   37 #   define BYTE_ORDER       LITTLE_ENDIAN
   38 #endif
   39 
   40 #ifndef LE64
   41 #   if BYTE_ORDER == LITTLE_ENDIAN
   42 #       define LE64(x)  (x)
   43 #   endif
   44 #endif
   45 
   46 // Custom data types
   47 
   48 #ifndef TC_LARGEST_COMPILER_UINT
   49 #   ifdef TC_NO_COMPILER_INT64
   50         typedef unsigned __int32    TC_LARGEST_COMPILER_UINT;
   51 #   else
   52         typedef unsigned __int64    TC_LARGEST_COMPILER_UINT;
   53 #   endif
   54 #endif
   55 
   56 #ifndef TCDEFS_H
   57 typedef union
   58 {
   59     struct
   60     {
   61         unsigned __int32 LowPart;
   62         unsigned __int32 HighPart;
   63     };
   64 #   ifndef TC_NO_COMPILER_INT64
   65     unsigned __int64 Value;
   66 #   endif
   67 
   68 } UINT64_STRUCT;
   69 #endif
   70 
   71 // Public function prototypes
   72 
   73 void EncryptBufferXTS (unsigned __int8 *buffer, TC_LARGEST_COMPILER_UINT length, const UINT64_STRUCT *startDataUnitNo, unsigned int startCipherBlockNo, unsigned __int8 *ks, unsigned __int8 *ks2, int cipher);
   74 static void EncryptBufferXTSParallel (unsigned __int8 *buffer, TC_LARGEST_COMPILER_UINT length, const UINT64_STRUCT *startDataUnitNo, unsigned int startCipherBlockNo, unsigned __int8 *ks, unsigned __int8 *ks2, int cipher);
   75 static void EncryptBufferXTSNonParallel (unsigned __int8 *buffer, TC_LARGEST_COMPILER_UINT length, const UINT64_STRUCT *startDataUnitNo, unsigned int startCipherBlockNo, unsigned __int8 *ks, unsigned __int8 *ks2, int cipher);
   76 void DecryptBufferXTS (unsigned __int8 *buffer, TC_LARGEST_COMPILER_UINT length, const UINT64_STRUCT *startDataUnitNo, unsigned int startCipherBlockNo, unsigned __int8 *ks, unsigned __int8 *ks2, int cipher);
   77 static void DecryptBufferXTSParallel (unsigned __int8 *buffer, TC_LARGEST_COMPILER_UINT length, const UINT64_STRUCT *startDataUnitNo, unsigned int startCipherBlockNo, unsigned __int8 *ks, unsigned __int8 *ks2, int cipher);
   78 static void DecryptBufferXTSNonParallel (unsigned __int8 *buffer, TC_LARGEST_COMPILER_UINT length, const UINT64_STRUCT *startDataUnitNo, unsigned int startCipherBlockNo, unsigned __int8 *ks, unsigned __int8 *ks2, int cipher);
   79 
   80 #ifdef __cplusplus
   81 }
   82 #endif
   83 
   84 #endif  // #ifndef XTS_H