| 345 | handshake_failed_((conn), (h), __func__, __LINE__) |
| 346 | |
| 347 | static struct io_plan *handshake_succeeded(struct io_conn *conn, |
| 348 | struct handshake *h) |
| 349 | { |
| 350 | struct crypto_state cs; |
| 351 | struct io_plan *(*cb)(struct io_conn *conn, |
| 352 | const struct pubkey *their_id, |
| 353 | const struct wireaddr_internal *addr, |
| 354 | struct crypto_state *cs, |
| 355 | struct oneshot *timeout, |
| 356 | void *cbarg); |
| 357 | void *cbarg; |
| 358 | struct pubkey their_id; |
| 359 | struct wireaddr_internal addr; |
| 360 | struct oneshot *timeout; |
| 361 | |
| 362 | /* BOLT #8: |
| 363 | * |
| 364 | * 9. `rk, sk = HKDF(ck, zero)` |
| 365 | * * where `zero` is a zero-length plaintext, `rk` is the key to |
| 366 | * be used by the responder to decrypt the messages sent by the |
| 367 | * initiator, and `sk` is the key to be used by the responder |
| 368 | * to encrypt messages to the initiator |
| 369 | * |
| 370 | * * The final encryption keys, to be used for sending and |
| 371 | * receiving messages for the duration of the session, are |
| 372 | * generated. |
| 373 | */ |
| 374 | if (h->side == RESPONDER) |
| 375 | hkdf_two_keys(&cs.rk, &cs.sk, &h->ck, NULL, 0); |
| 376 | else |
| 377 | hkdf_two_keys(&cs.sk, &cs.rk, &h->ck, NULL, 0); |
| 378 | |
| 379 | cs.rn = cs.sn = 0; |
| 380 | cs.r_ck = cs.s_ck = h->ck; |
| 381 | |
| 382 | cb = h->cb; |
| 383 | cbarg = h->cbarg; |
| 384 | their_id = h->their_id; |
| 385 | addr = h->addr; |
| 386 | timeout = h->timeout; |
| 387 | |
| 388 | tal_free(h); |
| 389 | return cb(conn, &their_id, &addr, &cs, timeout, cbarg); |
| 390 | } |
| 391 | |
| 392 | static struct handshake *new_handshake(const tal_t *ctx, |
| 393 | const struct pubkey *responder_id) |
no test coverage detected