2017-08-28 18:06:01 +02:00
|
|
|
#ifndef LIGHTNING_COMMON_CRYPTOMSG_H
|
|
|
|
#define LIGHTNING_COMMON_CRYPTOMSG_H
|
2017-01-10 06:08:33 +01:00
|
|
|
#include "config.h"
|
2017-01-10 06:08:33 +01:00
|
|
|
#include <ccan/tal/tal.h>
|
2017-10-11 11:56:50 +02:00
|
|
|
#include <common/crypto_state.h>
|
2017-01-10 06:08:33 +01:00
|
|
|
|
2018-09-27 23:04:19 +02:00
|
|
|
/* BOLT #8:
|
|
|
|
*
|
|
|
|
* ### Receiving and Decrypting Messages
|
|
|
|
*
|
|
|
|
* In order to decrypt the _next_ message in the network stream, the
|
|
|
|
* following steps are completed:
|
|
|
|
*
|
|
|
|
* 1. Read _exactly_ 18 bytes from the network buffer.
|
|
|
|
*/
|
|
|
|
#define CRYPTOMSG_HDR_SIZE 18
|
|
|
|
|
|
|
|
/* BOLT #8:
|
|
|
|
*
|
|
|
|
* 4. Read _exactly_ `l+16` bytes from the network buffer
|
|
|
|
*/
|
|
|
|
#define CRYPTOMSG_BODY_OVERHEAD 16
|
2017-01-10 06:08:33 +01:00
|
|
|
|
2017-04-01 12:25:59 +02:00
|
|
|
/* Low-level functions for sync comms: doesn't discard unknowns! */
|
2017-02-21 05:45:29 +01:00
|
|
|
u8 *cryptomsg_encrypt_msg(const tal_t *ctx,
|
|
|
|
struct crypto_state *cs,
|
|
|
|
const u8 *msg);
|
2017-02-24 06:52:35 +01:00
|
|
|
bool cryptomsg_decrypt_header(struct crypto_state *cs, u8 hdr[18], u16 *lenp);
|
2017-02-21 05:45:29 +01:00
|
|
|
u8 *cryptomsg_decrypt_body(const tal_t *ctx,
|
|
|
|
struct crypto_state *cs, const u8 *in);
|
2017-08-28 18:06:01 +02:00
|
|
|
#endif /* LIGHTNING_COMMON_CRYPTOMSG_H */
|