(root)/
Python-3.12.0/
Modules/
_hacl/
Hacl_Hash_SHA3.h
       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  
      26  #ifndef __Hacl_Hash_SHA3_H
      27  #define __Hacl_Hash_SHA3_H
      28  
      29  #if defined(__cplusplus)
      30  extern "C" {
      31  #endif
      32  
      33  #include <string.h>
      34  #include "krml/types.h"
      35  #include "krml/lowstar_endianness.h"
      36  #include "krml/internal/target.h"
      37  
      38  #include "Hacl_Streaming_Types.h"
      39  
      40  typedef struct Hacl_Streaming_Keccak_hash_buf_s
      41  {
      42    Spec_Hash_Definitions_hash_alg fst;
      43    uint64_t *snd;
      44  }
      45  Hacl_Streaming_Keccak_hash_buf;
      46  
      47  typedef struct Hacl_Streaming_Keccak_state_s
      48  {
      49    Hacl_Streaming_Keccak_hash_buf block_state;
      50    uint8_t *buf;
      51    uint64_t total_len;
      52  }
      53  Hacl_Streaming_Keccak_state;
      54  
      55  Spec_Hash_Definitions_hash_alg Hacl_Streaming_Keccak_get_alg(Hacl_Streaming_Keccak_state *s);
      56  
      57  Hacl_Streaming_Keccak_state *Hacl_Streaming_Keccak_malloc(Spec_Hash_Definitions_hash_alg a);
      58  
      59  void Hacl_Streaming_Keccak_free(Hacl_Streaming_Keccak_state *s);
      60  
      61  Hacl_Streaming_Keccak_state *Hacl_Streaming_Keccak_copy(Hacl_Streaming_Keccak_state *s0);
      62  
      63  void Hacl_Streaming_Keccak_reset(Hacl_Streaming_Keccak_state *s);
      64  
      65  Hacl_Streaming_Types_error_code
      66  Hacl_Streaming_Keccak_update(Hacl_Streaming_Keccak_state *p, uint8_t *data, uint32_t len);
      67  
      68  Hacl_Streaming_Types_error_code
      69  Hacl_Streaming_Keccak_finish(Hacl_Streaming_Keccak_state *s, uint8_t *dst);
      70  
      71  Hacl_Streaming_Types_error_code
      72  Hacl_Streaming_Keccak_squeeze(Hacl_Streaming_Keccak_state *s, uint8_t *dst, uint32_t l);
      73  
      74  uint32_t Hacl_Streaming_Keccak_block_len(Hacl_Streaming_Keccak_state *s);
      75  
      76  uint32_t Hacl_Streaming_Keccak_hash_len(Hacl_Streaming_Keccak_state *s);
      77  
      78  bool Hacl_Streaming_Keccak_is_shake(Hacl_Streaming_Keccak_state *s);
      79  
      80  void
      81  Hacl_SHA3_shake128_hacl(
      82    uint32_t inputByteLen,
      83    uint8_t *input,
      84    uint32_t outputByteLen,
      85    uint8_t *output
      86  );
      87  
      88  void
      89  Hacl_SHA3_shake256_hacl(
      90    uint32_t inputByteLen,
      91    uint8_t *input,
      92    uint32_t outputByteLen,
      93    uint8_t *output
      94  );
      95  
      96  void Hacl_SHA3_sha3_224(uint32_t inputByteLen, uint8_t *input, uint8_t *output);
      97  
      98  void Hacl_SHA3_sha3_256(uint32_t inputByteLen, uint8_t *input, uint8_t *output);
      99  
     100  void Hacl_SHA3_sha3_384(uint32_t inputByteLen, uint8_t *input, uint8_t *output);
     101  
     102  void Hacl_SHA3_sha3_512(uint32_t inputByteLen, uint8_t *input, uint8_t *output);
     103  
     104  void Hacl_Impl_SHA3_absorb_inner(uint32_t rateInBytes, uint8_t *block, uint64_t *s);
     105  
     106  void
     107  Hacl_Impl_SHA3_squeeze(
     108    uint64_t *s,
     109    uint32_t rateInBytes,
     110    uint32_t outputByteLen,
     111    uint8_t *output
     112  );
     113  
     114  void
     115  Hacl_Impl_SHA3_keccak(
     116    uint32_t rate,
     117    uint32_t capacity,
     118    uint32_t inputByteLen,
     119    uint8_t *input,
     120    uint8_t delimitedSuffix,
     121    uint32_t outputByteLen,
     122    uint8_t *output
     123  );
     124  
     125  #if defined(__cplusplus)
     126  }
     127  #endif
     128  
     129  #define __Hacl_Hash_SHA3_H_DEFINED
     130  #endif