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 
14 /* When linking with libcvmfs, we have a name clash with functions of similar purpose. Redefine the names here to protect our namespace. */
15 
16 #define sha1_init dttools_sha1_init
17 #define sha1_update dttools_sha1_update
18 #define sha1_final dttools_sha1_final
19 #define sha1_buffer dttools_sha1_buffer
20 #define sha1_file dttools_sha1_file
21 #define sha1_string dttools_sha1_string
22 
23 #include "int_sizes.h"
24 
25 #define SHA1_DIGEST_LENGTH 20
26 #define SHA1_DIGEST_ASCII_LENGTH 42
27 
28 typedef struct {
29  UINT32_T digest[5];
30  UINT32_T countLo, countHi;
31  UINT32_T data[16];
32  int Endianness;
34 
35 void sha1_init(sha1_context_t * ctx);
36 void sha1_update(sha1_context_t * ctx, const unsigned char *, unsigned int);
37 void sha1_final(unsigned char digest[SHA1_DIGEST_LENGTH], sha1_context_t * ctx);
38 
47 void sha1_buffer(const char *buffer, int length, unsigned char digest[SHA1_DIGEST_LENGTH]);
48 
57 int sha1_file(const char *filename, unsigned char digest[SHA1_DIGEST_LENGTH]);
58 
64 const char *sha1_string(unsigned char digest[SHA1_DIGEST_LENGTH]);
65 
66 #endif
const char * sha1_string(unsigned char digest[SHA1_DIGEST_LENGTH])
Convert an SHA1 digest into a printable string.
int sha1_file(const char *filename, unsigned char digest[SHA1_DIGEST_LENGTH])
Checksum a local file.
void sha1_buffer(const char *buffer, int length, unsigned char digest[SHA1_DIGEST_LENGTH])
Checksum a memory buffer.
Definition: sha1.h:28