libsodium (1.0.19)

(root)/
include/
sodium/
crypto_hash_sha256.h
       1  #ifndef crypto_hash_sha256_H
       2  #define crypto_hash_sha256_H
       3  
       4  /*
       5   * WARNING: Unless you absolutely need to use SHA256 for interoperability,
       6   * purposes, you might want to consider crypto_generichash() instead.
       7   * Unlike SHA256, crypto_generichash() is not vulnerable to length
       8   * extension attacks.
       9   */
      10  
      11  #include <stddef.h>
      12  #include <stdint.h>
      13  #include <stdlib.h>
      14  
      15  #include "export.h"
      16  
      17  #ifdef __cplusplus
      18  # ifdef __GNUC__
      19  #  pragma GCC diagnostic ignored "-Wlong-long"
      20  # endif
      21  extern "C" {
      22  #endif
      23  
      24  typedef struct crypto_hash_sha256_state {
      25      uint32_t state[8];
      26      uint64_t count;
      27      uint8_t  buf[64];
      28  } crypto_hash_sha256_state;
      29  
      30  SODIUM_EXPORT
      31  size_t crypto_hash_sha256_statebytes(void);
      32  
      33  #define crypto_hash_sha256_BYTES 32U
      34  SODIUM_EXPORT
      35  size_t crypto_hash_sha256_bytes(void);
      36  
      37  SODIUM_EXPORT
      38  int crypto_hash_sha256(unsigned char *out, const unsigned char *in,
      39                         unsigned long long inlen) __attribute__ ((nonnull(1)));
      40  
      41  SODIUM_EXPORT
      42  int crypto_hash_sha256_init(crypto_hash_sha256_state *state)
      43              __attribute__ ((nonnull));
      44  
      45  SODIUM_EXPORT
      46  int crypto_hash_sha256_update(crypto_hash_sha256_state *state,
      47                                const unsigned char *in,
      48                                unsigned long long inlen)
      49              __attribute__ ((nonnull(1)));
      50  
      51  SODIUM_EXPORT
      52  int crypto_hash_sha256_final(crypto_hash_sha256_state *state,
      53                               unsigned char *out)
      54              __attribute__ ((nonnull));
      55  
      56  #ifdef __cplusplus
      57  }
      58  #endif
      59  
      60  #endif