2019-11-04 02:22:03 +00:00
|
|
|
#ifndef MD5_NATIVE_HH
|
|
|
|
#define MD5_NATIVE_HH
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2008-05-05 14:29:12 +00:00
|
|
|
#include <qpdf/qpdf-config.h>
|
2019-11-04 02:22:03 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <cstring>
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2019-11-04 02:22:03 +00:00
|
|
|
class MD5_native
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef unsigned char Digest[16];
|
|
|
|
|
2019-11-04 02:22:03 +00:00
|
|
|
MD5_native();
|
2008-04-29 12:55:25 +00:00
|
|
|
void init();
|
2019-06-21 03:35:23 +00:00
|
|
|
void update(unsigned char*, size_t);
|
2019-11-04 02:22:03 +00:00
|
|
|
void finalize();
|
|
|
|
void digest(Digest);
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2019-11-04 02:22:03 +00:00
|
|
|
private:
|
|
|
|
static void transform(uint32_t[4], unsigned char[64]);
|
|
|
|
static void encode(unsigned char*, uint32_t*, size_t);
|
|
|
|
static void decode(uint32_t*, unsigned char*, size_t);
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2022-02-08 14:18:08 +00:00
|
|
|
uint32_t state[4]; // state (ABCD)
|
|
|
|
uint32_t count[2]; // number of bits, modulo 2^64 (lsb first)
|
|
|
|
unsigned char buffer[64]; // input buffer
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
bool finalized;
|
|
|
|
Digest digest_val;
|
|
|
|
};
|
|
|
|
|
2019-11-04 02:22:03 +00:00
|
|
|
#endif // MD5_NATIVE_HH
|