X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/0f00dc4c8eb47e67bc0f148c2dd109f73a451e0a..1519ef6617fd7351bd40026b9eeb47c7f7f42234:/symm/sha512.h diff --git a/symm/sha512.h b/symm/sha512.h index 2f3edc29..1a0de279 100644 --- a/symm/sha512.h +++ b/symm/sha512.h @@ -61,6 +61,14 @@ #define SHA384_HASHSZ 48 #define SHA384_STATESZ 64 +#define SHA512_256_BUFSZ 128 +#define SHA512_256_HASHSZ 32 +#define SHA512_256_STATESZ 64 + +#define SHA512_224_BUFSZ 128 +#define SHA512_224_HASHSZ 28 +#define SHA512_224_STATESZ 64 + /*----- Data structures ---------------------------------------------------*/ typedef struct sha512_ctx { @@ -68,11 +76,11 @@ typedef struct sha512_ctx { uint32 nh, nl; /* Byte count so far */ unsigned off; /* Offset into buffer */ octet buf[SHA512_BUFSZ]; /* Accumulation buffer */ -} sha512_ctx, sha384_ctx; +} sha512_ctx, sha384_ctx, sha512_256_ctx, sha512_224_ctx; /*----- Functions provided ------------------------------------------------*/ -/* --- @sha512_compress@, @sha384_compress@ --- * +/* --- @sha512_compress@, etc. --- * * * Arguments: @sha512_ctx *ctx@ = pointer to context block * @const void *sbuf@ = pointer to buffer of appropriate size @@ -84,8 +92,10 @@ typedef struct sha512_ctx { extern void sha512_compress(sha512_ctx */*ctx*/, const void */*sbuf*/); #define sha384_compress sha512_compress +#define sha512_256_compress sha512_compress +#define sha512_224_compress sha512_compress -/* --- @sha512_init@, @sha384_init@ --- * +/* --- @sha512_init@, etc. --- * * * Arguments: @sha512_ctx *ctx@ = pointer to context block to initialize * @@ -96,8 +106,10 @@ extern void sha512_compress(sha512_ctx */*ctx*/, const void */*sbuf*/); extern void sha512_init(sha512_ctx */*ctx*/); extern void sha384_init(sha512_ctx */*ctx*/); +extern void sha512_256_init(sha512_ctx */*ctx*/); +extern void sha512_224_init(sha512_ctx */*ctx*/); -/* --- @sha512_set@, @sha384_set@ --- * +/* --- @sha512_set@, etc. --- * * * Arguments: @sha512_ctx *ctx@ = pointer to context block * @const void *buf@ = pointer to state buffer @@ -113,8 +125,10 @@ extern void sha384_init(sha512_ctx */*ctx*/); extern void sha512_set(sha512_ctx */*ctx*/, const void */*buf*/, unsigned long /*count*/); #define sha384_set sha512_set +#define sha512_256_set sha512_set +#define sha512_224_set sha512_set -/* --- @sha512_hash@, @sha384_hash@ --- * +/* --- @sha512_hash@, etc. --- * * * Arguments: @sha512_ctx *ctx@ = pointer to context block * @const void *buf@ = buffer of data to hash @@ -129,8 +143,10 @@ extern void sha512_set(sha512_ctx */*ctx*/, const void */*buf*/, extern void sha512_hash(sha512_ctx */*ctx*/, const void */*buf*/, size_t /*sz*/); #define sha384_hash sha512_hash +#define sha512_256_hash sha512_hash +#define sha512_224_hash sha512_hash -/* --- @sha512_done@, @sha384_done@ --- * +/* --- @sha512_done@, etc. --- * * * Arguments: @sha512_ctx *ctx@ = pointer to context block * @void *hash@ = pointer to output buffer @@ -142,6 +158,8 @@ extern void sha512_hash(sha512_ctx */*ctx*/, extern void sha512_done(sha512_ctx */*ctx*/, void */*hash*/); extern void sha384_done(sha512_ctx */*ctx*/, void */*hash*/); +extern void sha512_256_done(sha512_ctx */*ctx*/, void */*hash*/); +extern void sha512_224_done(sha512_ctx */*ctx*/, void */*hash*/); /* --- @sha512_state@, @sha384_state@ --- * * @@ -156,11 +174,15 @@ extern void sha384_done(sha512_ctx */*ctx*/, void */*hash*/); extern unsigned long sha512_state(sha512_ctx */*ctx*/, void */*state*/); #define sha384_state sha512_state +#define sha512_256_state sha512_state +#define sha512_224_state sha512_state /*----- Generic hash interface --------------------------------------------*/ extern const gchash sha512; extern const gchash sha384; +extern const gchash sha512_256; +extern const gchash sha512_224; /*----- That's all, folks -------------------------------------------------*/