md4transform.h

Go to the documentation of this file.
00001 /**
00002  * Copyright (C) 1990-1992, RSA Data Security, Inc. All rights reserved.
00003  *
00004  * License to copy and use this software is granted provided that it
00005  * is identified as the "RSA Data Security, Inc. MD4 Message-Digest
00006  * Algorithm" in all material mentioning or referencing this software
00007  * or this function.
00008  *
00009  * License is also granted to make and use derivative works provided
00010  * that such works are identified as "derived from the RSA Data
00011  * Security, Inc. MD4 Message-Digest Algorithm" in all material
00012  * mentioning or referencing the derived work.
00013  *
00014  * RSA Data Security, Inc. makes no representations concerning either
00015  * the merchantability of this software or the suitability of this
00016  * software for any particular purpose. It is provided "as is"
00017  * without express or implied warranty of any kind.
00018  *
00019  * These notices must be retained in any copies of any part of this
00020  * documentation and/or software.
00021  */
00022 
00023 /** @file Md4Transform.h Interface for Md4Transform class. */
00024 
00025 #ifndef __MD4TRANSFORM_H__
00026 #define __MD4TRANSFORM_H__
00027 
00028 #include <hn/hash.h>
00029 #include <hn/osdep.h>
00030 
00031 /**
00032  * Md4Transform class handles data md4 checksumming functionality.
00033  *
00034  * The entire implementation is hidden within this class's implementation
00035  * file's static functions, and only this interface is provided to users. To
00036  * use this class, instantiate Md4Transform object (either on stack or heap),
00037  * and pass data to overloaded SumUp functions. You can call SumUp function as
00038  * many times as you want, the data will be accomulated. When you are done
00039  * passing data, call GetHash() function ONCE to retrieve the hash. After
00040  * GetHash() has been called once, the instance of the class will become
00041  * useless and cannot be reused for new data. Never use same Md4Transform
00042  * instance to generate multiple checksums.
00043  */
00044 class DLLEXPORT Md4Transform {
00045 private:
00046         uint32_t state[4];
00047         uint32_t count[2];
00048         unsigned char buffer[64];
00049         bool wasFlushed;
00050 public:
00051         /**
00052          * Default constructor
00053          */
00054         Md4Transform();
00055 
00056         /**
00057          * Default destructor
00058          */
00059         ~Md4Transform();
00060 
00061         /**
00062          * Adds data to this Md4Transform instance.
00063          *
00064          * @param data       Pointer pointing to array containing the data.
00065          * @param size       Size of the data array.
00066          */
00067         void sumUp(const uint8_t *data, uint32_t size);
00068 
00069         /**
00070          * Adds data to this Md4Transform instance.
00071          *
00072          * @param data       Pointer to data.
00073          * @param size       Size of data.
00074          */
00075         void sumUp(const char *data, uint32_t size);
00076 
00077         /**
00078          * Finalizes Md4 checksumming operation and returns the checksum of
00079          * the data. Call this function only ONCE per each instance of this
00080          * class.
00081          *
00082          * @return     Md4 checksum of the input data
00083          */
00084         Hash<MD4Hash> getHash();
00085 };
00086 
00087 #endif /* #ifndef __MD4TRANSFORM_H__ */