cctools
sha1.h
Go to the documentation of this file.
1/*
2Copyright (C) 2022 The University of Notre Dame
3This software is distributed under the GNU General Public License.
4See 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
33typedef struct {
34 uint32_t digest[5];
35 size_t countLo, countHi;
36 uint32_t data[16];
37 int Endianness;
39
40void sha1_init(sha1_context_t * ctx);
41void sha1_update(sha1_context_t * ctx, const void *, size_t);
42void sha1_final(unsigned char digest[SHA1_DIGEST_LENGTH], sha1_context_t * ctx);
43
52void sha1_buffer(const void *buffer, size_t length, unsigned char digest[SHA1_DIGEST_LENGTH]);
53
62int sha1_file(const char *path, unsigned char digest[SHA1_DIGEST_LENGTH]);
63
64int sha1_fd(int fd, unsigned char digest[SHA1_DIGEST_LENGTH]);
65
71const char *sha1_string(unsigned char digest[SHA1_DIGEST_LENGTH]);
72
73#endif
const char * sha1_string(unsigned char digest[SHA1_DIGEST_LENGTH])
Convert an SHA1 digest into a printable string.
int sha1_file(const char *path, unsigned char digest[SHA1_DIGEST_LENGTH])
Checksum a local file.
void sha1_buffer(const void *buffer, size_t length, unsigned char digest[SHA1_DIGEST_LENGTH])
Checksum a memory buffer.
Definition buffer.h:26
Definition sha1.h:33