ameshkov/dnscrypt

minQuestionSize problem in padding

zoli opened this issue · 2 comments

zoli commented

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)

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

zoli commented

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.