initial commit

This commit is contained in:
Markku-Juhani O. Saarinen
2015-12-14 10:53:03 +00:00
parent cb22037ec0
commit fbf23fa687
5 changed files with 384 additions and 0 deletions

36
sha3.h Normal file
View File

@@ -0,0 +1,36 @@
// sha3.h
// 19-Nov-11 Markku-Juhani O. Saarinen <mjos@iki.fi>
#ifndef SHA3_H
#define SHA3_H
#include <stddef.h>
#include <stdint.h>
#ifndef SHA3_ROUNDS
#define SHA3_ROUNDS 24
#endif
#ifndef ROTL64
#define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y))))
#endif
// state context
typedef struct {
union { // state:
uint8_t b[200]; // 8-bit bytes
uint64_t q[25]; // 64-bit words
} st;
int pt, rsiz, mdlen; // these don't overflow
} sha3_ctx_t;
// OpenSSL - like interfece
int sha3_init(sha3_ctx_t *c, int mdlen); // mdlen = hash output in bytes
int sha3_update(sha3_ctx_t *c, const void *data, size_t len);
int sha3_final(void *md, sha3_ctx_t *c); // digest goes to md
// compute a sha3 hash (md) of given byte length from "in"
unsigned char *sha3(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen);
#endif