diff options
Diffstat (limited to 'src/microhttpd/sha256.h')
-rw-r--r-- | src/microhttpd/sha256.h | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/src/microhttpd/sha256.h b/src/microhttpd/sha256.h index 6d36ebef..5eee4a41 100644 --- a/src/microhttpd/sha256.h +++ b/src/microhttpd/sha256.h | |||
@@ -32,14 +32,10 @@ | |||
32 | the GNU Lesser General Public License along with this program. If | 32 | the GNU Lesser General Public License along with this program. If |
33 | not, see http://www.gnu.org/licenses/. | 33 | not, see http://www.gnu.org/licenses/. |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #ifndef NETTLE_SHA2_H_INCLUDED | 36 | #ifndef NETTLE_SHA2_H_INCLUDED |
37 | #define NETTLE_SHA2_H_INCLUDED | 37 | #define NETTLE_SHA2_H_INCLUDED |
38 | 38 | ||
39 | #ifdef __cplusplus | ||
40 | extern "C" { | ||
41 | #endif | ||
42 | |||
43 | #define SHA256_DIGEST_SIZE 32 | 39 | #define SHA256_DIGEST_SIZE 32 |
44 | #define SHA256_BLOCK_SIZE 64 | 40 | #define SHA256_BLOCK_SIZE 64 |
45 | 41 | ||
@@ -54,21 +50,36 @@ struct sha256_ctx | |||
54 | unsigned int index; /* index into buffer */ | 50 | unsigned int index; /* index into buffer */ |
55 | }; | 51 | }; |
56 | 52 | ||
57 | void | ||
58 | sha256_init(struct sha256_ctx *ctx); | ||
59 | 53 | ||
54 | /** | ||
55 | * Start SHA256 calculation. | ||
56 | * | ||
57 | * @param ctx_ must be a `struct sha256_ctx *` | ||
58 | */ | ||
60 | void | 59 | void |
61 | sha256_update(struct sha256_ctx *ctx, | 60 | sha256_init (void *ctx_); |
62 | size_t length, | ||
63 | const uint8_t *data); | ||
64 | 61 | ||
65 | void | ||
66 | sha256_digest(struct sha256_ctx *ctx, | ||
67 | size_t length, | ||
68 | uint8_t *digest); | ||
69 | 62 | ||
70 | #ifdef __cplusplus | 63 | /** |
71 | } | 64 | * Update hash calculation. |
72 | #endif | 65 | * |
66 | * @param ctx_ must be a `struct sha256_ctx *` | ||
67 | * @param length number of bytes in @a data | ||
68 | * @param data bytes to add to hash | ||
69 | */ | ||
70 | void | ||
71 | sha256_update (void *ctx_, | ||
72 | const uint8_t *data, | ||
73 | size_t length); | ||
74 | |||
75 | /** | ||
76 | * Complete SHA256 calculation. | ||
77 | * | ||
78 | * @param ctx_ must be a `struct sha256_ctx *` | ||
79 | * @param digest[out] set to the hash, must be #SHA256_DIGEST_SIZE bytes | ||
80 | */ | ||
81 | void | ||
82 | sha256_digest (void *ctx_, | ||
83 | uint8_t digest[SHA256_DIGEST_SIZE]); | ||
73 | 84 | ||
74 | #endif /* NETTLE_SHA2_H_INCLUDED */ | 85 | #endif /* NETTLE_SHA2_H_INCLUDED */ |