"Fossies" - the Fresh Open Source Software Archive

Member "src/Crypto/Sha2.h" (10 Oct 2018, 1439 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 "Sha2.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (c) 2013-2017 IDRIX
    3  * Governed by the Apache License 2.0 the full text of which is contained
    4  * in the file License.txt included in VeraCrypt binary and source
    5  * code distribution packages.
    6  */
    7 
    8 #ifndef _SHA2_H
    9 #define _SHA2_H
   10 
   11 #include "Common/Tcdefs.h"
   12 #include "Common/Endian.h"
   13 #include "Crypto/config.h"
   14 
   15 #if defined(__cplusplus)
   16 extern "C" {
   17 #endif
   18 
   19 #define SHA256_DIGEST_SIZE  32
   20 #define SHA256_BLOCK_SIZE   64
   21 
   22 #define SHA512_DIGEST_SIZE  64
   23 #define SHA512_BLOCK_SIZE  128
   24 
   25 #if CRYPTOPP_BOOL_X64
   26 #define SHA2_ALIGN  CRYPTOPP_ALIGN_DATA(32)
   27 #else
   28 #define SHA2_ALIGN  CRYPTOPP_ALIGN_DATA(16)
   29 #endif
   30 
   31 typedef struct
   32 {   uint_64t count[2];
   33     SHA2_ALIGN uint_64t hash[8];
   34     SHA2_ALIGN uint_64t wbuf[16];
   35 } sha512_ctx;
   36 
   37 typedef struct
   38 {   uint_32t count[2];
   39     SHA2_ALIGN uint_32t hash[8];
   40     SHA2_ALIGN uint_32t wbuf[16];
   41 } sha256_ctx;
   42 
   43 
   44 void sha512_begin(sha512_ctx* ctx);
   45 void sha512_hash(const unsigned char * source, uint_64t sourceLen, sha512_ctx *ctx);
   46 void sha512_end(unsigned char * result, sha512_ctx* ctx);
   47 void sha512(unsigned char * result, const unsigned char* source, uint_64t sourceLen);
   48 
   49 void sha256_begin(sha256_ctx* ctx);
   50 void sha256_hash(const unsigned char * source, uint_32t sourceLen, sha256_ctx *ctx);
   51 void sha256_end(unsigned char * result, sha256_ctx* ctx);
   52 void sha256(unsigned char * result, const unsigned char* source, uint_32t sourceLen);
   53 
   54 #if defined(__cplusplus)
   55 }
   56 #endif
   57 
   58 
   59 
   60 #endif