Thu Apr 28 2011 17:13:35

Asterisk developer's documentation


sha1.h

Go to the documentation of this file.
00001 /*
00002  *  sha1.h
00003  *
00004  *  Description:
00005  *      This is the header file for code which implements the Secure
00006  *      Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
00007  *      April 17, 1995.
00008  *
00009  *      Many of the variable names in this code, especially the
00010  *      single character names, were used because those were the names
00011  *      used in the publication.
00012  *
00013  *      Please read the file sha1.c for more information.
00014  *
00015  */
00016 
00017 
00018 #ifndef _SHA1_H_
00019 #define _SHA1_H_
00020 
00021 /*
00022  * We assume that the standard asterisk headers have been included before this one.
00023  * If you do not have the ISO standard stdint.h header file, then you
00024  * must typdef the following:
00025  *    name              meaning
00026  *  uint32_t         unsigned 32 bit integer
00027  *  uint8_t          unsigned 8 bit integer (i.e., unsigned char)
00028  *
00029  */
00030 
00031 #ifndef _SHA_enum_
00032 #define _SHA_enum_
00033 enum
00034 {
00035     shaSuccess = 0,
00036     shaNull,            /* Null pointer parameter */
00037     shaInputTooLong,    /* input data too long */
00038     shaStateError       /* called Input after Result */
00039 };
00040 #endif
00041 #define SHA1HashSize 20
00042 
00043 /*!
00044  * \brief This structure will hold context information for the SHA-1 hashing operation
00045 */
00046 typedef struct SHA1Context
00047 {
00048     uint32_t Intermediate_Hash[SHA1HashSize/4]; /*! Message Digest  */
00049 
00050     uint32_t Length_Low;            /*!< Message length in bits      */
00051     uint32_t Length_High;           /*!< Message length in bits      */
00052 
00053                                /* Index into message block array   */
00054     uint32_t Message_Block_Index;   /*!< 8 bits actually suffice */
00055     uint8_t Message_Block[64];      /*!< 512-bit message blocks      */
00056 
00057     int Computed;               /*!< Is the digest computed?         */
00058     int Corrupted;             /*!< Is the message digest corrupted? */
00059 } SHA1Context;
00060 
00061 /*
00062  *  Function Prototypes
00063  */
00064 
00065 
00066 int SHA1Reset(  SHA1Context *);
00067 int SHA1Input(  SHA1Context *,
00068                 const uint8_t *,
00069                 unsigned int);
00070 int SHA1Result( SHA1Context *,
00071                 uint8_t Message_Digest[SHA1HashSize]);
00072 
00073 #endif