DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/mt32/sha1/sha1.h
00001 /*
00002  *  sha1.h
00003  *
00004  *  Copyright (C) 1998, 2009
00005  *  Paul E. Jones <paulej@packetizer.com>
00006  *  All Rights Reserved.
00007  *
00008  *****************************************************************************
00009  *  $Id: sha1.h 12 2009-06-22 19:34:25Z paulej $
00010  *****************************************************************************
00011  *
00012  *  Description:
00013  *      This class implements the Secure Hashing Standard as defined
00014  *      in FIPS PUB 180-1 published April 17, 1995.
00015  *
00016  *      Many of the variable names in this class, especially the single
00017  *      character names, were used because those were the names used
00018  *      in the publication.
00019  *
00020  *      Please read the file sha1.cpp for more information.
00021  *
00022  */
00023 
00024 #ifndef _SHA1_H_
00025 #define _SHA1_H_
00026 
00027 class SHA1
00028 {
00029 
00030     public:
00031 
00032         SHA1();
00033         virtual ~SHA1();
00034 
00035         /*
00036          *  Re-initialize the class
00037          */
00038         void Reset();
00039 
00040         /*
00041          *  Returns the message digest
00042          */
00043         bool Result(unsigned *message_digest_array);
00044 
00045         /*
00046          *  Provide input to SHA1
00047          */
00048         void Input( const unsigned char *message_array,
00049                     unsigned            length);
00050         void Input( const char  *message_array,
00051                     unsigned    length);
00052         void Input(unsigned char message_element);
00053         void Input(char message_element);
00054         SHA1& operator<<(const char *message_array);
00055         SHA1& operator<<(const unsigned char *message_array);
00056         SHA1& operator<<(const char message_element);
00057         SHA1& operator<<(const unsigned char message_element);
00058 
00059     private:
00060 
00061         /*
00062          *  Process the next 512 bits of the message
00063          */
00064         void ProcessMessageBlock();
00065 
00066         /*
00067          *  Pads the current message block to 512 bits
00068          */
00069         void PadMessage();
00070 
00071         /*
00072          *  Performs a circular left shift operation
00073          */
00074         inline unsigned CircularShift(int bits, unsigned word);
00075 
00076         unsigned H[5];                      // Message digest buffers
00077 
00078         unsigned Length_Low;                // Message length in bits
00079         unsigned Length_High;               // Message length in bits
00080 
00081         unsigned char Message_Block[64] = {};    // 512-bit message blocks
00082         int Message_Block_Index;            // Index into message block array
00083 
00084         bool Computed;                      // Is the digest computed?
00085         bool Corrupted;                     // Is the message digest corruped?
00086     
00087 };
00088 
00089 #endif