mirror of https://github.com/vacp2p/nim-quic.git
Add AEAD overhead
This commit is contained in:
parent
bd32d3ecd9
commit
3f9d9050df
|
@ -0,0 +1 @@
|
|||
const NGTCP2_FAKE_AEAD_OVERHEAD* = 16
|
|
@ -3,6 +3,7 @@ import ngtcp2
|
|||
import ids
|
||||
import encrypt
|
||||
import decrypt
|
||||
import aead
|
||||
import hp
|
||||
import log
|
||||
|
||||
|
@ -93,3 +94,6 @@ proc setupClient*(path: ptr ngtcp2_path, sourceId: ptr ngtcp2_cid, destinationId
|
|||
)
|
||||
|
||||
ngtcp2_conn_set_retry_aead(result, addr retryAead, addr aeadContext)
|
||||
|
||||
ngtcp2_conn_set_aead_overhead(result, NGTCP2_FAKE_AEAD_OVERHEAD)
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import ngtcp2
|
||||
import aead
|
||||
|
||||
proc dummyDecrypt*(dest: ptr uint8,
|
||||
aead: ptr ngtcp2_crypto_aead,
|
||||
|
@ -10,5 +11,6 @@ proc dummyDecrypt*(dest: ptr uint8,
|
|||
ad: ptr uint8,
|
||||
adlen: uint): cint {.cdecl.} =
|
||||
echo "DECRYPT"
|
||||
copyMem(dest, ciphertext, ciphertextlen)
|
||||
assert ciphertextlen >= NGTCP2_FAKE_AEAD_OVERHEAD
|
||||
moveMem(dest, ciphertext, ciphertextlen - NGTCP2_FAKE_AEAD_OVERHEAD)
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import ngtcp2
|
||||
import aead
|
||||
|
||||
proc dummyEncrypt*(dest: ptr uint8,
|
||||
aead: ptr ngtcp2_crypto_aead,
|
||||
|
@ -10,4 +11,6 @@ proc dummyEncrypt*(dest: ptr uint8,
|
|||
ad: ptr uint8,
|
||||
adlen: uint): cint{.cdecl.} =
|
||||
echo "ENCRYPT"
|
||||
if plaintextlen.bool and plaintext != dest:
|
||||
copyMem(dest, plaintext, plaintextlen)
|
||||
zeroMem(cast[ptr uint8](cast[ByteAddress](dest) + ByteAddress(plaintextlen)), NGTCP2_FAKE_AEAD_OVERHEAD)
|
||||
|
|
|
@ -2,6 +2,7 @@ import std/monotimes
|
|||
import ngtcp2
|
||||
import encrypt
|
||||
import decrypt
|
||||
import aead
|
||||
import hp
|
||||
import ids
|
||||
import log
|
||||
|
@ -116,4 +117,4 @@ proc setupServer*(path: ptr ngtcp2_path, sourceId: ptr ngtcp2_cid, destinationId
|
|||
addr hpContext
|
||||
)
|
||||
|
||||
ngtcp2_conn_set_aead_overhead(result, 0)
|
||||
ngtcp2_conn_set_aead_overhead(result, NGTCP2_FAKE_AEAD_OVERHEAD)
|
||||
|
|
Loading…
Reference in New Issue