crypto_hash_sha512.h (1673B)
1 /* Added for Tor. */ 2 #include "lib/crypt_ops/crypto_digest.h" 3 4 /* Set 'out' to the 512-bit SHA512 hash of the 'len'-byte string in 'inp' */ 5 #define crypto_hash_sha512(out, inp, len) \ 6 crypto_digest512((char *)(out), (const char *)(inp), (len), DIGEST_SHA512) 7 8 /* Set 'out' to the 512-bit SHA512 hash of the 'len1'-byte string in 'inp1', 9 * concatenated with the 'len2'-byte string in 'inp2'. */ 10 #define crypto_hash_sha512_2(out, inp1, len1, inp2, len2) \ 11 do { \ 12 crypto_digest_t *sha_ctx_; \ 13 sha_ctx_ = crypto_digest512_new(DIGEST_SHA512); \ 14 crypto_digest_add_bytes(sha_ctx_, (const char *)(inp1), (len1)); \ 15 crypto_digest_add_bytes(sha_ctx_, (const char *)(inp2), (len2)); \ 16 crypto_digest_get_digest(sha_ctx_, (char *)out, DIGEST512_LEN); \ 17 crypto_digest_free(sha_ctx_); \ 18 } while (0) 19 20 /* Set 'out' to the 512-bit SHA512 hash of the 'len1'-byte string in 'inp1', 21 * concatenated with the 'len2'-byte string in 'inp2', concatenated with 22 * the 'len3'-byte string in 'len3'. */ 23 #define crypto_hash_sha512_3(out, inp1, len1, inp2, len2, inp3, len3) \ 24 do { \ 25 crypto_digest_t *sha_ctx_; \ 26 sha_ctx_ = crypto_digest512_new(DIGEST_SHA512); \ 27 crypto_digest_add_bytes(sha_ctx_, (const char *)(inp1), (len1)); \ 28 crypto_digest_add_bytes(sha_ctx_, (const char *)(inp2), (len2)); \ 29 crypto_digest_add_bytes(sha_ctx_, (const char *)(inp3), (len3)); \ 30 crypto_digest_get_digest(sha_ctx_, (char *)out, DIGEST512_LEN); \ 31 crypto_digest_free(sha_ctx_); \ 32 } while(0)