random(4) overheads question

2011-09-26 Thread Sandy Harris
I'm working on a demon that collects timer randomness, distills it
some, and pushes the results into /dev/random.

My code produces the random material in 32-bit chunks. The current
version sends it to /dev/random 32 bits at a time, doing a write() and
an entropy-update ioctl() for each chunk. Obviously I could add some
buffering and write fewer and larger chunks. My questions are whether
that is worth doing and, if so, what the optimum write() size is
likely to be.

I am not overly concerned about overheads on my side of the interface,
unless they are quite large. My concern is whether doing many small
writes wastes kernel resources.
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC v2.1 0/6] evm: digital signature verification extension

2011-09-26 Thread Kasatkin, Dmitry
On Tue, Sep 20, 2011 at 4:24 PM, Mimi Zohar zo...@linux.vnet.ibm.com wrote:
 On Tue, 2011-09-13 at 17:20 +0300, Dmitry Kasatkin wrote:
 Hello,

 Changes to version 2.0:
 - MPI patch has been split to smaller in order to go to mailing lists.
   First 2 patches include only source and header files which are needed
   to build ksign verification. Headers and sources are split just to
   meet 100k kernel.org limit.
   Last patch adds all rest soures from original ported MPI library.

 Changes to version 1.1:
 - GnuPG MPI library has been refactored with lindent and checkpatch errors
   and warnings has been fixed.
 - creation of evm keyring has been remove. It is done now in user space.
 - related ksign and evm patches has been squashed.
 - patch descriptions has been updated.

 As EVM patches were recently merged to security-testing-2.6#next,
 it is a good time to resend evm signature verification patches for active
 discussion. Last time I forgot --cc linux-crypto. Here it is.

 This patchset introduces digital signature extensions for the IMA/EVM kernel
 integrity subsystem and is applied on the top of the EVM patches posted to
 LSM mailing list earlier.

 Hi Herbert

 Back in March 2011, in preparation for EVM, Dmitry posted the GnuPG MPI
 library patch here on linux-crypto. The reason given for not upstreaming
 the MPI library, at the time, was for lack of an in kernel user
 (http://www.mail-archive.com/linux-crypto@vger.kernel.org/msg05613.html).
 With the recent merging of the EVM patches in linux-next, via
 security-testing-2.6/#next, that is changing.  Any chance of re-opening
 the discussion?

 thanks,

 Mimi

 --
 To unsubscribe from this list: send the line unsubscribe 
 linux-security-module in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html


Hi,

It seems nobody wants to share their thoughts about it?
Does this silence mean acceptance?
Should I prepare final patches for merge?

BR,
Dmitry
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 04/17] crypto: Add userspace configuration API

2011-09-26 Thread Steffen Klassert
On Wed, Sep 21, 2011 at 11:02:38AM +0200, Steffen Klassert wrote:
 +
 +static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 +{
 + struct nlattr *attrs[CRYPTOCFGA_MAX+1];
 + struct crypto_link *link;
 + int type, err;
 +
 + type = nlh-nlmsg_type;
 + if (type  CRYPTO_MSG_MAX)
 + return -EINVAL;
 +
 + type -= CRYPTO_MSG_BASE;
 + link = crypto_dispatch[type];
 +
 + if (security_netlink_recv(skb, CAP_NET_ADMIN))
 + return -EPERM;
 +

I'm just wondering whether CAP_NET_ADMIN is the right capability to
use here? Do you think we can keep it like that, or would it be better
to define a new CAP_CRYPTO_ADMIN capability?
 
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


群发软件+买家搜索机+最新广交会买家、海关数据,B2B询盘买家500万。

2011-09-26 Thread 保证有买家回复
群发软件+买家搜索机+109届广交会买家、展会买家、海关数据,B2B询盘买家500万。

一共8个包(数据是全行业的,按照行业分好类,并且可以按照关键词查询的): 
1,2011春季109届广交会买家数据库新鲜出炉,超级新鲜买家,新鲜数据,容易成单! 
2,最新全球买家库,共451660条数据。 
3,2008年,2009年,2010年 春季+秋季广交会买家名录,103 104 105 106 107 108 共六届 共120.6万数据。
4,2010年国际促销协会(PPAI)成员名单 PPAI Members Directory,非常重要的大买家。
5,2010年到香港采购的国外客人名录(香港贸发局提供),共7.2万数据,超级重要的买家。
6,60.8万条最新国外B2B买家询盘。
7,2009年海关提单数据piers版数据 1千万。
8,群发软件,群发软件的部署与安装。

共 500万个买家,每个均有Email. 

保证每天都有买家回复。
保证每天都有买家回复。

要的抓紧联系QQ: 1339625218   或者立即回复邮箱: 1339625...@qq.com
要的抓紧联系QQ: 1339625218   或者立即回复邮箱: 1339625...@qq.com
要的抓紧联系QQ: 1339625218   或者立即回复邮箱: 1339625...@qq.com


诚信为本,如果不信任本人,可以走淘宝交易,收货验证后再付款,这是对您最好的保障了。 

保证每天都有买家回复。
保证每天都有买家回复。
保证每天都有买家回复。




广交会买家按产品类别分类,分为以下几类:
1 办公设备
2 编织及藤铁工艺品
3 玻璃
4 餐厨用具
5 车辆
6 大型机械及设备
7 电子电气
8 电子消费品
9 纺织
10 服装
11 个人护理
12 工程机械
13 工具
14 化工
15 计算机及通讯
16 家居用品
17 家居装饰
18 家具
19 家用电器
20 建筑及装饰材料
21 节日用品
22 礼品及赠品
23 摩托车
24 汽车配件
25 食品
26 陶瓷
27 铁石
28 玩具
29 卫浴
30 五金
31 小型机械
32 鞋
33 休闲用品
34 医疗
35 浴室产品
36 园林
37 照明产品
38 钟表眼镜
39 自行车
40 包


保证每天都有买家回复。
保证每天都有买家回复。
保证每天都有买家回复。
保证每天都有买家回复。
保证每天都有买家回复。


[PATCH 1/3] crypto: tcrypt: add ctr(twofish) speed test

2011-09-26 Thread Jussi Kivilinna
Signed-off-by: Jussi Kivilinna jussi.kivili...@mbnet.fi
---
 crypto/tcrypt.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index e353a28..fc35650 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -1039,6 +1039,10 @@ static int do_test(int m)
speed_template_16_24_32);
test_cipher_speed(cbc(twofish), DECRYPT, sec, NULL, 0,
speed_template_16_24_32);
+   test_cipher_speed(ctr(twofish), ENCRYPT, sec, NULL, 0,
+   speed_template_16_24_32);
+   test_cipher_speed(ctr(twofish), DECRYPT, sec, NULL, 0,
+   speed_template_16_24_32);
break;
 
case 203:

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] crypto: twofish-x86-asm: make assembler functions use twofish_ctx instead of crypto_tfm

2011-09-26 Thread Jussi Kivilinna
This needed by 3-way twofish patch to be able to easily use one block
assembler functions. As glue code is shared between i586/x86_64 apply
change to i586 assembler too. Also export assembler functions for
3-way parallel twofish module.

CC: Joachim Fritschi jfrits...@freenet.de
Signed-off-by: Jussi Kivilinna jussi.kivili...@mbnet.fi
---
 arch/x86/crypto/twofish-i586-asm_32.S   |   10 +-
 arch/x86/crypto/twofish-x86_64-asm_64.S |6 ++
 arch/x86/crypto/twofish_glue.c  |   12 
 3 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/arch/x86/crypto/twofish-i586-asm_32.S 
b/arch/x86/crypto/twofish-i586-asm_32.S
index 575331c..658af4b 100644
--- a/arch/x86/crypto/twofish-i586-asm_32.S
+++ b/arch/x86/crypto/twofish-i586-asm_32.S
@@ -26,7 +26,7 @@
 
 #define in_blk12  /* input byte array address parameter*/
 #define out_blk   8  /* output byte array address parameter*/
-#define tfm   4  /* Twofish context structure */
+#define ctx   4  /* Twofish context structure */
 
 #define a_offset   0
 #define b_offset   4
@@ -229,8 +229,8 @@ twofish_enc_blk:
push%esi
push%edi
 
-   mov tfm + 16(%esp), %ebp/* abuse the base pointer: set new base 
bointer to the crypto tfm */
-   add $crypto_tfm_ctx_offset, %ebp/* ctx address */
+   mov ctx + 16(%esp), %ebp/* abuse the base pointer: set new base
+* pointer to the ctx address */
mov in_blk+16(%esp),%edi/* input address in edi */
 
mov (%edi), %eax
@@ -285,8 +285,8 @@ twofish_dec_blk:
push%edi
 
 
-   mov tfm + 16(%esp), %ebp/* abuse the base pointer: set new base 
bointer to the crypto tfm */
-   add $crypto_tfm_ctx_offset, %ebp/* ctx address */
+   mov ctx + 16(%esp), %ebp/* abuse the base pointer: set new base
+* pointer to the ctx address */
mov in_blk+16(%esp),%edi/* input address in edi */
 
mov (%edi), %eax
diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S 
b/arch/x86/crypto/twofish-x86_64-asm_64.S
index 573aa10..7bcf3fc 100644
--- a/arch/x86/crypto/twofish-x86_64-asm_64.S
+++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
@@ -221,10 +221,9 @@
 twofish_enc_blk:
pushqR1
 
-   /* %rdi contains the crypto tfm address */
+   /* %rdi contains the ctx address */
/* %rsi contains the output address */
/* %rdx contains the input address */
-   add $crypto_tfm_ctx_offset, %rdi/* set ctx address */
/* ctx address is moved to free one non-rex register
as target for the 8bit high operations */
mov %rdi,   %r11
@@ -274,10 +273,9 @@ twofish_enc_blk:
 twofish_dec_blk:
pushqR1
 
-   /* %rdi contains the crypto tfm address */
+   /* %rdi contains the ctx address */
/* %rsi contains the output address */
/* %rdx contains the input address */
-   add $crypto_tfm_ctx_offset, %rdi/* set ctx address */
/* ctx address is moved to free one non-rex register
as target for the 8bit high operations */
mov %rdi,   %r11
diff --git a/arch/x86/crypto/twofish_glue.c b/arch/x86/crypto/twofish_glue.c
index cefaf8b..dc6b3fb 100644
--- a/arch/x86/crypto/twofish_glue.c
+++ b/arch/x86/crypto/twofish_glue.c
@@ -44,17 +44,21 @@
 #include linux/module.h
 #include linux/types.h
 
-asmlinkage void twofish_enc_blk(struct crypto_tfm *tfm, u8 *dst, const u8 
*src);
-asmlinkage void twofish_dec_blk(struct crypto_tfm *tfm, u8 *dst, const u8 
*src);
+asmlinkage void twofish_enc_blk(struct twofish_ctx *ctx, u8 *dst,
+   const u8 *src);
+EXPORT_SYMBOL_GPL(twofish_enc_blk);
+asmlinkage void twofish_dec_blk(struct twofish_ctx *ctx, u8 *dst,
+   const u8 *src);
+EXPORT_SYMBOL_GPL(twofish_dec_blk);
 
 static void twofish_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
 {
-   twofish_enc_blk(tfm, dst, src);
+   twofish_enc_blk(crypto_tfm_ctx(tfm), dst, src);
 }
 
 static void twofish_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
 {
-   twofish_dec_blk(tfm, dst, src);
+   twofish_dec_blk(crypto_tfm_ctx(tfm), dst, src);
 }
 
 static struct crypto_alg alg = {

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] crypto: twofish: add 3-way parallel x86_64 assembler implemention

2011-09-26 Thread Jussi Kivilinna
Patch adds 3-way parallel x86_64 assembly implementation of twofish as new
module. New assembler functions crypt data in three blocks chunks, improving
cipher performance on out-of-order CPUs.

Patch has been tested with tcrypt and automated filesystem tests.

Summary of the tcrypt benchmarks:

Twofish 3-way-asm vs twofish asm (128bit 8kb block ECB)
 encrypt: 1.3x speed
 decrypt: 1.3x speed

Twofish 3-way-asm vs twofish asm (128bit 8kb block CBC)
 encrypt: 1.07x speed
 decrypt: 1.4x speed

Twofish 3-way-asm vs twofish asm (128bit 8kb block CTR)
 encrypt: 1.4x speed

Twofish 3-way-asm vs AES asm (128bit 8kb block ECB)
 encrypt: 1.0x speed
 decrypt: 1.0x speed

Twofish 3-way-asm vs AES asm (128bit 8kb block CBC)
 encrypt: 0.84x speed
 decrypt: 1.09x speed

Twofish 3-way-asm vs AES asm (128bit 8kb block CTR)
 encrypt: 1.15x speed

Full output:
 http://koti.mbnet.fi/axh/kernel/crypto/tcrypt-speed-twofish-3way-asm-x86_64.txt
 http://koti.mbnet.fi/axh/kernel/crypto/tcrypt-speed-twofish-asm-x86_64.txt
 http://koti.mbnet.fi/axh/kernel/crypto/tcrypt-speed-aes-asm-x86_64.txt

Tests were run on:
 vendor_id  : AuthenticAMD
 cpu family : 16
 model  : 10
 model name : AMD Phenom(tm) II X6 1055T Processor

Also userspace test were run on:
 vendor_id  : GenuineIntel
 cpu family : 6
 model  : 15
 model name : Intel(R) Xeon(R) CPU   E7330  @ 2.40GHz
 stepping   : 11

Userspace test results:

Encryption/decryption of twofish 3-way vs x86_64-asm on AMD Phenom II:
 encrypt: 1.27x
 decrypt: 1.25x

Encryption/decryption of twofish 3-way vs x86_64-asm on Intel Xeon E7330:
 encrypt: 1.36x
 decrypt: 1.36x

Signed-off-by: Jussi Kivilinna jussi.kivili...@mbnet.fi
---
 arch/x86/crypto/Makefile |2 
 arch/x86/crypto/twofish-x86_64-asm_64-3way.S |  316 +
 arch/x86/crypto/twofish_glue_3way.c  |  472 ++
 crypto/Kconfig   |   20 +
 4 files changed, 810 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/crypto/twofish-x86_64-asm_64-3way.S
 create mode 100644 arch/x86/crypto/twofish_glue_3way.c

diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile
index 725addf..3537d4b 100644
--- a/arch/x86/crypto/Makefile
+++ b/arch/x86/crypto/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_CRYPTO_SALSA20_586) += salsa20-i586.o
 obj-$(CONFIG_CRYPTO_AES_X86_64) += aes-x86_64.o
 obj-$(CONFIG_CRYPTO_BLOWFISH_X86_64) += blowfish-x86_64.o
 obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o
+obj-$(CONFIG_CRYPTO_TWOFISH_X86_64_3WAY) += twofish-x86_64-3way.o
 obj-$(CONFIG_CRYPTO_SALSA20_X86_64) += salsa20-x86_64.o
 obj-$(CONFIG_CRYPTO_AES_NI_INTEL) += aesni-intel.o
 obj-$(CONFIG_CRYPTO_GHASH_CLMUL_NI_INTEL) += ghash-clmulni-intel.o
@@ -23,6 +24,7 @@ salsa20-i586-y := salsa20-i586-asm_32.o salsa20_glue.o
 aes-x86_64-y := aes-x86_64-asm_64.o aes_glue.o
 blowfish-x86_64-y := blowfish-x86_64-asm_64.o blowfish_glue.o
 twofish-x86_64-y := twofish-x86_64-asm_64.o twofish_glue.o
+twofish-x86_64-3way-y := twofish-x86_64-asm_64-3way.o twofish_glue_3way.o
 salsa20-x86_64-y := salsa20-x86_64-asm_64.o salsa20_glue.o
 
 aesni-intel-y := aesni-intel_asm.o aesni-intel_glue.o fpu.o
diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S 
b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
new file mode 100644
index 000..5b012a2
--- /dev/null
+++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
@@ -0,0 +1,316 @@
+/*
+ * Twofish Cipher 3-way parallel algorithm (x86_64)
+ *
+ * Copyright (C) 2011 Jussi Kivilinna jussi.kivili...@mbnet.fi
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
+ * USA
+ *
+ */
+
+.file twofish-x86_64-asm-3way.S
+.text
+
+/* structure of crypto context */
+#define s0 0
+#define s1 1024
+#define s2 2048
+#define s3 3072
+#define w  4096
+#define k  4128
+
+/**
+  3-way twofish
+ **/
+#define CTX %rdi
+#define RIO %rdx
+
+#define RAB0 %rax
+#define RAB1 %rbx
+#define RAB2 %rcx
+
+#define RAB0d %eax
+#define RAB1d %ebx
+#define RAB2d %ecx
+
+#define RAB0bh %ah
+#define RAB1bh %bh
+#define RAB2bh %ch
+
+#define RAB0bl %al
+#define RAB1bl %bl
+#define RAB2bl %cl
+
+#define RCD0 %r8
+#define RCD1 %r9
+#define RCD2 %r10

Re: [RFC v2.1 0/6] evm: digital signature verification extension

2011-09-26 Thread James Morris
On Mon, 26 Sep 2011, Kasatkin, Dmitry wrote:

 It seems nobody wants to share their thoughts about it?
 Does this silence mean acceptance?
 Should I prepare final patches for merge?

Not yet.

I'd like to hear what the crypto folk think about the crypto.

-- 
James Morris
jmor...@namei.org
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 00/17] crypto user configuration api

2011-09-26 Thread Steffen Klassert
This patchset adds a netlink based user configuration API for the crypto
layer, similar to the configuration API of xfrm.

The patchset is based on the current cryptodev tree.

A userspace tool that makes use of the configuration API is available at

https://sourceforge.net/projects/crconf/files/crconf-pre2.tar.gz

With this it is possible to instantiate certain algorithms by doing

crconf add driver cbc(aes-generic) type 4

or

crconf add driver cbc(aes-generic) type 4 priority 100

To remove a (form templates build and unused) algorithm with all subsequent
algorithms do

crconf del driver cbc(aes-generic) type 4

It is possible to update the priority of an algorithm by doing

crconf update driver cbc(aes-generic) type 4 priority 200

this updates the priority of this algorithm and removes all algorithms
on top.

Finally it is possible to print the instantiated crypto algorithms
similar to /proc/crypto by doing

crconf show all

This prints the algorithm informations of all instantiated algorithms
as long as the information fits into a netlink message.

Changes from v1:

- Removed the priority update functions.
- Fix algorithm information printing when build as module.
- Update the crconf tool according to the kernel changes.

Changes from v2:

- Use one structure for creating and basic querying of algorithms.
- Send the algorithm flags to userspace, so the userspace can
  check for things like passed selftest, async algorithms etc.
- Update the crconf tool according to the kernel changes.
- Add some priority update functions. We need to be able to update
  the priority of algorithms, as we can't delete core algorithms like
  aes-generic. When we update the priority of an algorithm, we remove
  all algorithms on top.

Changes from v3:

- Remove the priority field from struct crypto_user_alg and use the
  existing netlink attribute to send the priority value to userspace.
- Update the crconf tool according to the kernel changes.
- Don't distinguish between netlink attributes that use the same
  type value.

Steffen
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 01/17] crypto: Add a flag to identify crypto instances

2011-09-26 Thread Steffen Klassert
The upcomming crypto user configuration api needs to identify
crypto instances. This patch adds a flag that is set if the
algorithm is an instance that is build from templates.

Signed-off-by: Steffen Klassert steffen.klass...@secunet.com
---
 crypto/algapi.c|1 +
 include/linux/crypto.h |5 +
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/crypto/algapi.c b/crypto/algapi.c
index c3cf1a6..6fd9bcf 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -493,6 +493,7 @@ int crypto_register_instance(struct crypto_template *tmpl,
goto err;
 
inst-alg.cra_module = tmpl-module;
+   inst-alg.cra_flags |= CRYPTO_ALG_INSTANCE;
 
down_write(crypto_alg_sem);
 
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index e5e468e..de9adec 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -72,6 +72,11 @@
 #define CRYPTO_ALG_TESTED  0x0400
 
 /*
+ * Set if the algorithm is an instance that is build from templates.
+ */
+#define CRYPTO_ALG_INSTANCE0x0800
+
+/*
  * Transform masks and values (for crt_flags).
  */
 #define CRYPTO_TFM_REQ_MASK0x000fff00
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 03/17] crypto: Export crypto_remove_final

2011-09-26 Thread Steffen Klassert
The upcomming crypto usrerspace configuration api needs
to remove the spawns on top on an algorithm, so export
crypto_remove_final.

Signed-off-by: Steffen Klassert steffen.klass...@secunet.com
---
 crypto/algapi.c   |5 ++---
 crypto/internal.h |1 +
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/algapi.c b/crypto/algapi.c
index 1b54d74..54dd4e3 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -22,8 +22,6 @@
 
 #include internal.h
 
-static void crypto_remove_final(struct list_head *list);
-
 static LIST_HEAD(crypto_template_list);
 
 void crypto_larval_error(const char *name, u32 type, u32 mask)
@@ -321,7 +319,7 @@ unlock:
 }
 EXPORT_SYMBOL_GPL(crypto_alg_tested);
 
-static void crypto_remove_final(struct list_head *list)
+void crypto_remove_final(struct list_head *list)
 {
struct crypto_alg *alg;
struct crypto_alg *n;
@@ -331,6 +329,7 @@ static void crypto_remove_final(struct list_head *list)
crypto_alg_put(alg);
}
 }
+EXPORT_SYMBOL_GPL(crypto_remove_final);
 
 static void crypto_wait_for_test(struct crypto_larval *larval)
 {
diff --git a/crypto/internal.h b/crypto/internal.h
index b6dcb31..b865ca1 100644
--- a/crypto/internal.h
+++ b/crypto/internal.h
@@ -88,6 +88,7 @@ void crypto_alg_tested(const char *name, int err);
 
 void crypto_remove_spawns(struct crypto_alg *alg, struct list_head *list,
  struct crypto_alg *nalg);
+void crypto_remove_final(struct list_head *list);
 void crypto_shoot_alg(struct crypto_alg *alg);
 struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
  u32 mask);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 04/17] crypto: Add userspace configuration API

2011-09-26 Thread Steffen Klassert
This patch adds a basic userspace configuration API for the crypto layer.
With this it is possible to instantiate, remove and to show crypto
algorithms from userspace.

Signed-off-by: Steffen Klassert steffen.klass...@secunet.com
---
 crypto/Kconfig |7 +
 crypto/Makefile|1 +
 crypto/crypto_user.c   |  372 
 include/linux/cryptouser.h |   52 ++
 include/linux/netlink.h|1 +
 5 files changed, 433 insertions(+), 0 deletions(-)
 create mode 100644 crypto/crypto_user.c
 create mode 100644 include/linux/cryptouser.h

diff --git a/crypto/Kconfig b/crypto/Kconfig
index 0763774..0bf53f4 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -100,6 +100,13 @@ config CRYPTO_MANAGER2
select CRYPTO_BLKCIPHER2
select CRYPTO_PCOMP2
 
+config CRYPTO_USER
+   tristate Userspace cryptographic algorithm configuration
+   select CRYPTO_MANAGER
+   help
+ Userapace configuration for cryptographic instantiations such as
+ cbc(aes).
+
 config CRYPTO_MANAGER_DISABLE_TESTS
bool Disable run-time self tests
default y
diff --git a/crypto/Makefile b/crypto/Makefile
index fa8cbbb..9e6eee2 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_CRYPTO_PCOMP2) += pcompress.o
 cryptomgr-y := algboss.o testmgr.o
 
 obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
+obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
 obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
 obj-$(CONFIG_CRYPTO_VMAC) += vmac.o
 obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
new file mode 100644
index 000..513cfe7
--- /dev/null
+++ b/crypto/crypto_user.c
@@ -0,0 +1,372 @@
+/*
+ * Crypto user configuration API.
+ *
+ * Copyright (C) 2011 secunet Security Networks AG
+ * Copyright (C) 2011 Steffen Klassert steffen.klass...@secunet.com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include linux/module.h
+#include linux/crypto.h
+#include linux/cryptouser.h
+#include net/netlink.h
+#include linux/security.h
+#include net/net_namespace.h
+#include internal.h
+
+DEFINE_MUTEX(crypto_cfg_mutex);
+
+/* The crypto netlink socket */
+static struct sock *crypto_nlsk;
+
+struct crypto_dump_info {
+   struct sk_buff *in_skb;
+   struct sk_buff *out_skb;
+   u32 nlmsg_seq;
+   u16 nlmsg_flags;
+};
+
+static struct crypto_alg *crypto_alg_match(struct crypto_user_alg *p, int 
exact)
+{
+   int match;
+   struct crypto_alg *q, *alg = NULL;
+
+   down_read(crypto_alg_sem);
+
+   if (list_empty(crypto_alg_list))
+   return NULL;
+
+   list_for_each_entry(q, crypto_alg_list, cra_list) {
+
+   if ((q-cra_flags ^ p-cru_type)  p-cru_mask)
+   continue;
+
+   if (strlen(p-cru_driver_name))
+   match = !strcmp(q-cra_driver_name,
+   p-cru_driver_name);
+   else if (!exact)
+   match = !strcmp(q-cra_name, p-cru_name);
+
+   if (match) {
+   alg = q;
+   break;
+   }
+   }
+
+   up_read(crypto_alg_sem);
+
+   return alg;
+}
+
+static int crypto_report_one(struct crypto_alg *alg,
+struct crypto_user_alg *ualg, struct sk_buff *skb)
+{
+   memcpy(ualg-cru_name, alg-cra_name, sizeof(ualg-cru_name));
+   memcpy(ualg-cru_driver_name, alg-cra_driver_name,
+  sizeof(ualg-cru_driver_name));
+   memcpy(ualg-cru_module_name, module_name(alg-cra_module),
+  CRYPTO_MAX_ALG_NAME);
+
+   ualg-cru_flags = alg-cra_flags;
+   ualg-cru_refcnt = atomic_read(alg-cra_refcnt);
+
+   NLA_PUT_U32(skb, CRYPTOCFGA_PRIORITY_VAL, alg-cra_priority);
+
+   return 0;
+
+nla_put_failure:
+   return -EMSGSIZE;
+}
+
+static int crypto_report_alg(struct crypto_alg *alg,
+struct crypto_dump_info *info)
+{
+   struct sk_buff *in_skb = info-in_skb;
+   struct sk_buff *skb = info-out_skb;
+   struct nlmsghdr *nlh;
+   struct crypto_user_alg *ualg;
+   int err = 0;
+
+   nlh = nlmsg_put(skb, NETLINK_CB(in_skb).pid, info-nlmsg_seq,
+   CRYPTO_MSG_GETALG, sizeof(*ualg), info-nlmsg_flags);
+   if (!nlh) {
+ 

[PATCH v4 05/17] crypto: Add a report function pointer to crypto_type

2011-09-26 Thread Steffen Klassert
We add a report function pointer to struct crypto_type. This function
pointer is used from the crypto userspace configuration API to report
crypto algorithms to userspace.

Signed-off-by: Steffen Klassert steffen.klass...@secunet.com
---
 crypto/crypto_user.c|5 +
 include/crypto/algapi.h |2 ++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
index 513cfe7..aa67c74 100644
--- a/crypto/crypto_user.c
+++ b/crypto/crypto_user.c
@@ -84,6 +84,11 @@ static int crypto_report_one(struct crypto_alg *alg,
 
NLA_PUT_U32(skb, CRYPTOCFGA_PRIORITY_VAL, alg-cra_priority);
 
+   if (alg-cra_type  alg-cra_type-report) {
+   if (alg-cra_type-report(skb, alg))
+   goto nla_put_failure;
+   }
+
return 0;
 
 nla_put_failure:
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index 59c3e5b..ecc721d 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -15,6 +15,7 @@
 #include linux/crypto.h
 #include linux/list.h
 #include linux/kernel.h
+#include linux/skbuff.h
 
 struct module;
 struct rtattr;
@@ -26,6 +27,7 @@ struct crypto_type {
int (*init)(struct crypto_tfm *tfm, u32 type, u32 mask);
int (*init_tfm)(struct crypto_tfm *tfm);
void (*show)(struct seq_file *m, struct crypto_alg *alg);
+   int (*report)(struct sk_buff *skb, struct crypto_alg *alg);
struct crypto_alg *(*lookup)(const char *name, u32 type, u32 mask);
 
unsigned int type;
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 06/17] crypto: Add userspace report for larval type algorithms

2011-09-26 Thread Steffen Klassert

Signed-off-by: Steffen Klassert steffen.klass...@secunet.com
---
 crypto/crypto_user.c   |   12 
 include/linux/cryptouser.h |5 +
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
index aa67c74..8a0c5c6 100644
--- a/crypto/crypto_user.c
+++ b/crypto/crypto_user.c
@@ -84,11 +84,23 @@ static int crypto_report_one(struct crypto_alg *alg,
 
NLA_PUT_U32(skb, CRYPTOCFGA_PRIORITY_VAL, alg-cra_priority);
 
+   if (alg-cra_flags  CRYPTO_ALG_LARVAL) {
+   struct crypto_report_larval rl;
+
+   snprintf(rl.type, CRYPTO_MAX_ALG_NAME, %s, larval);
+
+   NLA_PUT(skb, CRYPTOCFGA_REPORT_LARVAL,
+   sizeof(struct crypto_report_larval), rl);
+
+   goto out;
+   }
+
if (alg-cra_type  alg-cra_type-report) {
if (alg-cra_type-report(skb, alg))
goto nla_put_failure;
}
 
+out:
return 0;
 
 nla_put_failure:
diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h
index b874e38..7a849b4 100644
--- a/include/linux/cryptouser.h
+++ b/include/linux/cryptouser.h
@@ -36,6 +36,7 @@ enum {
 enum crypto_attr_type_t {
CRYPTOCFGA_UNSPEC,
CRYPTOCFGA_PRIORITY_VAL,/* __u32 */
+   CRYPTOCFGA_REPORT_LARVAL,   /* struct crypto_report_larval */
__CRYPTOCFGA_MAX
 
 #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1)
@@ -50,3 +51,7 @@ struct crypto_user_alg {
__u32 cru_refcnt;
__u32 cru_flags;
 };
+
+struct crypto_report_larval {
+   char type[CRYPTO_MAX_NAME];
+};
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] whirlpool: count rounds from 0

2011-09-26 Thread Alexey Dobriyan
rc[0] is unused because rounds are counted from 1.
Save an u64!

Signed-off-by: Alexey Dobriyan adobri...@gmail.com
---

 crypto/wp512.c |   18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

--- a/crypto/wp512.c
+++ b/crypto/wp512.c
@@ -762,11 +762,17 @@ static const u64 C7[256] = {
0x86228644a411c286ULL,
 };
 
-static const u64 rc[WHIRLPOOL_ROUNDS + 1] = {
-   0xULL, 0x1823c6e887b8014fULL, 0x36a6d2f5796f9152ULL,
-   0x60bc9b8ea30c7b35ULL, 0x1de0d7c22e4bfe57ULL, 0x157737e59ff04adaULL,
-   0x58c9290ab1a06b85ULL, 0xbd5d10f4cb3e0567ULL, 0xe427418ba77d95d8ULL,
-   0xfbee7c66dd17479eULL, 0xca2dbf07ad5a8333ULL,
+static const u64 rc[WHIRLPOOL_ROUNDS] = {
+   0x1823c6e887b8014fULL,
+   0x36a6d2f5796f9152ULL,
+   0x60bc9b8ea30c7b35ULL,
+   0x1de0d7c22e4bfe57ULL,
+   0x157737e59ff04adaULL,
+   0x58c9290ab1a06b85ULL,
+   0xbd5d10f4cb3e0567ULL,
+   0xe427418ba77d95d8ULL,
+   0xfbee7c66dd17479eULL,
+   0xca2dbf07ad5a8333ULL,
 };
 
 /**
@@ -793,7 +799,7 @@ static void wp512_process_buffer(struct wp512_ctx *wctx) {
state[6] = block[6] ^ (K[6] = wctx-hash[6]);
state[7] = block[7] ^ (K[7] = wctx-hash[7]);
 
-   for (r = 1; r = WHIRLPOOL_ROUNDS; r++) {
+   for (r = 0; r  WHIRLPOOL_ROUNDS; r++) {
 
L[0] = C0[(int)(K[0]  56)   ] ^
   C1[(int)(K[7]  48)  0xff] ^
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 08/17] crypto: Add userspace report for ahash type algorithms

2011-09-26 Thread Steffen Klassert

Signed-off-by: Steffen Klassert steffen.klass...@secunet.com
---
 crypto/ahash.c |   21 +
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/crypto/ahash.c b/crypto/ahash.c
index f669822..a3e6ef9 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -21,6 +21,8 @@
 #include linux/sched.h
 #include linux/slab.h
 #include linux/seq_file.h
+#include linux/cryptouser.h
+#include net/netlink.h
 
 #include internal.h
 
@@ -397,6 +399,24 @@ static unsigned int crypto_ahash_extsize(struct crypto_alg 
*alg)
return sizeof(struct crypto_shash *);
 }
 
+static int crypto_ahash_report(struct sk_buff *skb, struct crypto_alg *alg)
+{
+   struct crypto_report_hash rhash;
+
+   snprintf(rhash.type, CRYPTO_MAX_ALG_NAME, %s, ahash);
+
+   rhash.blocksize = alg-cra_blocksize;
+   rhash.digestsize = __crypto_hash_alg_common(alg)-digestsize;
+
+   NLA_PUT(skb, CRYPTOCFGA_REPORT_HASH,
+   sizeof(struct crypto_report_hash), rhash);
+
+   return 0;
+
+nla_put_failure:
+   return -EMSGSIZE;
+}
+
 static void crypto_ahash_show(struct seq_file *m, struct crypto_alg *alg)
__attribute__ ((unused));
 static void crypto_ahash_show(struct seq_file *m, struct crypto_alg *alg)
@@ -415,6 +435,7 @@ const struct crypto_type crypto_ahash_type = {
 #ifdef CONFIG_PROC_FS
.show = crypto_ahash_show,
 #endif
+   .report = crypto_ahash_report,
.maskclear = ~CRYPTO_ALG_TYPE_MASK,
.maskset = CRYPTO_ALG_TYPE_AHASH_MASK,
.type = CRYPTO_ALG_TYPE_AHASH,
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 09/17] crypto: Add userspace report for blkcipher type algorithms

2011-09-26 Thread Steffen Klassert

Signed-off-by: Steffen Klassert steffen.klass...@secunet.com
---
 crypto/blkcipher.c |   25 +
 include/linux/cryptouser.h |   10 ++
 2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
index 7a72192..2572d26 100644
--- a/crypto/blkcipher.c
+++ b/crypto/blkcipher.c
@@ -24,6 +24,8 @@
 #include linux/seq_file.h
 #include linux/slab.h
 #include linux/string.h
+#include linux/cryptouser.h
+#include net/netlink.h
 
 #include internal.h
 
@@ -492,6 +494,28 @@ static int crypto_init_blkcipher_ops(struct crypto_tfm 
*tfm, u32 type, u32 mask)
return crypto_init_blkcipher_ops_async(tfm);
 }
 
+static int crypto_blkcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
+{
+   struct crypto_report_blkcipher rblkcipher;
+
+   snprintf(rblkcipher.type, CRYPTO_MAX_ALG_NAME, %s, blkcipher);
+   snprintf(rblkcipher.geniv, CRYPTO_MAX_ALG_NAME, %s,
+alg-cra_blkcipher.geniv ?: default);
+
+   rblkcipher.blocksize = alg-cra_blocksize;
+   rblkcipher.min_keysize = alg-cra_blkcipher.min_keysize;
+   rblkcipher.max_keysize = alg-cra_blkcipher.max_keysize;
+   rblkcipher.ivsize = alg-cra_blkcipher.ivsize;
+
+   NLA_PUT(skb, CRYPTOCFGA_REPORT_BLKCIPHER,
+   sizeof(struct crypto_report_blkcipher), rblkcipher);
+
+   return 0;
+
+nla_put_failure:
+   return -EMSGSIZE;
+}
+
 static void crypto_blkcipher_show(struct seq_file *m, struct crypto_alg *alg)
__attribute__ ((unused));
 static void crypto_blkcipher_show(struct seq_file *m, struct crypto_alg *alg)
@@ -511,6 +535,7 @@ const struct crypto_type crypto_blkcipher_type = {
 #ifdef CONFIG_PROC_FS
.show = crypto_blkcipher_show,
 #endif
+   .report = crypto_blkcipher_report,
 };
 EXPORT_SYMBOL_GPL(crypto_blkcipher_type);
 
diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h
index ee46882..a96a1a1 100644
--- a/include/linux/cryptouser.h
+++ b/include/linux/cryptouser.h
@@ -38,6 +38,7 @@ enum crypto_attr_type_t {
CRYPTOCFGA_PRIORITY_VAL,/* __u32 */
CRYPTOCFGA_REPORT_LARVAL,   /* struct crypto_report_larval */
CRYPTOCFGA_REPORT_HASH, /* struct crypto_report_hash */
+   CRYPTOCFGA_REPORT_BLKCIPHER,/* struct crypto_report_blkcipher */
__CRYPTOCFGA_MAX
 
 #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1)
@@ -62,3 +63,12 @@ struct crypto_report_hash {
unsigned int blocksize;
unsigned int digestsize;
 };
+
+struct crypto_report_blkcipher {
+   char type[CRYPTO_MAX_NAME];
+   char geniv[CRYPTO_MAX_NAME];
+   unsigned int blocksize;
+   unsigned int min_keysize;
+   unsigned int max_keysize;
+   unsigned int ivsize;
+};
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 11/17] crypto: Add userspace report for givcipher type algorithms

2011-09-26 Thread Steffen Klassert

Signed-off-by: Steffen Klassert steffen.klass...@secunet.com
---
 crypto/ablkcipher.c |   23 +++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c
index 5ea49ad..a816f24 100644
--- a/crypto/ablkcipher.c
+++ b/crypto/ablkcipher.c
@@ -457,6 +457,28 @@ static int crypto_init_givcipher_ops(struct crypto_tfm 
*tfm, u32 type,
return 0;
 }
 
+static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
+{
+   struct crypto_report_blkcipher rblkcipher;
+
+   snprintf(rblkcipher.type, CRYPTO_MAX_ALG_NAME, %s, givcipher);
+   snprintf(rblkcipher.geniv, CRYPTO_MAX_ALG_NAME, %s,
+alg-cra_ablkcipher.geniv ?: built-in);
+
+   rblkcipher.blocksize = alg-cra_blocksize;
+   rblkcipher.min_keysize = alg-cra_ablkcipher.min_keysize;
+   rblkcipher.max_keysize = alg-cra_ablkcipher.max_keysize;
+   rblkcipher.ivsize = alg-cra_ablkcipher.ivsize;
+
+   NLA_PUT(skb, CRYPTOCFGA_REPORT_BLKCIPHER,
+   sizeof(struct crypto_report_blkcipher), rblkcipher);
+
+   return 0;
+
+nla_put_failure:
+   return -EMSGSIZE;
+}
+
 static void crypto_givcipher_show(struct seq_file *m, struct crypto_alg *alg)
__attribute__ ((unused));
 static void crypto_givcipher_show(struct seq_file *m, struct crypto_alg *alg)
@@ -479,6 +501,7 @@ const struct crypto_type crypto_givcipher_type = {
 #ifdef CONFIG_PROC_FS
.show = crypto_givcipher_show,
 #endif
+   .report = crypto_givcipher_report,
 };
 EXPORT_SYMBOL_GPL(crypto_givcipher_type);
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 12/17] crypto: Add userspace report for aead type algorithms

2011-09-26 Thread Steffen Klassert

Signed-off-by: Steffen Klassert steffen.klass...@secunet.com
---
 crypto/aead.c  |   25 +
 include/linux/cryptouser.h |9 +
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/crypto/aead.c b/crypto/aead.c
index 6729e8f..bb641bd 100644
--- a/crypto/aead.c
+++ b/crypto/aead.c
@@ -21,6 +21,8 @@
 #include linux/sched.h
 #include linux/slab.h
 #include linux/seq_file.h
+#include linux/cryptouser.h
+#include net/netlink.h
 
 #include internal.h
 
@@ -109,6 +111,28 @@ static int crypto_init_aead_ops(struct crypto_tfm *tfm, 
u32 type, u32 mask)
return 0;
 }
 
+static int crypto_aead_report(struct sk_buff *skb, struct crypto_alg *alg)
+{
+   struct crypto_report_aead raead;
+   struct aead_alg *aead = alg-cra_aead;
+
+   snprintf(raead.type, CRYPTO_MAX_ALG_NAME, %s, aead);
+   snprintf(raead.geniv, CRYPTO_MAX_ALG_NAME, %s,
+aead-geniv ?: built-in);
+
+   raead.blocksize = alg-cra_blocksize;
+   raead.maxauthsize = aead-maxauthsize;
+   raead.ivsize = aead-ivsize;
+
+   NLA_PUT(skb, CRYPTOCFGA_REPORT_AEAD,
+   sizeof(struct crypto_report_aead), raead);
+
+   return 0;
+
+nla_put_failure:
+   return -EMSGSIZE;
+}
+
 static void crypto_aead_show(struct seq_file *m, struct crypto_alg *alg)
__attribute__ ((unused));
 static void crypto_aead_show(struct seq_file *m, struct crypto_alg *alg)
@@ -130,6 +154,7 @@ const struct crypto_type crypto_aead_type = {
 #ifdef CONFIG_PROC_FS
.show = crypto_aead_show,
 #endif
+   .report = crypto_aead_report,
 };
 EXPORT_SYMBOL_GPL(crypto_aead_type);
 
diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h
index a96a1a1..48030c7 100644
--- a/include/linux/cryptouser.h
+++ b/include/linux/cryptouser.h
@@ -39,6 +39,7 @@ enum crypto_attr_type_t {
CRYPTOCFGA_REPORT_LARVAL,   /* struct crypto_report_larval */
CRYPTOCFGA_REPORT_HASH, /* struct crypto_report_hash */
CRYPTOCFGA_REPORT_BLKCIPHER,/* struct crypto_report_blkcipher */
+   CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */
__CRYPTOCFGA_MAX
 
 #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1)
@@ -72,3 +73,11 @@ struct crypto_report_blkcipher {
unsigned int max_keysize;
unsigned int ivsize;
 };
+
+struct crypto_report_aead {
+   char type[CRYPTO_MAX_NAME];
+   char geniv[CRYPTO_MAX_NAME];
+   unsigned int blocksize;
+   unsigned int maxauthsize;
+   unsigned int ivsize;
+};
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 13/17] crypto: Add userspace report for nivaead type algorithms

2011-09-26 Thread Steffen Klassert

Signed-off-by: Steffen Klassert steffen.klass...@secunet.com
---
 crypto/aead.c |   23 +++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/crypto/aead.c b/crypto/aead.c
index bb641bd..701556f 100644
--- a/crypto/aead.c
+++ b/crypto/aead.c
@@ -190,6 +190,28 @@ static int crypto_init_nivaead_ops(struct crypto_tfm *tfm, 
u32 type, u32 mask)
return 0;
 }
 
+static int crypto_nivaead_report(struct sk_buff *skb, struct crypto_alg *alg)
+{
+   struct crypto_report_aead raead;
+   struct aead_alg *aead = alg-cra_aead;
+
+   snprintf(raead.type, CRYPTO_MAX_ALG_NAME, %s, nivaead);
+   snprintf(raead.geniv, CRYPTO_MAX_ALG_NAME, %s, aead-geniv);
+
+   raead.blocksize = alg-cra_blocksize;
+   raead.maxauthsize = aead-maxauthsize;
+   raead.ivsize = aead-ivsize;
+
+   NLA_PUT(skb, CRYPTOCFGA_REPORT_AEAD,
+   sizeof(struct crypto_report_aead), raead);
+
+   return 0;
+
+nla_put_failure:
+   return -EMSGSIZE;
+}
+
+
 static void crypto_nivaead_show(struct seq_file *m, struct crypto_alg *alg)
__attribute__ ((unused));
 static void crypto_nivaead_show(struct seq_file *m, struct crypto_alg *alg)
@@ -211,6 +233,7 @@ const struct crypto_type crypto_nivaead_type = {
 #ifdef CONFIG_PROC_FS
.show = crypto_nivaead_show,
 #endif
+   .report = crypto_nivaead_report,
 };
 EXPORT_SYMBOL_GPL(crypto_nivaead_type);
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 14/17] crypto: Add userspace report for pcompress type algorithms

2011-09-26 Thread Steffen Klassert

Signed-off-by: Steffen Klassert steffen.klass...@secunet.com
---
 crypto/pcompress.c |   18 ++
 include/linux/cryptouser.h |5 +
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/crypto/pcompress.c b/crypto/pcompress.c
index f7c4a7d..fefda78 100644
--- a/crypto/pcompress.c
+++ b/crypto/pcompress.c
@@ -24,6 +24,8 @@
 #include linux/module.h
 #include linux/seq_file.h
 #include linux/string.h
+#include linux/cryptouser.h
+#include net/netlink.h
 
 #include crypto/compress.h
 #include crypto/internal/compress.h
@@ -46,6 +48,21 @@ static int crypto_pcomp_init_tfm(struct crypto_tfm *tfm)
return 0;
 }
 
+static int crypto_pcomp_report(struct sk_buff *skb, struct crypto_alg *alg)
+{
+   struct crypto_report_comp rpcomp;
+
+   snprintf(rpcomp.type, CRYPTO_MAX_ALG_NAME, %s, pcomp);
+
+   NLA_PUT(skb, CRYPTOCFGA_REPORT_COMPRESS,
+   sizeof(struct crypto_report_comp), rpcomp);
+
+   return 0;
+
+nla_put_failure:
+   return -EMSGSIZE;
+}
+
 static void crypto_pcomp_show(struct seq_file *m, struct crypto_alg *alg)
__attribute__ ((unused));
 static void crypto_pcomp_show(struct seq_file *m, struct crypto_alg *alg)
@@ -60,6 +77,7 @@ static const struct crypto_type crypto_pcomp_type = {
 #ifdef CONFIG_PROC_FS
.show   = crypto_pcomp_show,
 #endif
+   .report = crypto_pcomp_report,
.maskclear  = ~CRYPTO_ALG_TYPE_MASK,
.maskset= CRYPTO_ALG_TYPE_MASK,
.type   = CRYPTO_ALG_TYPE_PCOMPRESS,
diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h
index 48030c7..c8c1dfc 100644
--- a/include/linux/cryptouser.h
+++ b/include/linux/cryptouser.h
@@ -40,6 +40,7 @@ enum crypto_attr_type_t {
CRYPTOCFGA_REPORT_HASH, /* struct crypto_report_hash */
CRYPTOCFGA_REPORT_BLKCIPHER,/* struct crypto_report_blkcipher */
CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */
+   CRYPTOCFGA_REPORT_COMPRESS, /* struct crypto_report_comp */
__CRYPTOCFGA_MAX
 
 #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1)
@@ -81,3 +82,7 @@ struct crypto_report_aead {
unsigned int maxauthsize;
unsigned int ivsize;
 };
+
+struct crypto_report_comp {
+   char type[CRYPTO_MAX_NAME];
+};
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 15/17] crypto: Add userspace report for rng type algorithms

2011-09-26 Thread Steffen Klassert

Signed-off-by: Steffen Klassert steffen.klass...@secunet.com
---
 crypto/rng.c   |   20 
 include/linux/cryptouser.h |6 ++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/crypto/rng.c b/crypto/rng.c
index 45229ae..feb7de0 100644
--- a/crypto/rng.c
+++ b/crypto/rng.c
@@ -21,6 +21,8 @@
 #include linux/seq_file.h
 #include linux/slab.h
 #include linux/string.h
+#include linux/cryptouser.h
+#include net/netlink.h
 
 static DEFINE_MUTEX(crypto_default_rng_lock);
 struct crypto_rng *crypto_default_rng;
@@ -58,6 +60,23 @@ static int crypto_init_rng_ops(struct crypto_tfm *tfm, u32 
type, u32 mask)
return 0;
 }
 
+static int crypto_rng_report(struct sk_buff *skb, struct crypto_alg *alg)
+{
+   struct crypto_report_rng rrng;
+
+   snprintf(rrng.type, CRYPTO_MAX_ALG_NAME, %s, rng);
+
+   rrng.seedsize = alg-cra_rng.seedsize;
+
+   NLA_PUT(skb, CRYPTOCFGA_REPORT_RNG,
+   sizeof(struct crypto_report_rng), rrng);
+
+   return 0;
+
+nla_put_failure:
+   return -EMSGSIZE;
+}
+
 static void crypto_rng_show(struct seq_file *m, struct crypto_alg *alg)
__attribute__ ((unused));
 static void crypto_rng_show(struct seq_file *m, struct crypto_alg *alg)
@@ -78,6 +97,7 @@ const struct crypto_type crypto_rng_type = {
 #ifdef CONFIG_PROC_FS
.show = crypto_rng_show,
 #endif
+   .report = crypto_rng_report,
 };
 EXPORT_SYMBOL_GPL(crypto_rng_type);
 
diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h
index c8c1dfc..ed8a40e 100644
--- a/include/linux/cryptouser.h
+++ b/include/linux/cryptouser.h
@@ -41,6 +41,7 @@ enum crypto_attr_type_t {
CRYPTOCFGA_REPORT_BLKCIPHER,/* struct crypto_report_blkcipher */
CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */
CRYPTOCFGA_REPORT_COMPRESS, /* struct crypto_report_comp */
+   CRYPTOCFGA_REPORT_RNG,  /* struct crypto_report_rng */
__CRYPTOCFGA_MAX
 
 #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1)
@@ -86,3 +87,8 @@ struct crypto_report_aead {
 struct crypto_report_comp {
char type[CRYPTO_MAX_NAME];
 };
+
+struct crypto_report_rng {
+   char type[CRYPTO_MAX_NAME];
+   unsigned int seedsize;
+};
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 16/17] crypto: Add userspace report for cipher type algorithms

2011-09-26 Thread Steffen Klassert

Signed-off-by: Steffen Klassert steffen.klass...@secunet.com
---
 crypto/crypto_user.c   |   29 +
 include/linux/cryptouser.h |8 
 2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
index 8a0c5c6..52459ae 100644
--- a/crypto/crypto_user.c
+++ b/crypto/crypto_user.c
@@ -70,6 +70,25 @@ static struct crypto_alg *crypto_alg_match(struct 
crypto_user_alg *p, int exact)
return alg;
 }
 
+static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg)
+{
+   struct crypto_report_cipher rcipher;
+
+   snprintf(rcipher.type, CRYPTO_MAX_ALG_NAME, %s, cipher);
+
+   rcipher.blocksize = alg-cra_blocksize;
+   rcipher.min_keysize = alg-cra_cipher.cia_min_keysize;
+   rcipher.max_keysize = alg-cra_cipher.cia_max_keysize;
+
+   NLA_PUT(skb, CRYPTOCFGA_REPORT_CIPHER,
+   sizeof(struct crypto_report_cipher), rcipher);
+
+   return 0;
+
+nla_put_failure:
+   return -EMSGSIZE;
+}
+
 static int crypto_report_one(struct crypto_alg *alg,
 struct crypto_user_alg *ualg, struct sk_buff *skb)
 {
@@ -98,6 +117,16 @@ static int crypto_report_one(struct crypto_alg *alg,
if (alg-cra_type  alg-cra_type-report) {
if (alg-cra_type-report(skb, alg))
goto nla_put_failure;
+
+   goto out;
+   }
+
+   switch (alg-cra_flags  (CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL)) {
+   case CRYPTO_ALG_TYPE_CIPHER:
+   if (crypto_report_cipher(skb, alg))
+   goto nla_put_failure;
+
+   break;
}
 
 out:
diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h
index ed8a40e..532fb58 100644
--- a/include/linux/cryptouser.h
+++ b/include/linux/cryptouser.h
@@ -42,6 +42,7 @@ enum crypto_attr_type_t {
CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */
CRYPTOCFGA_REPORT_COMPRESS, /* struct crypto_report_comp */
CRYPTOCFGA_REPORT_RNG,  /* struct crypto_report_rng */
+   CRYPTOCFGA_REPORT_CIPHER,   /* struct crypto_report_cipher */
__CRYPTOCFGA_MAX
 
 #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1)
@@ -67,6 +68,13 @@ struct crypto_report_hash {
unsigned int digestsize;
 };
 
+struct crypto_report_cipher {
+   char type[CRYPTO_MAX_ALG_NAME];
+   unsigned int blocksize;
+   unsigned int min_keysize;
+   unsigned int max_keysize;
+};
+
 struct crypto_report_blkcipher {
char type[CRYPTO_MAX_NAME];
char geniv[CRYPTO_MAX_NAME];
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 17/17] crypto: Add userspace report for compress type algorithms

2011-09-26 Thread Steffen Klassert

Signed-off-by: Steffen Klassert steffen.klass...@secunet.com
---
 crypto/crypto_user.c |   20 
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
index 52459ae..748990f 100644
--- a/crypto/crypto_user.c
+++ b/crypto/crypto_user.c
@@ -89,6 +89,21 @@ nla_put_failure:
return -EMSGSIZE;
 }
 
+static int crypto_report_comp(struct sk_buff *skb, struct crypto_alg *alg)
+{
+   struct crypto_report_comp rcomp;
+
+   snprintf(rcomp.type, CRYPTO_MAX_ALG_NAME, %s, compression);
+
+   NLA_PUT(skb, CRYPTOCFGA_REPORT_COMPRESS,
+   sizeof(struct crypto_report_comp), rcomp);
+
+   return 0;
+
+nla_put_failure:
+   return -EMSGSIZE;
+}
+
 static int crypto_report_one(struct crypto_alg *alg,
 struct crypto_user_alg *ualg, struct sk_buff *skb)
 {
@@ -127,6 +142,11 @@ static int crypto_report_one(struct crypto_alg *alg,
goto nla_put_failure;
 
break;
+   case CRYPTO_ALG_TYPE_COMPRESS:
+   if (crypto_report_comp(skb, alg))
+   goto nla_put_failure;
+
+   break;
}
 
 out:
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html