summaryrefslogtreecommitdiff
path: root/common/sha1.h
blob: e55e52e7c667ca82cdc8f049176de68c0c01828b (plain)
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
39
40
41
42
43
/*
 *    Fetched from ftp://ftp.funet.fi/pub/crypt/hash/sha/sha1.c on May 4, 1999
 *    Modified by EPG May 6, 1999
 *
 * SHA-1 in C
 * By Steve Reid <steve@edmweb.com>
 * 100% Public Domain
 *
 * Headers and minor additions by Stef Walter <stef@memberwebs.com>
 */

#ifndef __SHA1_H__
#define __SHA1_H__

#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN
#endif

#ifdef __cplusplus
extern "C" {
#endif

#define SHA1_LEN  20

typedef struct sha1_ctx
{
    unsigned long state[5];
    unsigned long count[2];
    unsigned char buffer[64];
}
sha1_ctx_t;

void sha1_init(sha1_ctx_t* context);
void sha1_update(sha1_ctx_t* context, const void* data, unsigned int len);
void sha1_final(unsigned char digest[SHA1_LEN], sha1_ctx_t* context);
void sha1_string(unsigned char digest[SHA1_LEN], const char* str);
int sha1_strcmp(unsigned char digest[SHA1_LEN], const char* str);

#ifdef __cplusplus
}
#endif

#endif // __SHA1_H__