mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-08-08 06:32:25 -04:00
tkey-libs: Import tag fw-3 of tkey-libs
- Use tag fw-3 from https://github.com/tillitis/tkey-libs/
This commit is contained in:
parent
d0c049cdba
commit
81f3195592
19 changed files with 861 additions and 79 deletions
45
hw/application_fpga/tkey-libs/blake2s/blake2s.h
Normal file
45
hw/application_fpga/tkey-libs/blake2s/blake2s.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
//======================================================================
|
||||
//
|
||||
// blake2s.h
|
||||
// ---------
|
||||
// BLAKE2s Hashing Context and API Prototypes
|
||||
//
|
||||
// See LICENSE for license terms.
|
||||
// See README.md in the repo root for info about source code origin.
|
||||
//======================================================================
|
||||
|
||||
#ifndef BLAKE2S_H
|
||||
#define BLAKE2S_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
// state context
|
||||
typedef struct {
|
||||
uint8_t b[64]; // input buffer
|
||||
uint32_t h[8]; // chained state
|
||||
uint32_t t[2]; // total number of bytes
|
||||
size_t c; // pointer for b[]
|
||||
size_t outlen; // digest size
|
||||
} blake2s_ctx;
|
||||
|
||||
// Initialize the hashing context "ctx" with optional key "key".
|
||||
// 1 <= outlen <= 32 gives the digest size in bytes.
|
||||
// Secret key (also <= 32 bytes) is optional (keylen = 0).
|
||||
int blake2s_init(blake2s_ctx *ctx, size_t outlen,
|
||||
const void *key, size_t keylen); // secret key
|
||||
|
||||
// Add "inlen" bytes from "in" into the hash.
|
||||
void blake2s_update(blake2s_ctx *ctx, // context
|
||||
const void *in, size_t inlen); // data to be hashed
|
||||
|
||||
// Generate the message digest (size given in init).
|
||||
// Result placed in "out".
|
||||
void blake2s_final(blake2s_ctx *ctx, void *out);
|
||||
|
||||
// All-in-one convenience function.
|
||||
int blake2s(void *out, size_t outlen, // return buffer for digest
|
||||
const void *key, size_t keylen, // optional secret key
|
||||
const void *in, size_t inlen); // data to be hashed
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue