"Fossies" - the Fresh Open Source Software Archive

Member "src/Crypto/GostCipher.h" (10 Oct 2018, 1470 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 "GostCipher.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.18_Source_vs_1.19_Source.

    1 
    2 /*
    3  Copyright (c) 2008-2011 TrueCrypt Developers Association. All rights reserved.
    4 
    5  Governed by the TrueCrypt License 3.0 the full text of which is contained in
    6  the file License.txt included in TrueCrypt binary and source code distribution
    7  packages.
    8 */
    9 
   10 
   11 
   12 #ifndef GOST_CIPHER_H
   13 #define GOST_CIPHER_H
   14 
   15 #include "Common/Tcdefs.h"
   16 #include "config.h"
   17 
   18 #ifdef __cplusplus
   19 extern "C" {
   20 #endif
   21 
   22 //In unsigned chars
   23 #define GOST_KEYSIZE    32
   24 #define GOST_BLOCKSIZE  8
   25 #define GOST_SBOX_SIZE  16
   26 
   27 //Production setting, but can be turned off to compare the algorithm with other implementations
   28 #define CIPHER_GOST89
   29 #define GOST_DYNAMIC_SBOXES
   30 
   31 #if defined(CIPHER_GOST89)
   32 
   33 #ifndef rotl32
   34 #define rotl32(b, shift) ((b << shift) | (b >> (32 - shift)))
   35 #endif
   36 
   37 #ifdef GST_WINDOWS_BOOT
   38 typedef int gst_word;
   39 typedef long gst_dword;
   40 typedef unsigned int gst_uword;
   41 typedef unsigned long gst_udword;
   42 #else
   43 typedef short gst_word;
   44 typedef int gst_dword;
   45 typedef unsigned short gst_uword;
   46 typedef unsigned int gst_udword;
   47 #endif
   48 
   49 typedef struct gost_kds
   50 {
   51     CRYPTOPP_ALIGN_DATA(16) byte key[32];
   52     gst_udword  sbox_cvt[256 * 4];
   53     byte            sbox[8][16];
   54 } gost_kds;
   55 
   56 #define GOST_KS             (sizeof(gost_kds))
   57 
   58 void gost_encrypt(const byte *in, byte *out, gost_kds *ks, int count);
   59 void gost_decrypt(const byte *in, byte *out, gost_kds *ks, int count);
   60 void gost_set_key(const byte *key, gost_kds *ks, int useDynamicSbox);
   61 
   62 #else 
   63 #define GOST_KS             (0)
   64 #endif
   65 
   66 #ifdef __cplusplus
   67 }
   68 #endif
   69 
   70 
   71 #endif