mbox series

[v5,0/2] STM32 CRYP crypto driver

Message ID 1508425830-13565-1-git-send-email-fabien.dessenne@st.com
Headers show
Series STM32 CRYP crypto driver | expand

Message

Fabien DESSENNE Oct. 19, 2017, 3:10 p.m. UTC
This set of patches adds a new crypto driver for STMicroelectronics stm32 HW.
This drivers uses the crypto API and provides with HW-enabled block cipher
algorithms.

This driver was successfully tested with tcrypt / testmgr.

Changes since v5:
-add timeout in wait_busy function
-clear key after use
-misc : remove unused functions, use -Exx, use dev_err

Changes since v4:
- remove AEAD support from crypto engine as proposed by Herbert : waiting for
  the crypto_engine interface clean up before
  [https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1474434.html]
- remove AES GCM & CCM algorithms

Changes since v3:
- update dt-bindings with Rob Herring remarks

Changes since v2:
- update dt-bindings (interrupts description)
- rebase on STM32 crypto patches (L. Debieve : update CRC32 + add HASH)

Fabien Dessenne (2):
  dt-bindings: Document STM32 CRYP bindings
  crypto: stm32 - Support for STM32 CRYP crypto module

 .../devicetree/bindings/crypto/st,stm32-cryp.txt   |   19 +
 drivers/crypto/stm32/Kconfig                       |    9 +
 drivers/crypto/stm32/Makefile                      |    3 +-
 drivers/crypto/stm32/stm32-cryp.c                  | 1172 ++++++++++++++++++++
 4 files changed, 1202 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/crypto/st,stm32-cryp.txt
 create mode 100644 drivers/crypto/stm32/stm32-cryp.c

Comments

Corentin Labbe Oct. 22, 2017, 7:26 a.m. UTC | #1
On Thu, Oct 19, 2017 at 05:10:30PM +0200, Fabien Dessenne wrote:
> This module registers block cipher algorithms that make use of the
> STMicroelectronics STM32 crypto "CRYP1" hardware.
> The following algorithms are supported:
> - aes: ecb, cbc, ctr
> - des: ecb, cbc
> - tdes: ecb, cbc
> 
> Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
> ---
>  drivers/crypto/stm32/Kconfig      |    9 +
>  drivers/crypto/stm32/Makefile     |    3 +-
>  drivers/crypto/stm32/stm32-cryp.c | 1172 +++++++++++++++++++++++++++++++++++++
>  3 files changed, 1183 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/crypto/stm32/stm32-cryp.c
> 
> diff --git a/drivers/crypto/stm32/Kconfig b/drivers/crypto/stm32/Kconfig
> +static void stm32_cryp_irq_write_block(struct stm32_cryp *cryp)
> +{
> +	unsigned int i, j;
> +	u32 *src;
> +	u8 d8[4];
> +
> +	src = sg_virt(cryp->in_sg) + _walked_in;
> +
> +	for (i = 0; i < cryp->hw_blocksize / sizeof(u32); i++) {
> +		if (likely(cryp->total_in >= sizeof(u32))) {
> +			/* Write a full u32 */
> +			stm32_cryp_write(cryp, CRYP_DIN, *src);

Hello

Try also to test your driver with userspace via AF_ALG (libkcapi is a good start).
It should probably crash here.
I have do the same on my first sunxi-ss driver and you should use kmap().

Regards
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Fabien DESSENNE Nov. 28, 2017, 9:47 a.m. UTC | #2
Just a gentle ping ... or have I missed out on a reply?


On 13/11/17 11:30, Fabien DESSENNE wrote:
> Hi Herbert,

>

> Can you check if this patchset (removed the AEAD part as you suggested +

> libkcapi test OK as suggested by Corentin) can be applied now?

>

> BR

>

> Fabien

>

>

> On 07/11/17 15:40, Fabien DESSENNE wrote:

>> On 22/10/17 09:26, Corentin Labbe wrote:

>>> On Thu, Oct 19, 2017 at 05:10:30PM +0200, Fabien Dessenne wrote:

>>>> This module registers block cipher algorithms that make use of the

>>>> STMicroelectronics STM32 crypto "CRYP1" hardware.

>>>> The following algorithms are supported:

>>>> - aes: ecb, cbc, ctr

>>>> - des: ecb, cbc

>>>> - tdes: ecb, cbc

>>>>

>>>> Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>

>>>> ---

>>>>     drivers/crypto/stm32/Kconfig      |    9 +

>>>>     drivers/crypto/stm32/Makefile     |    3 +-

>>>>     drivers/crypto/stm32/stm32-cryp.c | 1172 +++++++++++++++++++++++++++++++++++++

>>>>     3 files changed, 1183 insertions(+), 1 deletion(-)

>>>>     create mode 100644 drivers/crypto/stm32/stm32-cryp.c

>>>>

>>>> diff --git a/drivers/crypto/stm32/Kconfig b/drivers/crypto/stm32/Kconfig

>>>> +static void stm32_cryp_irq_write_block(struct stm32_cryp *cryp)

>>>> +{

>>>> +	unsigned int i, j;

>>>> +	u32 *src;

>>>> +	u8 d8[4];

>>>> +

>>>> +	src = sg_virt(cryp->in_sg) + _walked_in;

>>>> +

>>>> +	for (i = 0; i < cryp->hw_blocksize / sizeof(u32); i++) {

>>>> +		if (likely(cryp->total_in >= sizeof(u32))) {

>>>> +			/* Write a full u32 */

>>>> +			stm32_cryp_write(cryp, CRYP_DIN, *src);

>>> Hello

>>>

>>> Try also to test your driver with userspace via AF_ALG (libkcapi is a good start).

>>> It should probably crash here.

>>> I have do the same on my first sunxi-ss driver and you should use kmap().

>>>

>>> Regards

>> Hi Corentin,

>>

>> Thank you for suggesting to test from userspace through the AF_ALG

>> socket with libkcapi.

>> This increases my test coverage.

>>

>> I ran the miscellaneous tests (kcapi-enc-test(large).sh + test.sh) and

>> could not observe any crash.

>> Note that I had already fixed some 'memory crashes' while testing with

>> testmgr / tcrypt while testing from the kernel.

>>

>> So it looks like the proposed implementation is fine.

>>

>> BR

>>

>> Fabien
Herbert Xu Nov. 29, 2017, 6:29 a.m. UTC | #3
On Thu, Oct 19, 2017 at 05:10:28PM +0200, Fabien Dessenne wrote:
> This set of patches adds a new crypto driver for STMicroelectronics stm32 HW.
> This drivers uses the crypto API and provides with HW-enabled block cipher
> algorithms.
> 
> This driver was successfully tested with tcrypt / testmgr.
> 
> Changes since v5:
> -add timeout in wait_busy function
> -clear key after use
> -misc : remove unused functions, use -Exx, use dev_err

All applied.  Thanks.