diff options
Diffstat (limited to 'common/sha512.c')
-rw-r--r-- | common/sha512.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/common/sha512.c b/common/sha512.c index a09a5aa..2462424 100644 --- a/common/sha512.c +++ b/common/sha512.c @@ -65,6 +65,10 @@ static const char rcsid[] = "$Id: sha512.c 680 2003-07-25 21:58:07Z asaddi $"; #endif /* !lint */ + +/** + * @{ + */ #define ROTL(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) #define ROTR(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) #define ROTL64(x, n) (((x) << (n)) | ((x) >> (64 - (n)))) @@ -164,6 +168,11 @@ static inline uint64_t _byteswap64(uint64_t x) (ROTL((x), 8) & 0x00ff00ffL)) #define _BYTESWAP64(x) __byteswap64(x) +/** + * @} + */ + + static inline uint64_t __byteswap64(uint64_t x) { uint32_t a = x >> 32; @@ -219,6 +228,11 @@ static const uint8_t padding[128] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +/** + * Initiates a new SHA512 context with needed values + * + * @param sc SHA512Context + */ void SHA512Init (SHA512Context *sc) { @@ -303,6 +317,14 @@ SHA512Guts (SHA512Context *sc, const uint64_t *cbuf) sc->hash[7] += h; } + +/** + * Feeds the SHA512 with data for calculating the hash + * + * @param sc SHA512Context + * @param vdata Pointer to the data + * @param len Length of the data + */ void SHA512Update (SHA512Context *sc, const void *vdata, uint32_t len) { @@ -392,8 +414,14 @@ SHA512Update (SHA512Context *sc, const void *vdata, uint32_t len) burnStack (sizeof (uint64_t[90]) + sizeof (uint64_t *[6]) + sizeof (int)); } -void -SHA512Final (SHA512Context *sc, uint8_t hash[SHA512_HASH_SIZE]) + +/** + * Completes the calculation and returns a SHA512 hash. + * + * @param sc SHA512Context + * @param hash Array where the hash result will be put + */ +void SHA512Final (SHA512Context *sc, uint8_t hash[SHA512_HASH_SIZE]) { uint32_t bytesToPad; uint64_t lengthPad[2]; |