18 lines
944 B
C++
18 lines
944 B
C++
#include "./digest.h"
|
|
#ifdef NO_OPEN_SSL
|
|
#include <tomcrypt.h>
|
|
|
|
#define DECLARE_DIGEST(name, _unused_, digestLength) \
|
|
void digest::tomcrypt::name(const char* input, size_t length, uint8_t(& result)[digestLength]) { \
|
|
hash_state hash{}; \
|
|
\
|
|
name ##_init(&hash); \
|
|
name ##_process(&hash, (uint8_t*) input, length); \
|
|
name ##_done(&hash, result); \
|
|
}
|
|
|
|
DECLARE_DIGEST(sha1, SHA1, SHA_DIGEST_LENGTH)
|
|
DECLARE_DIGEST(sha256, SHA256, SHA256_DIGEST_LENGTH)
|
|
DECLARE_DIGEST(sha512, SHA512, SHA512_DIGEST_LENGTH)
|
|
#endif
|