Initial vendor import of ldns-1.6.4 into contrib.
[dragonfly.git] / contrib / ldns / ldns / sha1.h
1 #ifndef LDNS_SHA1_H
2 #define LDNS_SHA1_H
3  
4 #define LDNS_SHA1_BLOCK_LENGTH               64
5 #define LDNS_SHA1_DIGEST_LENGTH              20
6
7 typedef struct {
8         uint32_t       state[5];
9         uint64_t       count;
10         unsigned char   buffer[LDNS_SHA1_BLOCK_LENGTH];
11 } ldns_sha1_ctx;
12   
13 void ldns_sha1_init(ldns_sha1_ctx * context);
14 void ldns_sha1_transform(uint32_t state[5], const unsigned char buffer[LDNS_SHA1_BLOCK_LENGTH]);
15 void ldns_sha1_update(ldns_sha1_ctx *context, const unsigned char *data, unsigned int len);
16 void ldns_sha1_final(unsigned char digest[LDNS_SHA1_DIGEST_LENGTH], ldns_sha1_ctx *context);
17
18 /**
19  * Convenience function to digest a fixed block of data at once.
20  *
21  * \param[in] data the data to digest
22  * \param[in] data_len the length of data in bytes
23  * \param[out] digest the length of data in bytes
24  *             This pointer MUST have LDNS_SHA1_DIGEST_LENGTH bytes
25  *             available
26  * \return the SHA1 digest of the given data
27  */
28 unsigned char *ldns_sha1(unsigned char *data, unsigned int data_len, unsigned char *digest);
29 #endif /* LDNS_SHA1_H */