EHS Embedded HTTP Server  1.5.0.132
samples/sha1.h
00001 /* $Id: sha1.h 85 2012-03-22 12:17:32Z felfert $
00002  *
00003  *  sha1.h
00004  *
00005  *  Copyright (C) 1998, 2009
00006  *  Paul E. Jones <paulej@packetizer.com>
00007  *  All Rights Reserved.
00008  *
00009  *****************************************************************************
00010  *  $Id: sha1.h 85 2012-03-22 12:17:32Z felfert $
00011  *****************************************************************************
00012  *
00013  *  Description:
00014  *      This class implements the Secure Hashing Standard as defined
00015  *      in FIPS PUB 180-1 published April 17, 1995.
00016  *
00017  *      Many of the variable names in this class, especially the single
00018  *      character names, were used because those were the names used
00019  *      in the publication.
00020  *
00021  *      Please read the file sha1.cpp for more information.
00022  *
00023  */
00024 
00025 #ifndef _SHA1_H_
00026 #define _SHA1_H_
00027 
00054 class SHA1
00055 {
00056 
00057     public:
00058 
00059         SHA1();
00060         virtual ~SHA1();
00061 
00066         void Reset();
00067 
00074         bool Result(unsigned *message_digest_array);
00075 
00081         void Input( const unsigned char *message_array,
00082                     unsigned            length);
00088         void Input( const char  *message_array,
00089                     unsigned    length);
00094         void Input(unsigned char message_element);
00099         void Input(char message_element);
00105         SHA1& operator<<(const char *message_array);
00111         SHA1& operator<<(const unsigned char *message_array);
00117         SHA1& operator<<(const char message_element);
00123         SHA1& operator<<(const unsigned char message_element);
00124 
00125     private:
00126 
00127         /*
00128          *  Process the next 512 bits of the message
00129          */
00130         void ProcessMessageBlock();
00131 
00132         /*
00133          *  Pads the current message block to 512 bits
00134          */
00135         void PadMessage();
00136 
00137         /*
00138          *  Performs a circular left shift operation
00139          */
00140         inline unsigned CircularShift(int bits, unsigned word);
00141 
00142         unsigned H[5];                      // Message digest buffers
00143 
00144         unsigned Length_Low;                // Message length in bits
00145         unsigned Length_High;               // Message length in bits
00146 
00147         unsigned char Message_Block[64];    // 512-bit message blocks
00148         int Message_Block_Index;            // Index into message block array
00149 
00150         bool Computed;                      // Is the digest computed?
00151         bool Corrupted;                     // Is the message digest corruped?
00152     
00153 };
00154 
00155 #endif