Cleanup: install initial key for server at the right moment

This commit is contained in:
Mark Spanbroek 2020-10-05 16:19:13 +02:00 committed by markspanbroek
parent 4bdd74d9b6
commit 8c135eae81
1 changed files with 12 additions and 12 deletions

View File

@ -10,6 +10,18 @@ import settings
var cryptoData: array[4096, uint8]
proc receiveClientInitial(connection: ptr ngtcp2_conn, dcid: ptr ngtcp2_cid, userData: pointer): cint {.cdecl.} =
var initialKey: Key
assert 0 == ngtcp2_conn_install_initial_key(
connection,
addr initialKey.aeadContext,
addr initialKey.iv[0],
addr initialKey.hpContext,
addr initialKey.aeadContext,
addr initialKey.iv[0],
addr initialKey.hpContext,
sizeof(initialKey.iv).uint
)
var rxHandshakeKey: Key
assert 0 == ngtcp2_conn_install_rx_handshake_key(
connection,
@ -111,16 +123,4 @@ proc setupServer*(path: ptr ngtcp2_path, sourceId: ptr ngtcp2_cid, destinationId
nil
)
var initialKey: Key
assert 0 == ngtcp2_conn_install_initial_key(
result,
addr initialKey.aeadContext,
addr initialKey.iv[0],
addr initialKey.hpContext,
addr initialKey.aeadContext,
addr initialKey.iv[0],
addr initialKey.hpContext,
sizeof(initialKey.iv).uint
)
ngtcp2_conn_set_aead_overhead(result, NGTCP2_FAKE_AEAD_OVERHEAD)