xref: /dragonfly/contrib/ldns/ldns/sha1.h (revision d4ef6694)
1 #ifndef LDNS_SHA1_H
2 #define LDNS_SHA1_H
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #define LDNS_SHA1_BLOCK_LENGTH               64
9 #define LDNS_SHA1_DIGEST_LENGTH              20
10 
11 typedef struct {
12         uint32_t       state[5];
13         uint64_t       count;
14         unsigned char   buffer[LDNS_SHA1_BLOCK_LENGTH];
15 } ldns_sha1_ctx;
16 
17 void ldns_sha1_init(ldns_sha1_ctx * context);
18 void ldns_sha1_transform(uint32_t state[5], const unsigned char buffer[LDNS_SHA1_BLOCK_LENGTH]);
19 void ldns_sha1_update(ldns_sha1_ctx *context, const unsigned char *data, unsigned int len);
20 void ldns_sha1_final(unsigned char digest[LDNS_SHA1_DIGEST_LENGTH], ldns_sha1_ctx *context);
21 
22 /**
23  * Convenience function to digest a fixed block of data at once.
24  *
25  * \param[in] data the data to digest
26  * \param[in] data_len the length of data in bytes
27  * \param[out] digest the length of data in bytes
28  *             This pointer MUST have LDNS_SHA1_DIGEST_LENGTH bytes
29  *             available
30  * \return the SHA1 digest of the given data
31  */
32 unsigned char *ldns_sha1(unsigned char *data, unsigned int data_len, unsigned char *digest);
33 
34 #ifdef __cplusplus
35 }
36 #endif
37 
38 #endif /* LDNS_SHA1_H */
39