cctools
sha1.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2022 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 #ifndef DOXYGEN
20 
21 #define sha1_init dttools_sha1_init
22 #define sha1_update dttools_sha1_update
23 #define sha1_final dttools_sha1_final
24 #define sha1_buffer dttools_sha1_buffer
25 #define sha1_file dttools_sha1_file
26 #define sha1_string dttools_sha1_string
27 
28 #endif
29 
30 #define SHA1_DIGEST_LENGTH 20
31 #define SHA1_DIGEST_ASCII_LENGTH 42
32 
33 typedef struct {
34  uint32_t digest[5];
35  size_t countLo, countHi;
36  uint32_t data[16];
37  int Endianness;
39 
40 void sha1_init(sha1_context_t * ctx);
41 void sha1_update(sha1_context_t * ctx, const void *, size_t);
42 void sha1_final(unsigned char digest[SHA1_DIGEST_LENGTH], sha1_context_t * ctx);
43 
52 void sha1_buffer(const void *buffer, size_t length, unsigned char digest[SHA1_DIGEST_LENGTH]);
53 
62 int sha1_file(const char *path, unsigned char digest[SHA1_DIGEST_LENGTH]);
63 
64 int sha1_fd(int fd, unsigned char digest[SHA1_DIGEST_LENGTH]);
65 
71 const char *sha1_string(unsigned char digest[SHA1_DIGEST_LENGTH]);
72 
73 #endif
sha1_string
const char * sha1_string(unsigned char digest[SHA1_DIGEST_LENGTH])
Convert an SHA1 digest into a printable string.
sha1_context_t
Definition: sha1.h:33
sha1_buffer
void sha1_buffer(const void *buffer, size_t length, unsigned char digest[SHA1_DIGEST_LENGTH])
Checksum a memory buffer.
buffer
Definition: buffer.h:26
sha1_file
int sha1_file(const char *path, unsigned char digest[SHA1_DIGEST_LENGTH])
Checksum a local file.