Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use cryptographic random for determining skipped packet numbers #2940

Merged
merged 1 commit into from
Jan 17, 2021

Conversation

marten-seemann
Copy link
Member

As @lucas-clemente suggested in #2905 (review).

@codecov
Copy link

codecov bot commented Dec 15, 2020

Codecov Report

Merging #2940 (6b87198) into master (4867389) will decrease coverage by 0.00%.
The diff coverage is 88.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2940      +/-   ##
==========================================
- Coverage   86.18%   86.18%   -0.00%     
==========================================
  Files         132      132              
  Lines        9160     9165       +5     
==========================================
+ Hits         7894     7898       +4     
- Misses        914      915       +1     
  Partials      352      352              
Impacted Files Coverage Δ
internal/ackhandler/packet_number_generator.go 96.43% <88.89%> (-3.57%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4867389...6b87198. Read the comment docs.

@marten-seemann marten-seemann force-pushed the packet-number-skipping-cryptographic-random branch from 5b2588f to 6b87198 Compare December 15, 2020 10:46
}
max := int32((1 << 31) - 1 - (1<<31)%uint32(n))
v := r.Int31()
for v > max {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe increase the fallback by powers of two? That would allow you to drop this loop / skip the loop in crypto/rand.Int()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand your comment. tbh, I just copied this from the math/rand implementation of Int63n. max should be very close to math.MaxInt32, so this loop is very unlikely to be executed.

@marten-seemann marten-seemann merged commit 868127b into master Jan 17, 2021
@marten-seemann marten-seemann deleted the packet-number-skipping-cryptographic-random branch January 17, 2021 06:38
@aschmahmann aschmahmann mentioned this pull request May 14, 2021
71 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants