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