Commit c40dad8b authored by David S. Miller's avatar David S. Miller

Merge nuts.ninka.net:/home/davem/src/BK/network-2.5

into nuts.ninka.net:/home/davem/src/BK/net-2.5
parents 310b411f edab0449
......@@ -186,7 +186,6 @@ Original developers of the crypto algorithms:
Dag Arne Osvik (Serpent)
Brian Gladman (AES)
SHA1 algorithm contributors:
Jean-Francois Dive
......@@ -214,6 +213,9 @@ AES algorithm contributors:
Kyle McMartin
Adam J. Richter
CAST5 algorithm contributors:
Kartikey Mahendra Bhatt (original developers unknown, FSF copyright).
Generic scatterwalk code by Adam J. Richter <adam@yggdrasil.com>
Please send any credits updates or corrections to:
......
......@@ -126,6 +126,13 @@ config CRYPTO_AES
See http://csrc.nist.gov/encryption/aes/ for more information.
config CRYPTO_CAST5
tristate "CAST5 (CAST-128) cipher algorithm"
depends on CRYPTO
help
The CAST5 encryption algorithm (synonymous with CAST-128) is
described in RFC2144.
config CRYPTO_DEFLATE
tristate "Deflate compression algorithm"
depends on CRYPTO
......
......@@ -20,6 +20,7 @@ obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish.o
obj-$(CONFIG_CRYPTO_TWOFISH) += twofish.o
obj-$(CONFIG_CRYPTO_SERPENT) += serpent.o
obj-$(CONFIG_CRYPTO_AES) += aes.o
obj-$(CONFIG_CRYPTO_CAST5) += cast5.o
obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
obj-$(CONFIG_CRYPTO_TEST) += tcrypt.o
This diff is collapsed.
......@@ -2192,6 +2192,102 @@ test_aes(void)
crypto_free_tfm(tfm);
}
void
test_cast5(void)
{
unsigned int ret, i, tsize;
u8 *p, *q, *key;
struct crypto_tfm *tfm;
struct cast5_tv *c5_tv;
struct scatterlist sg[1];
printk("\ntesting cast5 encryption\n");
tfm = crypto_alloc_tfm("cast5", 0);
if (tfm == NULL) {
printk("failed to load transform for cast5 (default ecb)\n");
return;
}
tsize = sizeof (cast5_enc_tv_template);
if (tsize > TVMEMSIZE) {
printk("template (%u) too big for tvmem (%u)\n", tsize,
TVMEMSIZE);
return;
}
memcpy(tvmem, cast5_enc_tv_template, tsize);
c5_tv = (void *) tvmem;
for (i = 0; i < CAST5_ENC_TEST_VECTORS; i++) {
printk("test %u (%d bit key):\n", i + 1, c5_tv[i].keylen * 8);
key = c5_tv[i].key;
ret = crypto_cipher_setkey(tfm, key, c5_tv[i].keylen);
if (ret) {
printk("setkey() failed flags=%x\n", tfm->crt_flags);
if (!c5_tv[i].fail)
goto out;
}
p = c5_tv[i].plaintext;
sg[0].page = virt_to_page(p);
sg[0].offset = ((long) p & ~PAGE_MASK);
sg[0].length = sizeof(c5_tv[i].plaintext);
ret = crypto_cipher_encrypt(tfm, sg, sg, sg[0].length);
if (ret) {
printk("encrypt() failed flags=%x\n", tfm->crt_flags);
goto out;
}
q = kmap(sg[0].page) + sg[0].offset;
hexdump(q, sizeof(c5_tv[i].ciphertext));
printk("%s\n", memcmp(q, c5_tv[i].ciphertext,
sizeof(c5_tv[i].ciphertext)) ? "fail" : "pass");
}
tsize = sizeof (cast5_dec_tv_template);
if (tsize > TVMEMSIZE) {
printk("template (%u) too big for tvmem (%u)\n", tsize,
TVMEMSIZE);
return;
}
memcpy(tvmem, cast5_dec_tv_template, tsize);
c5_tv = (void *) tvmem;
for (i = 0; i < CAST5_DEC_TEST_VECTORS; i++) {
printk("test %u (%d bit key):\n", i + 1, c5_tv[i].keylen * 8);
key = c5_tv[i].key;
ret = crypto_cipher_setkey(tfm, key, c5_tv[i].keylen);
if (ret) {
printk("setkey() failed flags=%x\n", tfm->crt_flags);
if (!c5_tv[i].fail)
goto out;
}
p = c5_tv[i].plaintext;
sg[0].page = virt_to_page(p);
sg[0].offset = ((long) p & ~PAGE_MASK);
sg[0].length = sizeof(c5_tv[i].plaintext);
ret = crypto_cipher_decrypt(tfm, sg, sg, sg[0].length);
if (ret) {
printk("decrypt() failed flags=%x\n", tfm->crt_flags);
goto out;
}
q = kmap(sg[0].page) + sg[0].offset;
hexdump(q, sizeof(c5_tv[i].ciphertext));
printk("%s\n", memcmp(q, c5_tv[i].ciphertext,
sizeof(c5_tv[i].ciphertext)) ? "fail" : "pass");
}
out:
crypto_free_tfm (tfm);
}
static void
test_deflate(void)
{
......@@ -2304,6 +2400,7 @@ do_test(void)
test_sha384();
test_sha512();
test_deflate();
test_cast5();
#ifdef CONFIG_CRYPTO_HMAC
test_hmac_md5();
test_hmac_sha1();
......@@ -2363,6 +2460,10 @@ do_test(void)
test_deflate();
break;
case 14:
test_cast5();
break;
#ifdef CONFIG_CRYPTO_HMAC
case 100:
test_hmac_md5();
......
......@@ -1682,6 +1682,74 @@ struct aes_tv aes_dec_tv_template[] = {
},
};
/* Cast5 test vectors from RFC 2144 */
#define CAST5_ENC_TEST_VECTORS 3
#define CAST5_DEC_TEST_VECTORS 3
struct cast5_tv {
unsigned keylen;
unsigned fail;
u8 key[16];
u8 plaintext[8];
u8 ciphertext[8];
};
struct cast5_tv cast5_enc_tv_template[] =
{
{
16,
0,
{ 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9A },
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
{ 0x23, 0x8b, 0x4f, 0xe5, 0x84, 0x7e, 0x44, 0xb2 },
},
{
10,
0,
{ 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
0x23, 0x45 },
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
{ 0xeb, 0x6a, 0x71, 0x1a, 0x2c, 0x02, 0x27, 0x1b },
},
{
5,
0,
{ 0x01, 0x23, 0x45, 0x67, 0x12 },
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
{ 0x7a, 0xc8, 0x16, 0xd1, 0x6e, 0x9b, 0x30, 0x2e },
}
};
struct cast5_tv cast5_dec_tv_template[] =
{
{
16,
0,
{ 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9A },
{ 0x23, 0x8b, 0x4f, 0xe5, 0x84, 0x7e, 0x44, 0xb2 },
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
},
{
10,
0,
{ 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
0x23, 0x45 },
{ 0xeb, 0x6a, 0x71, 0x1a, 0x2c, 0x02, 0x27, 0x1b },
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
},
{
5,
0,
{ 0x01, 0x23, 0x45, 0x67, 0x12 },
{ 0x7a, 0xc8, 0x16, 0xd1, 0x6e, 0x9b, 0x30, 0x2e },
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
}
};
/*
* Compression stuff.
*/
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -201,6 +201,6 @@ int br_stp_handle_bpdu(struct sk_buff *skb)
out:
spin_unlock_bh(&br->lock);
err:
kfree(skb);
kfree_skb(skb);
return 0;
}
......@@ -922,6 +922,7 @@ static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa,
unsigned char *b = skb->tail;
nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(*ifm));
if (pid) nlh->nlmsg_flags |= NLM_F_MULTI;
ifm = NLMSG_DATA(nlh);
ifm->ifa_family = AF_INET;
ifm->ifa_prefixlen = ifa->ifa_prefixlen;
......
......@@ -125,14 +125,14 @@ int ic_proto_enabled __initdata = 0
int ic_host_name_set __initdata = 0; /* Host name set by us? */
u32 ic_myaddr __initdata = INADDR_NONE; /* My IP address */
u32 ic_netmask __initdata = INADDR_NONE; /* Netmask for local subnet */
u32 ic_gateway __initdata = INADDR_NONE; /* Gateway IP address */
u32 ic_myaddr = INADDR_NONE; /* My IP address */
u32 ic_netmask = INADDR_NONE; /* Netmask for local subnet */
u32 ic_gateway = INADDR_NONE; /* Gateway IP address */
u32 ic_servaddr __initdata = INADDR_NONE; /* Boot server IP address */
u32 ic_servaddr = INADDR_NONE; /* Boot server IP address */
u32 root_server_addr __initdata = INADDR_NONE; /* Address of NFS server */
u8 root_server_path[256] __initdata = { 0, }; /* Path to mount as root */
u32 root_server_addr = INADDR_NONE; /* Address of NFS server */
u8 root_server_path[256] = { 0, }; /* Path to mount as root */
/* Persistent data: */
......
......@@ -91,11 +91,18 @@ masquerade_target(struct sk_buff **pskb,
#ifdef CONFIG_IP_ROUTE_FWMARK
.fwmark = (*pskb)->nfmark
#endif
} },
.oif = out->ifindex };
} } };
if (ip_route_output_key(&rt, &fl) != 0) {
/* Shouldn't happen */
printk("MASQUERADE: No route: Rusty's brain broke!\n");
/* Funky routing can do this. */
if (net_ratelimit())
printk("MASQUERADE:"
" No route: Rusty's brain broke!\n");
return NF_DROP;
}
if (rt->u.dst.dev != out) {
if (net_ratelimit())
printk("MASQUERADE:"
" Route sent us somewhere else.\n");
return NF_DROP;
}
}
......
......@@ -2443,6 +2443,7 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
unsigned char *b = skb->tail;
nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(*ifm));
if (pid) nlh->nlmsg_flags |= NLM_F_MULTI;
ifm = NLMSG_DATA(nlh);
ifm->ifa_family = AF_INET6;
ifm->ifa_prefixlen = ifa->prefix_len;
......
......@@ -833,6 +833,7 @@ static int rawv6_getsockopt(struct sock *sk, int level, int optname,
val = -1;
else
val = opt->offset;
break;
default:
return -ENOPROTOOPT;
......
......@@ -102,7 +102,7 @@ proc_dodebug(ctl_table *table, int write, struct file *file,
len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data);
if (len > left)
len = left;
copy_to_user(buffer, tmpbuf, len);
__copy_to_user(buffer, tmpbuf, len);
if ((left -= len) > 0) {
put_user('\n', (char *)buffer + len);
left--;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment