Fork of OAuth4Tw to use mbed's official EthernetInterface and HTTPClient
Fork of OAuth4Tw by
sha1.h@1:b3501683b856, 2015-04-30 (annotated)
- Committer:
- vpcola
- Date:
- Thu Apr 30 10:19:31 2015 +0000
- Revision:
- 1:b3501683b856
- Parent:
- 0:0048b264a3ad
Fork of OAuth4Tw to use normal EthernetInterface and HTTPClient library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
takahashim | 0:0048b264a3ad | 1 | /* |
takahashim | 0:0048b264a3ad | 2 | * sha1.h |
takahashim | 0:0048b264a3ad | 3 | * |
takahashim | 0:0048b264a3ad | 4 | * Description: |
takahashim | 0:0048b264a3ad | 5 | * This is the header file for code which implements the Secure |
takahashim | 0:0048b264a3ad | 6 | * Hashing Algorithm 1 as defined in FIPS PUB 180-1 published |
takahashim | 0:0048b264a3ad | 7 | * April 17, 1995. |
takahashim | 0:0048b264a3ad | 8 | * |
takahashim | 0:0048b264a3ad | 9 | * Many of the variable names in this code, especially the |
takahashim | 0:0048b264a3ad | 10 | * single character names, were used because those were the names |
takahashim | 0:0048b264a3ad | 11 | * used in the publication. |
takahashim | 0:0048b264a3ad | 12 | * |
takahashim | 0:0048b264a3ad | 13 | * Please read the file sha1.c for more information. |
takahashim | 0:0048b264a3ad | 14 | * |
takahashim | 0:0048b264a3ad | 15 | */ |
takahashim | 0:0048b264a3ad | 16 | |
takahashim | 0:0048b264a3ad | 17 | #ifndef _SHA1_H_ |
takahashim | 0:0048b264a3ad | 18 | #define _SHA1_H_ |
takahashim | 0:0048b264a3ad | 19 | |
takahashim | 0:0048b264a3ad | 20 | #ifdef __cplusplus |
takahashim | 0:0048b264a3ad | 21 | extern "C" { |
takahashim | 0:0048b264a3ad | 22 | #endif |
takahashim | 0:0048b264a3ad | 23 | |
takahashim | 0:0048b264a3ad | 24 | //#include <stdint.h> |
takahashim | 0:0048b264a3ad | 25 | typedef unsigned long uint32_t; |
takahashim | 0:0048b264a3ad | 26 | typedef int int_least16_t; |
takahashim | 0:0048b264a3ad | 27 | typedef unsigned char uint8_t; |
takahashim | 0:0048b264a3ad | 28 | |
takahashim | 0:0048b264a3ad | 29 | /* |
takahashim | 0:0048b264a3ad | 30 | * If you do not have the ISO standard stdint.h header file, then you |
takahashim | 0:0048b264a3ad | 31 | * must typdef the following: |
takahashim | 0:0048b264a3ad | 32 | * name meaning |
takahashim | 0:0048b264a3ad | 33 | * uint32_t unsigned 32 bit integer |
takahashim | 0:0048b264a3ad | 34 | * uint8_t unsigned 8 bit integer (i.e., unsigned char) |
takahashim | 0:0048b264a3ad | 35 | * int_least16_t integer of >= 16 bits |
takahashim | 0:0048b264a3ad | 36 | * |
takahashim | 0:0048b264a3ad | 37 | */ |
takahashim | 0:0048b264a3ad | 38 | |
takahashim | 0:0048b264a3ad | 39 | #ifndef _SHA_enum_ |
takahashim | 0:0048b264a3ad | 40 | #define _SHA_enum_ |
takahashim | 0:0048b264a3ad | 41 | enum |
takahashim | 0:0048b264a3ad | 42 | { |
takahashim | 0:0048b264a3ad | 43 | shaSuccess = 0, |
takahashim | 0:0048b264a3ad | 44 | shaNull, /* Null pointer parameter */ |
takahashim | 0:0048b264a3ad | 45 | shaInputTooLong, /* input data too long */ |
takahashim | 0:0048b264a3ad | 46 | shaStateError /* called Input after Result */ |
takahashim | 0:0048b264a3ad | 47 | }; |
takahashim | 0:0048b264a3ad | 48 | #endif |
takahashim | 0:0048b264a3ad | 49 | #define SHA1HashSize 20 |
takahashim | 0:0048b264a3ad | 50 | |
takahashim | 0:0048b264a3ad | 51 | /* |
takahashim | 0:0048b264a3ad | 52 | * This structure will hold context information for the SHA-1 |
takahashim | 0:0048b264a3ad | 53 | * hashing operation |
takahashim | 0:0048b264a3ad | 54 | */ |
takahashim | 0:0048b264a3ad | 55 | typedef struct SHA1Context |
takahashim | 0:0048b264a3ad | 56 | { |
takahashim | 0:0048b264a3ad | 57 | uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */ |
takahashim | 0:0048b264a3ad | 58 | |
takahashim | 0:0048b264a3ad | 59 | uint32_t Length_Low; /* Message length in bits */ |
takahashim | 0:0048b264a3ad | 60 | uint32_t Length_High; /* Message length in bits */ |
takahashim | 0:0048b264a3ad | 61 | |
takahashim | 0:0048b264a3ad | 62 | /* Index into message block array */ |
takahashim | 0:0048b264a3ad | 63 | int_least16_t Message_Block_Index; |
takahashim | 0:0048b264a3ad | 64 | uint8_t Message_Block[64]; /* 512-bit message blocks */ |
takahashim | 0:0048b264a3ad | 65 | |
takahashim | 0:0048b264a3ad | 66 | int Computed; /* Is the digest computed? */ |
takahashim | 0:0048b264a3ad | 67 | int Corrupted; /* Is the message digest corrupted? */ |
takahashim | 0:0048b264a3ad | 68 | } SHA1Context; |
takahashim | 0:0048b264a3ad | 69 | |
takahashim | 0:0048b264a3ad | 70 | /* |
takahashim | 0:0048b264a3ad | 71 | * Function Prototypes |
takahashim | 0:0048b264a3ad | 72 | */ |
takahashim | 0:0048b264a3ad | 73 | |
takahashim | 0:0048b264a3ad | 74 | int SHA1Reset( SHA1Context *); |
takahashim | 0:0048b264a3ad | 75 | int SHA1Input( SHA1Context *, |
takahashim | 0:0048b264a3ad | 76 | const uint8_t *, |
takahashim | 0:0048b264a3ad | 77 | unsigned int); |
takahashim | 0:0048b264a3ad | 78 | int SHA1Result( SHA1Context *, |
takahashim | 0:0048b264a3ad | 79 | uint8_t Message_Digest[SHA1HashSize]); |
takahashim | 0:0048b264a3ad | 80 | |
takahashim | 0:0048b264a3ad | 81 | #ifdef __cplusplus |
takahashim | 0:0048b264a3ad | 82 | } |
takahashim | 0:0048b264a3ad | 83 | #endif |
takahashim | 0:0048b264a3ad | 84 | |
takahashim | 0:0048b264a3ad | 85 | #endif |