提交 c4365c92 编写于 作者: A Arnaldo Carvalho de Melo 提交者: David S. Miller

[RANDOM]: Introduce secure_dccp_sequence_number

Code contributed by Stephen Hemminger.
Signed-off-by: NArnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 d8c97a94
...@@ -1589,6 +1589,40 @@ u32 secure_tcpv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, __u16 dp ...@@ -1589,6 +1589,40 @@ u32 secure_tcpv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, __u16 dp
EXPORT_SYMBOL(secure_tcpv6_port_ephemeral); EXPORT_SYMBOL(secure_tcpv6_port_ephemeral);
#endif #endif
#if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE)
/* Similar to secure_tcp_sequence_number but generate a 48 bit value
* bit's 32-47 increase every key exchange
* 0-31 hash(source, dest)
*/
u64 secure_dccp_sequence_number(__u32 saddr, __u32 daddr,
__u16 sport, __u16 dport)
{
struct timeval tv;
u64 seq;
__u32 hash[4];
struct keydata *keyptr = get_keyptr();
hash[0] = saddr;
hash[1] = daddr;
hash[2] = (sport << 16) + dport;
hash[3] = keyptr->secret[11];
seq = half_md4_transform(hash, keyptr->secret);
seq |= ((u64)keyptr->count) << (32 - HASH_BITS);
do_gettimeofday(&tv);
seq += tv.tv_usec + tv.tv_sec * 1000000;
seq &= (1ull << 48) - 1;
#if 0
printk("dccp init_seq(%lx, %lx, %d, %d) = %d\n",
saddr, daddr, sport, dport, seq);
#endif
return seq;
}
EXPORT_SYMBOL(secure_dccp_sequence_number);
#endif
#endif /* CONFIG_INET */ #endif /* CONFIG_INET */
......
...@@ -59,6 +59,8 @@ extern __u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr, ...@@ -59,6 +59,8 @@ extern __u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr,
__u16 sport, __u16 dport); __u16 sport, __u16 dport);
extern __u32 secure_tcpv6_sequence_number(__u32 *saddr, __u32 *daddr, extern __u32 secure_tcpv6_sequence_number(__u32 *saddr, __u32 *daddr,
__u16 sport, __u16 dport); __u16 sport, __u16 dport);
extern u64 secure_dccp_sequence_number(__u32 saddr, __u32 daddr,
__u16 sport, __u16 dport);
#ifndef MODULE #ifndef MODULE
extern struct file_operations random_fops, urandom_fops; extern struct file_operations random_fops, urandom_fops;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册