crypto_hash_sha512.h 1.6 KB

123456789101112131415161718192021222324252627282930
  1. /* Added for Tor. */
  2. #include <openssl/sha.h>
  3. /* Set 'out' to the 512-bit SHA512 hash of the 'len'-byte string in 'inp' */
  4. #define crypto_hash_sha512(out, inp, len) \
  5. SHA512((inp), (len), (out))
  6. /* Set 'out' to the 512-bit SHA512 hash of the 'len1'-byte string in 'inp1',
  7. * concatenated with the 'len2'-byte string in 'inp2'. */
  8. #define crypto_hash_sha512_2(out, inp1, len1, inp2, len2) \
  9. do { \
  10. SHA512_CTX sha_ctx_; \
  11. SHA512_Init(&sha_ctx_); \
  12. SHA512_Update(&sha_ctx_, (inp1), (len1)); \
  13. SHA512_Update(&sha_ctx_, (inp2), (len2)); \
  14. SHA512_Final((out), &sha_ctx_); \
  15. } while(0)
  16. /* Set 'out' to the 512-bit SHA512 hash of the 'len1'-byte string in 'inp1',
  17. * concatenated with the 'len2'-byte string in 'inp2', concatenated with
  18. * the 'len3'-byte string in 'len3'. */
  19. #define crypto_hash_sha512_3(out, inp1, len1, inp2, len2, inp3, len3) \
  20. do { \
  21. SHA512_CTX sha_ctx_; \
  22. SHA512_Init(&sha_ctx_); \
  23. SHA512_Update(&sha_ctx_, (inp1), (len1)); \
  24. SHA512_Update(&sha_ctx_, (inp2), (len2)); \
  25. SHA512_Update(&sha_ctx_, (inp3), (len3)); \
  26. SHA512_Final((out), &sha_ctx_); \
  27. } while(0)