Source

Magnum / source / libs / magnum_crypto / source / magnum / crypto / MD4Digester.cpp

/* 
  Magnum 
  Copyright (C) 2002-2011 Kaya Kupferschmidt. All Rights Reserved.

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, under the terms in LICENSE.TXT.

  Kaya Kupferschmidt  (k.kupferschmidt@dimajix.de)
*/

#include "magnum/openssl/OpenSSL.h"
#include "magnum/crypto/MD4Digester.h"


namespace magnum { namespace crypto {
using magnum::openssl::OpenSSL;


/*--------------------------------------------------------------------------*/
/**
 */
MD4Digester::MD4Digester()
: AbstractDigester("MD4")
{
    OpenSSL::startup();
    MD4_Init(&m_Context);
}


/*--------------------------------------------------------------------------*/
/**
 */
MD4Digester::~MD4Digester()
{
}


/*--------------------------------------------------------------------------*/
/**
 */
void MD4Digester::resetImpl()
{
    MD4_Init(&m_Context);
}


/*--------------------------------------------------------------------------*/
/**
 */
void MD4Digester::updateImpl(const void* data, size_t len)
{
    MD4_Update(&m_Context, data, len);
}


/*--------------------------------------------------------------------------*/
/**
 */
ByteArray MD4Digester::digestImpl()
{
    unsigned char buffer[MD4_DIGEST_LENGTH];
    MD4_Final(buffer, &m_Context);
    return ByteArray((char*)buffer, MD4_DIGEST_LENGTH);
}

} }