add stripped-down & slightly-modified version of LibTomCrypt SHA256

This commit is contained in:
Steffen Jaeckel
2019-10-07 16:21:13 +02:00
committed by Dmitry Podgorny
parent 2a94a49cef
commit d78b02ee24
2 changed files with 248 additions and 0 deletions

34
src/sha256.h Normal file
View File

@@ -0,0 +1,34 @@
/* public api for Thomas Pornin's BearSSL SHA-256 implementation */
/** @file
* SHA-256 hash API.
*/
#ifndef __LIBSTROPHE_SHA256_H__
#define __LIBSTROPHE_SHA256_H__
#ifdef __cplusplus
extern "C" {
#endif
/* make sure the stdint.h types are available */
#include "ostypes.h"
typedef struct {
uint64_t length;
uint32_t state[8], curlen;
uint8_t buf[64];
} sha256_context;
#define SHA256_DIGEST_SIZE 32
void sha256_init(sha256_context *md);
void sha256_process(sha256_context *md, const uint8_t *in, size_t inlen);
void sha256_done(sha256_context *md, uint8_t *out);
void sha256_hash(const uint8_t *data, size_t len, uint8_t *digest);
#ifdef __cplusplus
}
#endif
#endif /* __LIBSTROPHE_SHA256_H__ */