mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
b122e44a0b
Blinded paths will want this too; it's mainly copied from sphinx. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
31 lines
798 B
C
31 lines
798 B
C
#ifndef LIGHTNING_COMMON_HMAC_H
|
|
#define LIGHTNING_COMMON_HMAC_H
|
|
#include "config.h"
|
|
#include <ccan/short_types/short_types.h>
|
|
#include <ccan/structeq/structeq.h>
|
|
#include <sodium/crypto_auth_hmacsha256.h>
|
|
|
|
struct secret;
|
|
|
|
/* HMAC used by Sphinx: SHA256 */
|
|
struct hmac {
|
|
u8 bytes[crypto_auth_hmacsha256_BYTES];
|
|
};
|
|
|
|
void hmac(const void *src, size_t slen,
|
|
const void *key, size_t klen,
|
|
struct hmac *hmac);
|
|
|
|
/* Common style: hmac to derive key using fixed string prefix. */
|
|
void subkey_from_hmac(const char *prefix,
|
|
const struct secret *base,
|
|
struct secret *key);
|
|
|
|
void towire_hmac(u8 **pptr, const struct hmac *hmac);
|
|
void fromwire_hmac(const u8 **ptr, size_t *max, struct hmac *hmac);
|
|
|
|
/* Define hmac_eq. */
|
|
STRUCTEQ_DEF(hmac, 0, bytes);
|
|
|
|
#endif /* LIGHTNING_COMMON_HMAC_H */
|