tor-browser

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

Hacl_Hash_SHA3.h (3836B)


      1 /* MIT License
      2 *
      3 * Copyright (c) 2016-2022 INRIA, CMU and Microsoft Corporation
      4 * Copyright (c) 2022-2023 HACL* Contributors
      5 *
      6 * Permission is hereby granted, free of charge, to any person obtaining a copy
      7 * of this software and associated documentation files (the "Software"), to deal
      8 * in the Software without restriction, including without limitation the rights
      9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     10 * copies of the Software, and to permit persons to whom the Software is
     11 * furnished to do so, subject to the following conditions:
     12 *
     13 * The above copyright notice and this permission notice shall be included in all
     14 * copies or substantial portions of the Software.
     15 *
     16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     22 * SOFTWARE.
     23 */
     24 
     25 #ifndef __Hacl_Hash_SHA3_H
     26 #define __Hacl_Hash_SHA3_H
     27 
     28 #if defined(__cplusplus)
     29 extern "C" {
     30 #endif
     31 
     32 #include <string.h>
     33 #include "krml/internal/types.h"
     34 #include "krml/lowstar_endianness.h"
     35 #include "krml/internal/target.h"
     36 
     37 #include "Hacl_Streaming_Types.h"
     38 
     39 typedef struct Hacl_Streaming_Keccak_hash_buf_s {
     40    Spec_Hash_Definitions_hash_alg fst;
     41    uint64_t *snd;
     42 } Hacl_Streaming_Keccak_hash_buf;
     43 
     44 typedef struct Hacl_Streaming_Keccak_state_s {
     45    Hacl_Streaming_Keccak_hash_buf block_state;
     46    uint8_t *buf;
     47    uint64_t total_len;
     48 } Hacl_Streaming_Keccak_state;
     49 
     50 Spec_Hash_Definitions_hash_alg Hacl_Streaming_Keccak_get_alg(Hacl_Streaming_Keccak_state *s);
     51 
     52 Hacl_Streaming_Keccak_state *Hacl_Streaming_Keccak_malloc(Spec_Hash_Definitions_hash_alg a);
     53 
     54 void Hacl_Streaming_Keccak_free(Hacl_Streaming_Keccak_state *s);
     55 
     56 Hacl_Streaming_Keccak_state *Hacl_Streaming_Keccak_copy(Hacl_Streaming_Keccak_state *s0);
     57 
     58 void Hacl_Streaming_Keccak_reset(Hacl_Streaming_Keccak_state *s);
     59 
     60 Hacl_Streaming_Types_error_code
     61 Hacl_Streaming_Keccak_update(Hacl_Streaming_Keccak_state *p, uint8_t *data, uint32_t len);
     62 
     63 Hacl_Streaming_Types_error_code
     64 Hacl_Streaming_Keccak_finish(Hacl_Streaming_Keccak_state *s, uint8_t *dst);
     65 
     66 Hacl_Streaming_Types_error_code
     67 Hacl_Streaming_Keccak_squeeze(Hacl_Streaming_Keccak_state *s, uint8_t *dst, uint32_t l);
     68 
     69 uint32_t Hacl_Streaming_Keccak_block_len(Hacl_Streaming_Keccak_state *s);
     70 
     71 uint32_t Hacl_Streaming_Keccak_hash_len(Hacl_Streaming_Keccak_state *s);
     72 
     73 bool Hacl_Streaming_Keccak_is_shake(Hacl_Streaming_Keccak_state *s);
     74 
     75 void
     76 Hacl_SHA3_shake128_hacl(
     77    uint32_t inputByteLen,
     78    uint8_t *input,
     79    uint32_t outputByteLen,
     80    uint8_t *output);
     81 
     82 void
     83 Hacl_SHA3_shake256_hacl(
     84    uint32_t inputByteLen,
     85    uint8_t *input,
     86    uint32_t outputByteLen,
     87    uint8_t *output);
     88 
     89 void Hacl_SHA3_sha3_224(uint32_t inputByteLen, uint8_t *input, uint8_t *output);
     90 
     91 void Hacl_SHA3_sha3_256(uint32_t inputByteLen, uint8_t *input, uint8_t *output);
     92 
     93 void Hacl_SHA3_sha3_384(uint32_t inputByteLen, uint8_t *input, uint8_t *output);
     94 
     95 void Hacl_SHA3_sha3_512(uint32_t inputByteLen, uint8_t *input, uint8_t *output);
     96 
     97 void Hacl_Impl_SHA3_absorb_inner(uint32_t rateInBytes, uint8_t *block, uint64_t *s);
     98 
     99 void
    100 Hacl_Impl_SHA3_squeeze(
    101    uint64_t *s,
    102    uint32_t rateInBytes,
    103    uint32_t outputByteLen,
    104    uint8_t *output);
    105 
    106 void
    107 Hacl_Impl_SHA3_keccak(
    108    uint32_t rate,
    109    uint32_t capacity,
    110    uint32_t inputByteLen,
    111    uint8_t *input,
    112    uint8_t delimitedSuffix,
    113    uint32_t outputByteLen,
    114    uint8_t *output);
    115 
    116 #if defined(__cplusplus)
    117 }
    118 #endif
    119 
    120 #define __Hacl_Hash_SHA3_H_DEFINED
    121 #endif