tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Hacl_Hash_SHA2_shim.h (980B)


      1 #include "blapi.h"
      2 #include "../pqg.h"
      3 
      4 static inline void
      5 sha512_pre_msg(uint8_t *hash, uint8_t *prefix, uint32_t len, uint8_t *input)
      6 {
      7    SHA512Context *ctx = SHA512_NewContext();
      8    uint32_t l = SHA512_LENGTH;
      9    SHA512_Begin(ctx);
     10    SHA512_Update(ctx, prefix, 32);
     11    SHA512_Update(ctx, input, len);
     12    SHA512_End(ctx, hash, &l, SHA512_LENGTH);
     13    SHA512_DestroyContext(ctx, PR_TRUE);
     14 }
     15 
     16 static inline void
     17 sha512_pre_pre2_msg(
     18    uint8_t *hash,
     19    uint8_t *prefix,
     20    uint8_t *prefix2,
     21    uint32_t len,
     22    uint8_t *input)
     23 {
     24    SHA512Context *ctx = SHA512_NewContext();
     25    uint32_t l = SHA512_LENGTH;
     26    SHA512_Begin(ctx);
     27    SHA512_Update(ctx, prefix, 32);
     28    SHA512_Update(ctx, prefix2, 32);
     29    SHA512_Update(ctx, input, len);
     30    SHA512_End(ctx, hash, &l, SHA512_LENGTH);
     31    SHA512_DestroyContext(ctx, PR_TRUE);
     32 }
     33 
     34 static void
     35 Hacl_Streaming_SHA2_hash_512(uint8_t *secret, uint32_t len, uint8_t *expanded)
     36 {
     37    SHA512_HashBuf(expanded, secret, len);
     38 }