File indexing completed on 2025-01-17 09:55:58
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _SHA1_H
0010 #define _SHA1_H
0011
0012 #include <sys/types.h>
0013
0014 #include <stdint.h>
0015
0016 #define SHA1_BLOCK_LENGTH 64
0017 #define SHA1_DIGEST_LENGTH 20
0018 #define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
0019
0020 typedef struct {
0021 uint32_t state[5];
0022 uint64_t count;
0023 uint8_t buffer[SHA1_BLOCK_LENGTH];
0024 } SHA1_CTX;
0025
0026 #ifdef __cplusplus
0027 extern "C" {
0028 #endif
0029
0030 void SHA1Init(SHA1_CTX *);
0031 void SHA1Pad(SHA1_CTX *);
0032 void SHA1Transform(uint32_t [5], const uint8_t [SHA1_BLOCK_LENGTH]);
0033 void SHA1Update(SHA1_CTX *, const uint8_t *, size_t);
0034 void SHA1Final(uint8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *);
0035 char *SHA1End(SHA1_CTX *, char *);
0036 char *SHA1File(const char *, char *);
0037 char *SHA1FileChunk(const char *, char *, off_t, off_t);
0038 char *SHA1Data(const uint8_t *, size_t, char *);
0039
0040 #ifdef __cplusplus
0041 }
0042 #endif
0043
0044 #define HTONDIGEST(x) do { \
0045 x[0] = htonl(x[0]); \
0046 x[1] = htonl(x[1]); \
0047 x[2] = htonl(x[2]); \
0048 x[3] = htonl(x[3]); \
0049 x[4] = htonl(x[4]); } while (0)
0050
0051 #define NTOHDIGEST(x) do { \
0052 x[0] = ntohl(x[0]); \
0053 x[1] = ntohl(x[1]); \
0054 x[2] = ntohl(x[2]); \
0055 x[3] = ntohl(x[3]); \
0056 x[4] = ntohl(x[4]); } while (0)
0057
0058 #endif