ameshkov / dnscrypt

DNSCrypt v2 protocol implementation + a command-line tool
The Unlicense
75 stars 14 forks source link

minQuestionSize problem in padding #24

Closed zoli closed 8 months ago

zoli commented 10 months ago

From what I understand this line in pad function isn't right.

// get closest divisible by 64 to <packet-len> + 1 byte for 0x80
minQuestionSize := (len(packet)+1+63)/64 + 64

It doesn't result in closes divisible by 64. For example if packet length is 56 it will result in 65 which should be 64 (the closest divisible by 64 to 56+1 is 64). I think it should get rewritten to STH like this:

minQuestionSize := len(packet) + 1 + (64 - (len(packet)+1)%64)
ameshkov commented 10 months ago

Would you like to submit a pull request? If you do, please also add a unit-test for this case.

zoli commented 10 months ago

Would you like to submit a pull request? If you do, please also add a unit-test for this case.

Sure. Will add unit tests too.