File indexing completed on 2025-01-17 09:55:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 #ifndef _SHA2_H
0038 #define _SHA2_H
0039
0040 #include <sys/types.h>
0041
0042 #include <stdint.h>
0043
0044
0045 #define SHA256_BLOCK_LENGTH 64
0046 #define SHA256_DIGEST_LENGTH 32
0047 #define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
0048 #define SHA384_BLOCK_LENGTH 128
0049 #define SHA384_DIGEST_LENGTH 48
0050 #define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
0051 #define SHA512_BLOCK_LENGTH 128
0052 #define SHA512_DIGEST_LENGTH 64
0053 #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
0054
0055
0056
0057 typedef struct _SHA2_CTX {
0058 union {
0059 uint32_t st32[8];
0060 uint64_t st64[8];
0061 } state;
0062 uint64_t bitcount[2];
0063 uint8_t buffer[SHA512_BLOCK_LENGTH];
0064 } SHA2_CTX;
0065
0066 #ifdef __cplusplus
0067 extern "C" {
0068 #endif
0069
0070 void SHA256Init(SHA2_CTX *);
0071 void SHA256Transform(uint32_t state[8], const uint8_t [SHA256_BLOCK_LENGTH]);
0072 void SHA256Update(SHA2_CTX *, const uint8_t *, size_t);
0073 void SHA256Pad(SHA2_CTX *);
0074 void SHA256Final(uint8_t [SHA256_DIGEST_LENGTH], SHA2_CTX *);
0075 char *SHA256End(SHA2_CTX *, char *);
0076 char *SHA256File(const char *, char *);
0077 char *SHA256FileChunk(const char *, char *, off_t, off_t);
0078 char *SHA256Data(const uint8_t *, size_t, char *);
0079
0080 void SHA384Init(SHA2_CTX *);
0081 void SHA384Transform(uint64_t state[8], const uint8_t [SHA384_BLOCK_LENGTH]);
0082 void SHA384Update(SHA2_CTX *, const uint8_t *, size_t);
0083 void SHA384Pad(SHA2_CTX *);
0084 void SHA384Final(uint8_t [SHA384_DIGEST_LENGTH], SHA2_CTX *);
0085 char *SHA384End(SHA2_CTX *, char *);
0086 char *SHA384File(const char *, char *);
0087 char *SHA384FileChunk(const char *, char *, off_t, off_t);
0088 char *SHA384Data(const uint8_t *, size_t, char *);
0089
0090 void SHA512Init(SHA2_CTX *);
0091 void SHA512Transform(uint64_t state[8], const uint8_t [SHA512_BLOCK_LENGTH]);
0092 void SHA512Update(SHA2_CTX *, const uint8_t *, size_t);
0093 void SHA512Pad(SHA2_CTX *);
0094 void SHA512Final(uint8_t [SHA512_DIGEST_LENGTH], SHA2_CTX *);
0095 char *SHA512End(SHA2_CTX *, char *);
0096 char *SHA512File(const char *, char *);
0097 char *SHA512FileChunk(const char *, char *, off_t, off_t);
0098 char *SHA512Data(const uint8_t *, size_t, char *);
0099
0100 #ifdef __cplusplus
0101 }
0102 #endif
0103
0104 #endif