Skip to contentSkip to conversation

Question about the syncookie_secret[] in syncookies.c

DISCUSSION openbsd shen 2 participants 2 messages Jan 17, 2006

lore
Share & tools
lore
#0 lore raw

In /usr/src/linux/net/ipv4/syncookies.c, there are 2 lines:

static __u32 syncookie_secret[2][16-3+SHA_DIGEST_WORDS]; #define SHA_DIGEST_WORDS 5

As we know 16-3+5 = 18, why not use syncookie_secret[2][18] directly ?

Thanks

#1 lore raw
Quoted 6 lines · openbsd shen

In /usr/src/linux/net/ipv4/syncookies.c, there are 2 lines:

static __u32 syncookie_secret[2][16-3+SHA_DIGEST_WORDS]; #define SHA_DIGEST_WORDS 5

As we know 16-3+5 = 18, why not use syncookie_secret[2][18] directly ?

Because it is good practice to define constants, which are used in multiple places, only once (here: SHA_DIGEST_WORDS is defined in <linux/cryptohash.h>) . It eases maintenance of code significantly.

\Steve

--

Steve Graegert <[email protected]>
Software Consultant {C/C++ && Java && .NET}
Office: +49 9131 7123988
Mobile: +49 1520 9289212