LCOV - code coverage report
Current view: top level - externals/compact25519/src/c25519 - sha512.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 3 3
Test Date: 2026-03-12 12:01:18 Functions: 100.0 % 1 1
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* SHA512
       2                 :             :  * Daniel Beer <dlbeer@gmail.com>, 22 Apr 2014
       3                 :             :  *
       4                 :             :  * This file is in the public domain.
       5                 :             :  */
       6                 :             : 
       7                 :             : #ifndef SHA512_H_
       8                 :             : #define SHA512_H_
       9                 :             : 
      10                 :             : #if !defined(COMPACT_DISABLE_ED25519) || !defined(COMPACT_DISABLE_X25519_DERIVE)
      11                 :             : #include <stdint.h>
      12                 :             : #include <stddef.h>
      13                 :             : #include <string.h>
      14                 :             : 
      15                 :             : /* SHA512 state. State is updated as data is fed in, and then the final
      16                 :             :  * hash can be read out in slices.
      17                 :             :  *
      18                 :             :  * Data is fed in as a sequence of full blocks terminated by a single
      19                 :             :  * partial block.
      20                 :             :  */
      21                 :             : struct sha512_state {
      22                 :             :         uint64_t  h[8];
      23                 :             : };
      24                 :             : 
      25                 :             : /* Initial state */
      26                 :             : extern const struct sha512_state sha512_initial_state;
      27                 :             : 
      28                 :             : /* Set up a new context */
      29                 :           8 : static inline void sha512_init(struct sha512_state *s)
      30                 :             : {
      31                 :           8 :         memcpy(s, &sha512_initial_state, sizeof(*s));
      32                 :           8 : }
      33                 :             : 
      34                 :             : /* Feed a full block in */
      35                 :             : #define SHA512_BLOCK_SIZE  128
      36                 :             : 
      37                 :             : void sha512_block(struct sha512_state *s, const uint8_t *blk);
      38                 :             : 
      39                 :             : /* Feed the last partial block in. The total stream size must be
      40                 :             :  * specified. The size of the block given is assumed to be (total_size %
      41                 :             :  * SHA512_BLOCK_SIZE). This might be zero, but you still need to call
      42                 :             :  * this function to terminate the stream.
      43                 :             :  */
      44                 :             : void sha512_final(struct sha512_state *s, const uint8_t *blk,
      45                 :             :                   size_t total_size);
      46                 :             : 
      47                 :             : /* Fetch a slice of the hash result. */
      48                 :             : #define SHA512_HASH_SIZE  64
      49                 :             : 
      50                 :             : void sha512_get(const struct sha512_state *s, uint8_t *hash,
      51                 :             :                 unsigned int offset, unsigned int len);
      52                 :             : 
      53                 :             : #endif
      54                 :             : #endif
        

Generated by: LCOV version 2.0-1