does not compile. update spec.

pull/1/head
Jeff Becker 6 years ago
parent 14d2de8edb
commit 0cc6d175cf
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -76,42 +76,27 @@ Bob transmits ( s + n + x + w1 ), r is ignored and discarded
Alice recieves ( s + n + x + w1 ) and verifies the signature silently
dropping if it does not match.
2) token offer
2) session start
Alice sends the token from the intro ack back to Bob
Alice uses the token from bob to start the wire session
32 bytes hmac, h
32 bytes nounce, n
32 bytes ciphertext, x
variadic byttes padding, w2
T = HS(token + n)
w2 = "[insert variable length random padding here]"
k = TKE(a.k, b.k, n)
x = SE(k, token, n[0:24])
h = MDS(n + x + w2, k)
K = TKE(a.k, b.k, T)
x = SE(K, token, n[0:24])
h = MDS(n + x + w2, K)
Alice transmits ( h + n + x + w2 )
Bob recieves ( h + n + x + w2) and verifies that h == MDS(n + x, k) silently
drops if not matching
4) token ack
Bob acks the token that he got from Alice
32 bytes hmac, h
32 bytes nounce, n
32 bytes ciphertext, x
variadic byttes padding, w3
w3 = "[insert variable length random padding here]"
S = TKE(a.k, b.k, token)
x = SE(S, token, n[0:24])
h = MDS(n + x + w3, S)
Alice transmits ( h + n + x + w3 ) to Bob and the session is now established
using shared secret S
Bob receves ( h + n + x + w3 ) and verifies that h == MDS(n + x + w3, S)
the session is now established with session key K,
Bob replies by transmitting a LIM
IWP payload format:

@ -261,6 +261,8 @@ identifies the sender as having the RC contained in r. The recipiant MUST
validate the RC's signature and ensure that the public key in use is listed in
the RC.a matching the ipv6 address it originated from.
if r is not present in sessions made by clients.
{
a: "i",
r: RC,

@ -63,11 +63,11 @@ void iwp_call_async_keygen(struct llarp_async_iwp * iwp, struct iwp_async_keygen
struct iwp_async_gen_intro;
struct iwp_async_intro;
typedef void (*iwp_intro_gen_hook)(struct iwp_async_gen_intro *);
typedef void (*iwp_intro_gen_hook)(struct iwp_async_intro *);
struct iwp_async_gen_intro
struct iwp_async_intro
{
struct llarp_async_iwp * iwp;
void * user;
@ -86,14 +86,14 @@ struct iwp_async_gen_intro
};
void iwp_call_async_gen_intro(struct llarp_async_iwp * iwp, struct iwp_async_gen_intro * intro);
void iwp_call_async_gen_intro(struct llarp_async_iwp * iwp, struct iwp_async_intro * intro);
struct iwp_async_gen_introack;
struct iwp_async_introack;
typedef void (*iwp_introack_gen_hook)(struct iwp_async_gen_introack *);
typedef void (*iwp_introack_gen_hook)(struct iwp_async_introack *);
struct iwp_async_gen_introack
struct iwp_async_introack
{
void * user;
uint8_t * buf;
@ -109,8 +109,18 @@ struct iwp_async_gen_introack
};
void iwp_call_async_gen_intro(struct llarp_async_iwp * iwp, struct iwp_async_gen_intro * intro);
void iwp_call_async_gen_introack(struct llarp_async_iwp * iwp, struct iwp_async_introack * introack);
void iwp_call_async_verify_introack(struct llarp_async_iwp * iwp, struct iwp_async_introack * introack);
struct iwp_async_token
{
void * user;
uint8_t * buf;
size_t sz;
uint8_t * nonce;
uint8_t * sharedkey;
};
struct llarp_async_cipher;
struct llarp_cipher_result;

@ -212,13 +212,13 @@ void iwp_call_async_keygen(struct llarp_async_iwp * iwp, struct iwp_async_keygen
static void iwp_inform_genintro(void * user)
{
struct iwp_async_gen_intro * intro = user;
struct iwp_async_intro * intro = user;
intro->hook(intro);
}
static void iwp_do_genintro(void * user)
{
struct iwp_async_gen_intro * intro = user;
struct iwp_async_intro * intro = user;
llarp_shorthash_t sharedkey;
llarp_buffer_t buf;
struct llarp_crypto * crypto = intro->iwp->crypto;
@ -249,7 +249,7 @@ static void iwp_do_genintro(void * user)
llarp_logic_queue_job(intro->iwp->logic, job);
}
void iwp_call_async_gen_intro(struct llarp_async_iwp * iwp, struct iwp_async_gen_intro * intro)
void iwp_call_async_gen_intro(struct llarp_async_iwp * iwp, struct iwp_async_intro * intro)
{
intro->iwp = iwp;

@ -25,8 +25,9 @@ struct session
llarp_sharedkey_t sessionkey;
llarp_link_session_listener establish_listener = {nullptr, nullptr, nullptr, nullptr};
llarp::Addr addr;
iwp_async_gen_intro intro;
iwp_async_gen_introack introack;
iwp_async_intro intro;
iwp_async_introack introack;
iwp_async_token token;
uint8_t workbuf[1024];
@ -41,10 +42,7 @@ struct session
eIntroSent,
eIntroAckSent,
eIntroAckRecv,
eTokenOfferSent,
eTokenOfferRecv,
eTokenAckSent,
eTokenAckRecv,
eSessionStartSent,
eEstablished,
eTimeout
};
@ -100,16 +98,55 @@ struct session
}
static void handle_verify_introack(iwp_async_introack * introack)
{
session * link = static_cast<session *>(introack->user);
if(introack->buf == nullptr)
{
// invalid signature
printf("introack validation failed\n");
return;
}
printf("introack validated\n");
link->state = eIntroAckRecv;
link->session_start();
}
void session_start()
{
}
void on_intro_ack(const void * buf, size_t sz)
{
printf("iwp intro ack\n");
if(sz >= sizeof(workbuf))
{
// too big?
printf("intro ack too big\n");
// TOOD: session destroy ?
return;
}
// copy buffer so we own it
memcpy(workbuf, buf, sz);
// set intro ack parameters
introack.buf = workbuf;
introack.sz = sz;
introack.nonce = workbuf + 64;
introack.remote_pubkey = remote;
introack.secretkey = eph_seckey;
introack.user = this;
introack.hook = &handle_verify_introack;
// async verify
iwp_call_async_verify_introack(iwp, &introack);
}
static void handle_generated_intro(iwp_async_gen_intro * i)
static void handle_generated_intro(iwp_async_intro * i)
{
session * link = static_cast<session *>(i->user);
llarp_ev_udp_sendto(link->udp, link->addr, i->buf, i->sz);
printf("sent introduce of size %ld\n", i->sz);
link->state = eIntroSent;
}

Loading…
Cancel
Save