GainSpan Wi-Fi library see: http://mbed.org/users/gsfan/notebook/gainspan_wifi/

Fork of GSwifi_old by gs fan

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sha1.h Source File

sha1.h

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