2006-02-04 16:32:27 +00:00
|
|
|
/*
|
|
|
|
* sha1.h
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This is the header file for code which implements the Secure
|
|
|
|
* Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
|
|
|
|
* April 17, 1995.
|
|
|
|
*
|
|
|
|
* Many of the variable names in this code, especially the
|
|
|
|
* single character names, were used because those were the names
|
|
|
|
* used in the publication.
|
|
|
|
*
|
|
|
|
* Please read the file sha1.c for more information.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _SHA1_H_
|
|
|
|
#define _SHA1_H_
|
|
|
|
|
|
|
|
/*
|
Start untangling header inclusion in a way that does not affect
build times - tested, there is no measureable difference before and
after this commit.
In this change:
use asterisk/compat.h to include a small set of system headers:
inttypes.h, unistd.h, stddef.h, stddint.h, sys/types.h, stdarg.h,
stdlib.h, alloca.h, stdio.h
Where available, the inclusion is conditional on HAVE_FOO_H as determined
by autoconf.
Normally, source files should not include any of the above system headers,
and instead use either "asterisk.h" or "asterisk/compat.h" which does it
better.
For the time being I have left alone second-level directories
(main/db1-ast, etc.).
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89333 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-16 20:04:58 +00:00
|
|
|
* We assume that the standard asterisk headers have been included before this one.
|
2006-02-04 16:32:27 +00:00
|
|
|
* If you do not have the ISO standard stdint.h header file, then you
|
|
|
|
* must typdef the following:
|
|
|
|
* name meaning
|
|
|
|
* uint32_t unsigned 32 bit integer
|
|
|
|
* uint8_t unsigned 8 bit integer (i.e., unsigned char)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SHA_enum_
|
|
|
|
#define _SHA_enum_
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
shaSuccess = 0,
|
|
|
|
shaNull, /* Null pointer parameter */
|
|
|
|
shaInputTooLong, /* input data too long */
|
|
|
|
shaStateError /* called Input after Result */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
#define SHA1HashSize 20
|
|
|
|
|
2007-09-05 16:31:39 +00:00
|
|
|
/*!
|
|
|
|
* \brief This structure will hold context information for the SHA-1 hashing operation
|
|
|
|
*/
|
2006-02-04 16:32:27 +00:00
|
|
|
typedef struct SHA1Context
|
|
|
|
{
|
2007-09-05 16:31:39 +00:00
|
|
|
uint32_t Intermediate_Hash[SHA1HashSize/4]; /*! Message Digest */
|
2006-02-04 16:32:27 +00:00
|
|
|
|
2007-09-05 16:31:39 +00:00
|
|
|
uint32_t Length_Low; /*!< Message length in bits */
|
|
|
|
uint32_t Length_High; /*!< Message length in bits */
|
2006-02-04 16:32:27 +00:00
|
|
|
|
|
|
|
/* Index into message block array */
|
2007-09-05 16:31:39 +00:00
|
|
|
uint32_t Message_Block_Index; /*!< 8 bits actually suffice */
|
|
|
|
uint8_t Message_Block[64]; /*!< 512-bit message blocks */
|
2006-02-04 16:32:27 +00:00
|
|
|
|
2007-09-05 16:31:39 +00:00
|
|
|
int Computed; /*!< Is the digest computed? */
|
|
|
|
int Corrupted; /*!< Is the message digest corrupted? */
|
2006-02-04 16:32:27 +00:00
|
|
|
} SHA1Context;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function Prototypes
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
int SHA1Reset( SHA1Context *);
|
|
|
|
int SHA1Input( SHA1Context *,
|
|
|
|
const uint8_t *,
|
|
|
|
unsigned int);
|
|
|
|
int SHA1Result( SHA1Context *,
|
|
|
|
uint8_t Message_Digest[SHA1HashSize]);
|
|
|
|
|
|
|
|
#endif
|