2020-04-17 18:46:45 -04:00
|
|
|
#ifndef NO_OPEN_SSL
|
2020-02-28 05:24:02 -05:00
|
|
|
#define NO_OPEN_SSL
|
2020-04-17 18:46:45 -04:00
|
|
|
#endif
|
|
|
|
|
2019-07-01 20:13:42 -04:00
|
|
|
#include "./digest.h"
|
2020-02-28 05:24:02 -05:00
|
|
|
#include <tomcrypt.h>
|
2019-07-01 20:13:42 -04:00
|
|
|
|
2020-02-28 05:24:02 -05:00
|
|
|
#define DECLARE_DIGEST(name, digestLength) \
|
|
|
|
void digest::tomcrypt::name(const char* input, size_t length, uint8_t* result) { \
|
|
|
|
hash_state hash{}; \
|
|
|
|
\
|
|
|
|
name ##_init(&hash); \
|
|
|
|
name ##_process(&hash, (uint8_t*) input, (unsigned long) length); \
|
|
|
|
name ##_done(&hash, result); \
|
|
|
|
}
|
2019-07-01 20:13:42 -04:00
|
|
|
|
2020-02-28 05:24:02 -05:00
|
|
|
DECLARE_DIGEST(sha1, SHA_DIGEST_LENGTH)
|
|
|
|
DECLARE_DIGEST(sha256, SHA256_DIGEST_LENGTH)
|
|
|
|
DECLARE_DIGEST(sha512, SHA512_DIGEST_LENGTH)
|