File indexing completed on 2025-01-18 10:02:16
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 #ifndef NETTLE_SHA2_H_INCLUDED
0035 #define NETTLE_SHA2_H_INCLUDED
0036
0037 #include "nettle-types.h"
0038
0039 #ifdef __cplusplus
0040 extern "C" {
0041 #endif
0042
0043
0044 #define sha224_init nettle_sha224_init
0045 #define sha224_digest nettle_sha224_digest
0046 #define sha256_init nettle_sha256_init
0047 #define sha256_update nettle_sha256_update
0048 #define sha256_digest nettle_sha256_digest
0049 #define sha256_compress nettle_sha256_compress
0050 #define sha384_init nettle_sha384_init
0051 #define sha384_digest nettle_sha384_digest
0052 #define sha512_init nettle_sha512_init
0053 #define sha512_update nettle_sha512_update
0054 #define sha512_digest nettle_sha512_digest
0055 #define sha512_compress nettle_sha512_compress
0056 #define sha512_224_init nettle_sha512_224_init
0057 #define sha512_224_digest nettle_sha512_224_digest
0058 #define sha512_256_init nettle_sha512_256_init
0059 #define sha512_256_digest nettle_sha512_256_digest
0060
0061
0062 #define SHA224_DATA_SIZE SHA256_BLOCK_SIZE
0063 #define SHA256_DATA_SIZE SHA256_BLOCK_SIZE
0064 #define SHA512_DATA_SIZE SHA512_BLOCK_SIZE
0065 #define SHA384_DATA_SIZE SHA512_BLOCK_SIZE
0066
0067
0068
0069 #define SHA256_DIGEST_SIZE 32
0070 #define SHA256_BLOCK_SIZE 64
0071
0072
0073 #define _SHA256_DIGEST_LENGTH 8
0074
0075 struct sha256_ctx
0076 {
0077 uint32_t state[_SHA256_DIGEST_LENGTH];
0078 uint64_t count;
0079 unsigned int index;
0080 uint8_t block[SHA256_BLOCK_SIZE];
0081 };
0082
0083 void
0084 sha256_init(struct sha256_ctx *ctx);
0085
0086 void
0087 sha256_update(struct sha256_ctx *ctx,
0088 size_t length,
0089 const uint8_t *data);
0090
0091 void
0092 sha256_digest(struct sha256_ctx *ctx,
0093 size_t length,
0094 uint8_t *digest);
0095
0096 void
0097 sha256_compress(uint32_t *state, const uint8_t *input);
0098
0099
0100
0101 #define SHA224_DIGEST_SIZE 28
0102 #define SHA224_BLOCK_SIZE SHA256_BLOCK_SIZE
0103 #define sha224_ctx sha256_ctx
0104
0105 void
0106 sha224_init(struct sha256_ctx *ctx);
0107
0108 #define sha224_update nettle_sha256_update
0109
0110 void
0111 sha224_digest(struct sha256_ctx *ctx,
0112 size_t length,
0113 uint8_t *digest);
0114
0115
0116
0117
0118 #define SHA512_DIGEST_SIZE 64
0119 #define SHA512_BLOCK_SIZE 128
0120
0121
0122 #define _SHA512_DIGEST_LENGTH 8
0123
0124 struct sha512_ctx
0125 {
0126 uint64_t state[_SHA512_DIGEST_LENGTH];
0127 uint64_t count_low, count_high;
0128 unsigned int index;
0129 uint8_t block[SHA512_BLOCK_SIZE];
0130 };
0131
0132 void
0133 sha512_init(struct sha512_ctx *ctx);
0134
0135 void
0136 sha512_update(struct sha512_ctx *ctx,
0137 size_t length,
0138 const uint8_t *data);
0139
0140 void
0141 sha512_digest(struct sha512_ctx *ctx,
0142 size_t length,
0143 uint8_t *digest);
0144
0145 void
0146 sha512_compress(uint64_t *state, const uint8_t *input);
0147
0148
0149
0150 #define SHA384_DIGEST_SIZE 48
0151 #define SHA384_BLOCK_SIZE SHA512_BLOCK_SIZE
0152 #define sha384_ctx sha512_ctx
0153
0154 void
0155 sha384_init(struct sha512_ctx *ctx);
0156
0157 #define sha384_update nettle_sha512_update
0158
0159 void
0160 sha384_digest(struct sha512_ctx *ctx,
0161 size_t length,
0162 uint8_t *digest);
0163
0164
0165
0166
0167
0168 #define SHA512_224_DIGEST_SIZE 28
0169 #define SHA512_224_BLOCK_SIZE SHA512_BLOCK_SIZE
0170 #define sha512_224_ctx sha512_ctx
0171
0172 void
0173 sha512_224_init(struct sha512_224_ctx *ctx);
0174
0175 #define sha512_224_update nettle_sha512_update
0176
0177 void
0178 sha512_224_digest(struct sha512_224_ctx *ctx,
0179 size_t length,
0180 uint8_t *digest);
0181
0182 #define SHA512_256_DIGEST_SIZE 32
0183 #define SHA512_256_BLOCK_SIZE SHA512_BLOCK_SIZE
0184 #define sha512_256_ctx sha512_ctx
0185
0186 void
0187 sha512_256_init(struct sha512_256_ctx *ctx);
0188
0189 #define sha512_256_update nettle_sha512_update
0190
0191 void
0192 sha512_256_digest(struct sha512_256_ctx *ctx,
0193 size_t length,
0194 uint8_t *digest);
0195
0196 #ifdef __cplusplus
0197 }
0198 #endif
0199
0200 #endif