| 1 |
/* |
| 2 |
* This is an implementation of the National Institute of Standards |
| 3 |
* and Technology US Secure Hash Algorithm 1 (SHA1). |
| 4 |
* |
| 5 |
* Public api for steve reid's public domain SHA-1 implementation. |
| 6 |
* This file is in the public domain. |
| 7 |
*/ |
| 8 |
|
| 9 |
#ifndef _CRYPT_ALG_SHA1_H |
| 10 |
#define _CRYPT_ALG_SHA1_H 1 |
| 11 |
|
| 12 |
/* Structure to save state of computation between the single steps. */ |
| 13 |
struct sha1_ctx |
| 14 |
{ |
| 15 |
uint32_t state[5]; |
| 16 |
uint32_t count[2]; |
| 17 |
uint8_t buffer[64]; |
| 18 |
}; |
| 19 |
|
| 20 |
/* Initialize structure containing state of computation. |
| 21 |
(RFC 3174, 6.1) */ |
| 22 |
extern void sha1_init_ctx (struct sha1_ctx *ctx); |
| 23 |
|
| 24 |
/* Starting with the result of former calls of this function (or the |
| 25 |
initialization function) update the context for the next LEN bytes |
| 26 |
starting at BUFFER. LEN does not need to be a multiple of 64. */ |
| 27 |
extern void sha1_process_bytes (const void *buffer, struct sha1_ctx *ctx, size_t size); |
| 28 |
|
| 29 |
/* Process the remaining bytes in the buffer and write the finalized |
| 30 |
hash to RESBUF, which should point to 20 bytes of storage. All |
| 31 |
data written to CTX is erased before returning from the function. */ |
| 32 |
extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf); |
| 33 |
|
| 34 |
#endif |