cctools
sha1.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2008- The University of Notre Dame
3 This software is distributed under the GNU General Public License.
4 See the file COPYING for details.
5 */
6 
7 #ifndef SHA1_H
8 #define SHA1_H
9 
10 #include <stdint.h>
11 #include <stdlib.h>
12 
17 /* When linking with libcvmfs, we have a name clash with functions of similar purpose. Redefine the names here to protect our namespace. */
18 
19 #define sha1_init dttools_sha1_init
20 #define sha1_update dttools_sha1_update
21 #define sha1_final dttools_sha1_final
22 #define sha1_buffer dttools_sha1_buffer
23 #define sha1_file dttools_sha1_file
24 #define sha1_string dttools_sha1_string
25 
26 #define SHA1_DIGEST_LENGTH 20
27 #define SHA1_DIGEST_ASCII_LENGTH 42
28 
29 typedef struct {
30  uint32_t digest[5];
31  size_t countLo, countHi;
32  uint32_t data[16];
33  int Endianness;
35 
36 void sha1_init(sha1_context_t * ctx);
37 void sha1_update(sha1_context_t * ctx, const void *, size_t);
38 void sha1_final(unsigned char digest[SHA1_DIGEST_LENGTH], sha1_context_t * ctx);
39 
48 void sha1_buffer(const void *buffer, size_t length, unsigned char digest[SHA1_DIGEST_LENGTH]);
49 
58 int sha1_file(const char *path, unsigned char digest[SHA1_DIGEST_LENGTH]);
59 
60 int sha1_fd(int fd, unsigned char digest[SHA1_DIGEST_LENGTH]);
61 
67 const char *sha1_string(unsigned char digest[SHA1_DIGEST_LENGTH]);
68 
69 #endif
const char * sha1_string(unsigned char digest[SHA1_DIGEST_LENGTH])
Convert an SHA1 digest into a printable string.
Definition: buffer.h:26
void sha1_buffer(const void *buffer, size_t length, unsigned char digest[SHA1_DIGEST_LENGTH])
Checksum a memory buffer.
Definition: sha1.h:29
int sha1_file(const char *path, unsigned char digest[SHA1_DIGEST_LENGTH])
Checksum a local file.