TeaSpeakLibrary/src/misc/digest.cpp

18 lines
923 B
C++
Raw Normal View History

#include "./digest.h"
#ifdef NO_OPEN_SSL
2019-07-07 19:13:11 +02:00
#include <tomcrypt.h>
2019-09-22 15:57:01 +01:00
#define DECLARE_DIGEST(name, digestLength) \
void digest::tomcrypt::name(const char* input, size_t length, uint8_t* result) { \
2019-07-07 18:05:22 +02:00
hash_state hash{}; \
\
name ##_init(&hash); \
2019-09-22 15:57:01 +01:00
name ##_process(&hash, (uint8_t*) input, (unsigned long) length); \
2019-07-07 18:05:22 +02:00
name ##_done(&hash, result); \
}
2019-07-08 11:00:58 +02:00
DECLARE_DIGEST(sha1, SHA_DIGEST_LENGTH)
DECLARE_DIGEST(sha256, SHA256_DIGEST_LENGTH)
DECLARE_DIGEST(sha512, SHA512_DIGEST_LENGTH)
2019-07-07 18:02:46 +02:00
#endif