// Md4Reg.cpp /TR 2018-11-02

#include "StdAfx.h"

#include "../../C/CpuArch.h"

EXTERN_C_BEGIN
#include "../../C/hashes/md4.h"
EXTERN_C_END

#include "../Common/MyCom.h"
#include "../7zip/Common/RegisterCodec.h"

// MD4
Z7_CLASS_IMP_COM_1(
  CMD4Hasher
  , IHasher
)
  MD4_CTX _ctx;

public:
  CMD4Hasher() { MD4_Init(&_ctx); }
};

Z7_COM7F_IMF2(void, CMD4Hasher::Init())
{
  MD4_Init(&_ctx);
}

Z7_COM7F_IMF2(void, CMD4Hasher::Update(const void *data, UInt32 size))
{
  MD4_Update(&_ctx, (const Byte *)data, size);
}

Z7_COM7F_IMF2(void, CMD4Hasher::Final(Byte *digest))
{
  MD4_Final(digest, &_ctx);
}
REGISTER_HASHER(CMD4Hasher, 0x206, "MD4", MD4_DIGEST_LENGTH)
