i try to use chacha20 encryption in my network software but i encounter a problem
if i encrypt 4 bytes data: 0x01 0x02 0x03 0x04
on server
and get the ciphertext: 0xd2 0xd3 0xc4 0xd5
, then send it to client
the client may receive <= 4bytes at a time
provided that client only recv 0xd2 0xd3
at first ,
it can decrypt data properly and get plaintext 0x01 0x02
but when client recv the last 2 bytes 0xc4 0xd5
it seems that the data can't be decrypt using the same nonce and key
so is there a way to solve the problem
adding length data as prefix before sending is a solution,but it's weird because i am using stream cipher.