Browse Source
In particular, the main daemon needs to pass it about (marshal/unmarshal) but it won't need to actually use it after the next patch. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>ppa-0.6.1
Rusty Russell
7 years ago
committed by
Christian Decker
11 changed files with 50 additions and 33 deletions
@ -0,0 +1,22 @@ |
|||||
|
#include <common/crypto_state.h> |
||||
|
#include <wire/wire.h> |
||||
|
|
||||
|
void towire_crypto_state(u8 **ptr, const struct crypto_state *cs) |
||||
|
{ |
||||
|
towire_u64(ptr, cs->rn); |
||||
|
towire_u64(ptr, cs->sn); |
||||
|
towire_secret(ptr, &cs->sk); |
||||
|
towire_secret(ptr, &cs->rk); |
||||
|
towire_secret(ptr, &cs->s_ck); |
||||
|
towire_secret(ptr, &cs->r_ck); |
||||
|
} |
||||
|
|
||||
|
void fromwire_crypto_state(const u8 **ptr, size_t *max, struct crypto_state *cs) |
||||
|
{ |
||||
|
cs->rn = fromwire_u64(ptr, max); |
||||
|
cs->sn = fromwire_u64(ptr, max); |
||||
|
fromwire_secret(ptr, max, &cs->sk); |
||||
|
fromwire_secret(ptr, max, &cs->rk); |
||||
|
fromwire_secret(ptr, max, &cs->s_ck); |
||||
|
fromwire_secret(ptr, max, &cs->r_ck); |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
#ifndef LIGHTNING_COMMON_CRYPTO_STATE_H |
||||
|
#define LIGHTNING_COMMON_CRYPTO_STATE_H |
||||
|
#include "config.h" |
||||
|
#include <bitcoin/privkey.h> |
||||
|
#include <ccan/short_types/short_types.h> |
||||
|
#include <stddef.h> |
||||
|
|
||||
|
struct crypto_state { |
||||
|
/* Received and sent nonces. */ |
||||
|
u64 rn, sn; |
||||
|
/* Sending and receiving keys. */ |
||||
|
struct secret sk, rk; |
||||
|
/* Chaining key for re-keying */ |
||||
|
struct secret s_ck, r_ck; |
||||
|
}; |
||||
|
|
||||
|
void towire_crypto_state(u8 **pptr, const struct crypto_state *cs); |
||||
|
void fromwire_crypto_state(const u8 **ptr, size_t *max, struct crypto_state *cs); |
||||
|
|
||||
|
#endif /* LIGHTNING_COMMON_CRYPTO_STATE_H */ |
Loading…
Reference in new issue