2012-12-05 15:19:48 -08:00
|
|
|
/* $OpenBSD: sha1.h,v 1.24 2012/12/05 23:19:57 deraadt Exp $ */
|
1997-07-10 15:52:59 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* SHA-1 in C
|
|
|
|
* By Steve Reid <steve@edmweb.com>
|
|
|
|
* 100% Public Domain
|
|
|
|
*/
|
1996-09-29 09:13:19 -07:00
|
|
|
|
1996-09-29 11:30:49 -07:00
|
|
|
#ifndef _SHA1_H
|
|
|
|
#define _SHA1_H
|
|
|
|
|
2004-04-26 12:38:12 -07:00
|
|
|
#define SHA1_BLOCK_LENGTH 64
|
|
|
|
#define SHA1_DIGEST_LENGTH 20
|
|
|
|
#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
|
|
|
|
|
1996-09-29 09:13:19 -07:00
|
|
|
typedef struct {
|
1997-07-10 15:52:59 -07:00
|
|
|
u_int32_t state[5];
|
2004-04-27 08:54:56 -07:00
|
|
|
u_int64_t count;
|
2004-04-26 12:38:12 -07:00
|
|
|
u_int8_t buffer[SHA1_BLOCK_LENGTH];
|
1997-07-10 15:52:59 -07:00
|
|
|
} SHA1_CTX;
|
2002-12-22 20:33:31 -08:00
|
|
|
|
|
|
|
__BEGIN_DECLS
|
2004-04-27 08:54:56 -07:00
|
|
|
void SHA1Init(SHA1_CTX *);
|
2004-05-03 10:30:14 -07:00
|
|
|
void SHA1Pad(SHA1_CTX *);
|
2004-05-05 10:09:45 -07:00
|
|
|
void SHA1Transform(u_int32_t [5], const u_int8_t [SHA1_BLOCK_LENGTH])
|
2004-04-29 08:51:16 -07:00
|
|
|
__attribute__((__bounded__(__minbytes__,1,5)))
|
|
|
|
__attribute__((__bounded__(__minbytes__,2,SHA1_BLOCK_LENGTH)));
|
2004-05-03 10:30:14 -07:00
|
|
|
void SHA1Update(SHA1_CTX *, const u_int8_t *, size_t)
|
2004-04-29 08:51:16 -07:00
|
|
|
__attribute__((__bounded__(__string__,2,3)));
|
2004-04-26 12:38:12 -07:00
|
|
|
void SHA1Final(u_int8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *)
|
2004-04-29 08:51:16 -07:00
|
|
|
__attribute__((__bounded__(__minbytes__,1,SHA1_DIGEST_LENGTH)));
|
|
|
|
char *SHA1End(SHA1_CTX *, char *)
|
|
|
|
__attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
|
2004-06-21 18:57:29 -07:00
|
|
|
char *SHA1File(const char *, char *)
|
2004-04-29 08:51:16 -07:00
|
|
|
__attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
|
2004-06-21 18:57:29 -07:00
|
|
|
char *SHA1FileChunk(const char *, char *, off_t, off_t)
|
2004-05-03 10:30:14 -07:00
|
|
|
__attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
|
2004-04-29 08:51:16 -07:00
|
|
|
char *SHA1Data(const u_int8_t *, size_t, char *)
|
|
|
|
__attribute__((__bounded__(__string__,1,2)))
|
|
|
|
__attribute__((__bounded__(__minbytes__,3,SHA1_DIGEST_STRING_LENGTH)));
|
2002-12-22 20:33:31 -08:00
|
|
|
__END_DECLS
|
1996-09-29 11:30:49 -07:00
|
|
|
|
2002-12-22 20:33:31 -08:00
|
|
|
#define HTONDIGEST(x) do { \
|
|
|
|
x[0] = htonl(x[0]); \
|
|
|
|
x[1] = htonl(x[1]); \
|
|
|
|
x[2] = htonl(x[2]); \
|
|
|
|
x[3] = htonl(x[3]); \
|
|
|
|
x[4] = htonl(x[4]); } while (0)
|
|
|
|
|
|
|
|
#define NTOHDIGEST(x) do { \
|
|
|
|
x[0] = ntohl(x[0]); \
|
|
|
|
x[1] = ntohl(x[1]); \
|
|
|
|
x[2] = ntohl(x[2]); \
|
|
|
|
x[3] = ntohl(x[3]); \
|
|
|
|
x[4] = ntohl(x[4]); } while (0)
|
1999-02-02 19:13:18 -08:00
|
|
|
|
1996-09-29 11:30:49 -07:00
|
|
|
#endif /* _SHA1_H */
|