rust-secp256k1-unsafe-fast/depend/secp256k1/src/hash.h

42 lines
1.7 KiB
C
Raw Normal View History

2015-10-26 14:54:21 +00:00
/**********************************************************************
* Copyright (c) 2014 Pieter Wuille *
* Distributed under the MIT software license, see the accompanying *
* file COPYING or http://www.opensource.org/licenses/mit-license.php.*
**********************************************************************/
#ifndef SECP256K1_HASH_H
#define SECP256K1_HASH_H
2015-10-26 14:54:21 +00:00
#include <stdlib.h>
#include <stdint.h>
typedef struct {
uint32_t s[8];
2015-10-26 14:54:21 +00:00
uint32_t buf[16]; /* In big endian */
size_t bytes;
} secp256k1_sha256;
2015-10-26 14:54:21 +00:00
static void secp256k1_sha256_initialize(secp256k1_sha256 *hash);
static void secp256k1_sha256_write(secp256k1_sha256 *hash, const unsigned char *data, size_t size);
static void secp256k1_sha256_finalize(secp256k1_sha256 *hash, unsigned char *out32);
2015-10-26 14:54:21 +00:00
typedef struct {
secp256k1_sha256 inner, outer;
} secp256k1_hmac_sha256;
2015-10-26 14:54:21 +00:00
static void secp256k1_hmac_sha256_initialize(secp256k1_hmac_sha256 *hash, const unsigned char *key, size_t size);
static void secp256k1_hmac_sha256_write(secp256k1_hmac_sha256 *hash, const unsigned char *data, size_t size);
static void secp256k1_hmac_sha256_finalize(secp256k1_hmac_sha256 *hash, unsigned char *out32);
2015-10-26 14:54:21 +00:00
typedef struct {
unsigned char v[32];
unsigned char k[32];
int retry;
} secp256k1_rfc6979_hmac_sha256;
2015-10-26 14:54:21 +00:00
static void secp256k1_rfc6979_hmac_sha256_initialize(secp256k1_rfc6979_hmac_sha256 *rng, const unsigned char *key, size_t keylen);
static void secp256k1_rfc6979_hmac_sha256_generate(secp256k1_rfc6979_hmac_sha256 *rng, unsigned char *out, size_t outlen);
static void secp256k1_rfc6979_hmac_sha256_finalize(secp256k1_rfc6979_hmac_sha256 *rng);
2015-10-26 14:54:21 +00:00
#endif /* SECP256K1_HASH_H */