/* MD5.H - header file for MD5C.C
 */

/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.

License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.

License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.

RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.



These notices must be retained in any copies of any part of this
documentation and/or software.
 */

// (NRM - 06.08.2003) Asuraified / cpp-ised / Hungarianed version of the non-open source MD5 from AvP Gold

// B E G I N   F I L E   W R A P P E R ///////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef ___ASURA_CHECKSUM_H___
#define ___ASURA_CHECKSUM_H___ 1

class Asura_Checksum
{
    public:
        enum {CHECKSUM_LENGTH = 16};

		Asura_Checksum() { Initialise(); }

        void Initialise(void);
        void Update(const u_char* pucBuffer, u_int uDataLength);
        void Finalise(u_char aucOutput[CHECKSUM_LENGTH]);
        
        static void EncodeFromBuffer(const u_char* pucBuffer, u_int uDataLength, u_char aucOutput[CHECKSUM_LENGTH]);

        static bool Compare( const u_char aucChecksum1[CHECKSUM_LENGTH], const u_char aucChecksum2[CHECKSUM_LENGTH] );

        struct Context
        {
            u_int  uState[4];                           /* state (ABCD) */
            u_int  uCount[2];                           /* number of bits, modulo 2^64 (lsb first) */
            u_char ucBuffer[64];                        /* input buffer */
        };

    private:
        
		Context m_xContext;

        void Transform(u_int auState[4], const u_char* ucBlock);
        void Encode(u_char* pucOutput, const u_int* puInput,   u_int uLength);
        void Decode(u_int* puOutput,   const u_char* pucInput, u_int uLength);
};

// E N D   F I L E   W R A P P E R ///////////////////////////////////////////

#endif // #ifndef ___ASURA_CHECKSUM_H___

