Created
September 27, 2016 01:50
-
-
Save chris-wood/d0a4a61c2679ed8712547ae7d248f18c to your computer and use it in GitHub Desktop.
Linux kernel secure sequence generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, | |
__be16 sport, __be16 dport) | |
{ | |
u32 hash[MD5_DIGEST_WORDS]; | |
net_secret_init(); | |
hash[0] = (__force u32)saddr; | |
hash[1] = (__force u32)daddr; | |
hash[2] = ((__force u16)sport << 16) + (__force u16)dport; | |
hash[3] = net_secret[15]; | |
md5_transform(hash, net_secret); | |
return seq_scale(hash[0]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment