Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:47:56 2009

## 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
    00023 #if defined(__OpenBSD__) || defined( __FreeBSD__)
    00024 #include <inttypes.h>
    00025 #else
    00026 #include <stdint.h>
    00027 #endif
    00028
    00029 /*
    00030  * If you do not have the ISO standard stdint.h header file, then you
    00031  * must typdef the following:
    00032  *    name              meaning
    00033  *  uint32_t         unsigned 32 bit integer
    00034  *  uint8_t          unsigned 8 bit integer (i.e., unsigned char)
    00035  *
    00036  */
    00037
    00038 #ifndef _SHA_enum_
    00039 #define _SHA_enum_
    00040 enum
    00041 {
    00042     shaSuccess = 0,
    00043     shaNull,            /* Null pointer parameter */
    00044     shaInputTooLong,    /* input data too long */
    00045     shaStateError       /* called Input after Result */
    00046 };
    00047 #endif
    00048 #define SHA1HashSize 20
    00049
    00050 /*
    00051  *  This structure will hold context information for the SHA-1
    00052  *  hashing operation
    00053  */
    00054 typedef struct SHA1Context
    00055 {
    00056     uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest  */
    00057
    00058     uint32_t Length_Low;            /* Message length in bits      */
    00059     uint32_t Length_High;           /* Message length in bits      */
    00060
    00061                                /* Index into message block array   */
    00062     uint32_t Message_Block_Index;   /* 8 bits actually suffice */
    00063     uint8_t Message_Block[64];      /* 512-bit message blocks      */
    00064
    00065     int Computed;               /* Is the digest computed?         */
    00066     int Corrupted;             /* Is the message digest corrupted? */
    00067 } SHA1Context;
    00068
    00069 /*
    00070  *  Function Prototypes
    00071  */
    00072
    00073
    00074 int SHA1Reset(  SHA1Context *);
    00075 int SHA1Input(  SHA1Context *,
    00076                 const uint8_t *,
    00077                 unsigned int);
    00078 int SHA1Result( SHA1Context *,
    00079                 uint8_t Message_Digest[SHA1HashSize]);
    00080
    00081 #endif