1/* $OpenBSD: sha1.h,v 1.22 2004/05/05 17:09:45 millert Exp $ */
2
3/*
4 * SHA-1 in C
5 * By Steve Reid <steve@edmweb.com>
6 * 100% Public Domain
7 */
8
9#ifndef _SHA1_H
10#define _SHA1_H
11
12#include <sys/types.h>
13
14#include <stdint.h>
15
16#define SHA1_BLOCK_LENGTH 64
17#define SHA1_DIGEST_LENGTH 20
18#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
19
20typedef struct {
21 uint32_t state[5];
22 uint64_t count;
23 uint8_t buffer[SHA1_BLOCK_LENGTH];
24} SHA1_CTX;
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30void SHA1Init(SHA1_CTX *);
31void SHA1Pad(SHA1_CTX *);
32void SHA1Transform(uint32_t [5], const uint8_t [SHA1_BLOCK_LENGTH]);
33void SHA1Update(SHA1_CTX *, const uint8_t *, size_t);
34void SHA1Final(uint8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *);
35char *SHA1End(SHA1_CTX *, char *);
36char *SHA1File(const char *, char *);
37char *SHA1FileChunk(const char *, char *, off_t, off_t);
38char *SHA1Data(const uint8_t *, size_t, char *);
39
40#ifdef __cplusplus
41}
42#endif
43
44#define HTONDIGEST(x) do { \
45 x[0] = htonl(x[0]); \
46 x[1] = htonl(x[1]); \
47 x[2] = htonl(x[2]); \
48 x[3] = htonl(x[3]); \
49 x[4] = htonl(x[4]); } while (0)
50
51#define NTOHDIGEST(x) do { \
52 x[0] = ntohl(x[0]); \
53 x[1] = ntohl(x[1]); \
54 x[2] = ntohl(x[2]); \
55 x[3] = ntohl(x[3]); \
56 x[4] = ntohl(x[4]); } while (0)
57
58#endif /* _SHA1_H */
59

source code of include/sha1.h