aboutsummaryrefslogtreecommitdiffstats
path: root/common.h
blob: 43735fc05e8085eb689b7423f93d3584a0928bf2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* See LICENSE file for copyright and license details. */
#include "libsha1.h"

#include <sys/stat.h>
#include <alloca.h>
#include <errno.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>


#ifndef ALLOCA_LIMIT
# define ALLOCA_LIMIT 0
#endif


/**
 * Truncate an unsigned integer to an unsigned 32-bit integer
 * 
 * @param   X:uint_least32_t  The value to truncate
 * @return  :uint_least32_t   The 32 lowest bits in `X`
 */
#define TRUNC32(X) ((X) & (uint_least32_t)0xFFFFFFFFUL)


/**
 * Process a chunk using SHA-1 or SHA-0
 * 
 * @param   state  The hashing state
 * @param   data   The data to process
 * @param   len    The number of available bytes
 * @return         The number of processed bytes
 */
#if defined(__GNUC__)
__attribute__((__nonnull__, __nothrow__))
#endif
size_t libsha1_process(struct libsha1_state *restrict, const unsigned char *restrict, size_t);