James Kuszmaul | 82f6c04 | 2021-01-17 11:30:16 -0800 | [diff] [blame^] | 1 | /** |
| 2 | * @file re_sha.h Interface to SHA (Secure Hash Standard) functions |
| 3 | * |
| 4 | * Copyright (C) 2010 Creytiv.com |
| 5 | */ |
| 6 | |
| 7 | |
| 8 | #ifdef USE_OPENSSL |
| 9 | #include <openssl/sha.h> |
| 10 | #else |
| 11 | |
| 12 | /* public api for steve reid's public domain SHA-1 implementation */ |
| 13 | /* this file is in the public domain */ |
| 14 | |
| 15 | /** SHA-1 Context */ |
| 16 | typedef struct { |
| 17 | uint32_t state[5]; /**< Context state */ |
| 18 | uint32_t count[2]; /**< Counter */ |
| 19 | uint8_t buffer[64]; /**< SHA-1 buffer */ |
| 20 | } SHA1_CTX; |
| 21 | |
| 22 | /** SHA-1 Context (OpenSSL compat) */ |
| 23 | typedef SHA1_CTX SHA_CTX; |
| 24 | |
| 25 | /** SHA-1 Digest size in bytes */ |
| 26 | #define SHA1_DIGEST_SIZE 20 |
| 27 | /** SHA-1 Digest size in bytes (OpenSSL compat) */ |
| 28 | #define SHA_DIGEST_LENGTH SHA1_DIGEST_SIZE |
| 29 | |
| 30 | void SHA1_Init(SHA1_CTX* context); |
| 31 | void SHA1_Update(SHA1_CTX* context, const void *p, size_t len); |
| 32 | void SHA1_Final(uint8_t digest[SHA1_DIGEST_SIZE], SHA1_CTX* context); |
| 33 | |
| 34 | #endif |