[PATCH 5/5] crypto: caam/qi2 - avoid allocating memory at crypto request runtime

2020-12-02 Thread Iuliana Prodan (OSS)
From: Iuliana Prodan Remove CRYPTO_ALG_ALLOCATES_MEMORY flag and allocate the memory needed by the driver, to fulfil a request, within the crypto request object. The extra size needed for base extended descriptor, hw descriptor commands and link tables is computed in frontend driver (caamalg_qi2

[PATCH 4/5] crypto: caam/qi - avoid allocating memory at crypto request runtime

2020-12-02 Thread Iuliana Prodan (OSS)
From: Iuliana Prodan Remove CRYPTO_ALG_ALLOCATES_MEMORY flag and allocate the memory needed by the driver, to fulfil a request, within the crypto request object. The extra size needed for base extended descriptor, hw descriptor commands and link tables is computed in frontend driver (caamalg_qi

[PATCH 3/5] crypto: caam/jr - avoid allocating memory at crypto request runtime fost hash

2020-12-02 Thread Iuliana Prodan (OSS)
From: Iuliana Prodan Remove CRYPTO_ALG_ALLOCATES_MEMORY flag and allocate the memory needed by the driver, to fulfil a request, within the crypto request object. The extra size needed for base extended descriptor and link tables is computed in frontend driver (caamhash) initialization and saved

[PATCH 2/5] crypto: caam/jr - avoid allocating memory at crypto request runtime for aead

2020-12-02 Thread Iuliana Prodan (OSS)
From: Iuliana Prodan Remove CRYPTO_ALG_ALLOCATES_MEMORY flag and allocate the memory needed by the driver, to fulfil a request, within the crypto request object. The extra size needed for base extended descriptor, hw descriptor commands and link tables is computed in frontend driver (caamalg

[PATCH 1/5] crypto: caam/jr - avoid allocating memory at crypto request runtime for skcipher

2020-12-02 Thread Iuliana Prodan (OSS)
From: Iuliana Prodan Remove CRYPTO_ALG_ALLOCATES_MEMORY flag and allocate the memory needed by the driver, to fulfil a request, within the crypto request object. The extra size needed for base extended descriptor and hw descriptor commands, link tables, IV is computed in frontend driver (caamalg

[PATCH 0/5] crypto: caam - avoid allocating memory at crypto request runtime

2020-12-02 Thread Iuliana Prodan (OSS)
From: Iuliana Prodan This series removes CRYPTO_ALG_ALLOCATES_MEMORY flag and allocates the memory needed by the driver, to fulfil a request, within the crypto request object. The extra size needed for base extended descriptor, hw descriptor commands and link tables is added to the reqsize field

Re: [RFC PATCH 0/4] crypto: add CRYPTO_TFM_REQ_DMA flag

2020-11-26 Thread Iuliana Prodan
On 11/26/2020 7:12 PM, Ard Biesheuvel wrote: On Thu, 26 Nov 2020 at 17:00, Iuliana Prodan wrote: On 11/26/2020 9:09 AM, Ard Biesheuvel wrote: On Wed, 25 Nov 2020 at 22:39, Iuliana Prodan wrote: On 11/25/2020 11:16 PM, Ard Biesheuvel wrote: On Wed, 25 Nov 2020 at 22:14, Iuliana Prodan

Re: [RFC PATCH 0/4] crypto: add CRYPTO_TFM_REQ_DMA flag

2020-11-26 Thread Iuliana Prodan
On 11/26/2020 9:09 AM, Ard Biesheuvel wrote: On Wed, 25 Nov 2020 at 22:39, Iuliana Prodan wrote: On 11/25/2020 11:16 PM, Ard Biesheuvel wrote: On Wed, 25 Nov 2020 at 22:14, Iuliana Prodan (OSS) wrote: From: Iuliana Prodan Add the option to allocate the crypto request object plus any

Re: [RFC PATCH 0/4] crypto: add CRYPTO_TFM_REQ_DMA flag

2020-11-25 Thread Iuliana Prodan
On 11/25/2020 11:16 PM, Ard Biesheuvel wrote: On Wed, 25 Nov 2020 at 22:14, Iuliana Prodan (OSS) wrote: From: Iuliana Prodan Add the option to allocate the crypto request object plus any extra space needed by the driver into a DMA-able memory. Add CRYPTO_TFM_REQ_DMA flag to be used by

[RFC PATCH 4/4] crypto: caam - avoid allocating memory at crypto request runtime for aead

2020-11-25 Thread Iuliana Prodan (OSS)
From: Iuliana Prodan Remove CRYPTO_ALG_ALLOCATES_MEMORY flag and allocate the memory needed by the driver, to fulfil a request, within the crypto request object. The extra size needed for base extended descriptor, hw descriptor commands and link tables is computed in frontend driver (caamalg

[RFC PATCH 3/4] crypto: caam - avoid allocating memory at crypto request runtime for skcipher

2020-11-25 Thread Iuliana Prodan (OSS)
From: Iuliana Prodan Remove CRYPTO_ALG_ALLOCATES_MEMORY flag and allocate the memory needed by the driver, to fulfil a request, within the crypto request object. The extra size needed for base extended descriptor and hw descriptor commands, link tables, IV is computed in frontend driver (caamalg

[RFC PATCH 2/4] net: esp: check CRYPTO_TFM_REQ_DMA flag when allocating crypto request

2020-11-25 Thread Iuliana Prodan (OSS)
From: Iuliana Prodan Some crypto backends might require the requests' private contexts to be allocated in DMA-able memory. Signed-off-by: Horia Geanta --- net/ipv4/esp4.c | 7 ++- net/ipv6/esp6.c | 7 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/net/ipv4/e

[RFC PATCH 1/4] crypto: add CRYPTO_TFM_REQ_DMA flag

2020-11-25 Thread Iuliana Prodan (OSS)
From: Iuliana Prodan The CRYPTO_TFM_REQ_DMA flag can be used by backend implementations to indicate to crypto API the need to allocate GFP_DMA memory for private contexts of the crypto requests. For public key encryption add the needed functions to set/get/clear flags. Signed-off-by: Horia

[RFC PATCH 0/4] crypto: add CRYPTO_TFM_REQ_DMA flag

2020-11-25 Thread Iuliana Prodan (OSS)
From: Iuliana Prodan Add the option to allocate the crypto request object plus any extra space needed by the driver into a DMA-able memory. Add CRYPTO_TFM_REQ_DMA flag to be used by backend implementations to indicate to crypto API the need to allocate GFP_DMA memory for private contexts of the

Re: [PATCH v2 0/7] crypto: add CRYPTO_ALG_ALLOCATES_MEMORY

2020-11-19 Thread Iuliana Prodan
Hi Herbert, On 7/22/2020 10:29 AM, Herbert Xu wrote: On Fri, Jul 17, 2020 at 05:42:43PM +0300, Horia Geantă wrote: Looks like there's no mention of a limit on src, dst scatterlists size that crypto implementations could use when pre-allocating memory and crypto users needing CRYPTO_ALG_ALLOC

Re: [PATCH] crypto: caam - fix printing on xts fallback allocation error path

2020-11-02 Thread Iuliana Prodan
han 8B IV") Signed-off-by: Horia Geantă Reviewed-by: Iuliana Prodan --- drivers/crypto/caam/caamalg.c | 4 ++-- drivers/crypto/caam/caamalg_qi.c | 4 ++-- drivers/crypto/caam/caamalg_qi2.c | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/caam/ca

[PATCH v2] crypto: caam - enable crypto-engine retry mechanism

2020-10-26 Thread Iuliana Prodan
-engine). The callback for do_batch_requests is NULL, since CAAM doesn't support linked requests. Signed-off-by: Iuliana Prodan --- Changes since v1: - add comment for THRESHOLD define; - update max size for crypto-engine queue. drivers/crypto/caam/intern.h | 8 drivers/crypto/caam

Re: [PATCH] crypto: caam - enable crypto-engine retry mechanism

2020-10-26 Thread Iuliana Prodan
On 10/26/2020 5:36 PM, Horia Geantă wrote: On 10/21/2020 11:07 PM, Iuliana Prodan wrote: Use the new crypto_engine_alloc_init_and_set() function to initialize crypto-engine and enable retry mechanism. Set the maximum size for crypto-engine software queue based on Job Ring size (JOBR_DEPTH) and

[PATCH] crypto: caam - enable crypto-engine retry mechanism

2020-10-21 Thread Iuliana Prodan
-engine). The callback for do_batch_requests is NULL, since CAAM doesn't support linked requests. Signed-off-by: Iuliana Prodan --- drivers/crypto/caam/intern.h | 3 +++ drivers/crypto/caam/jr.c | 6 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/caam/int

Re: [PATCH v2 1/4] crypto: caam - Fix kerneldoc

2020-09-11 Thread Iuliana Prodan
e: 'struct caam_hash_ctx' drivers/crypto/caam/ctrl.c:449: warning: Function parameter or member 'ctrl' not described in 'caam_get_era' Signed-off-by: Krzysztof Kozlowski Reviewed-by: Iuliana Prodan --- Changes since v1: 1. Fix more warnings --- drivers/crypto/caa

Re: [PATCH 1/4] crypto: caam - Fix kerneldoc

2020-09-03 Thread Iuliana Prodan
On 9/2/2020 6:05 PM, Krzysztof Kozlowski wrote: Fix kerneldoc warnings: drivers/crypto/caam/caamalg_qi2.c:73: warning: cannot understand function prototype: 'struct caam_ctx ' drivers/crypto/caam/caamalg_qi2.c:2962: warning: cannot understand function prototype: 'struct caam_hash_ctx '

Re: [PATCH 2/4] crypto: caam - Simplify with dev_err_probe()

2020-09-03 Thread Iuliana Prodan
On 9/2/2020 6:05 PM, Krzysztof Kozlowski wrote: Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Iuliana Prodan --- drivers/crypto/caam/caamalg_qi2.c | 3 +-- 1

Re: [PATCH v1] crypto: caam - use traditional error check pattern

2020-09-01 Thread Iuliana Prodan
On 8/31/2020 10:58 AM, Andy Shevchenko wrote: Use traditional error check pattern ret = ...; if (ret) return ret; ... instead of checking error code to be 0. Signed-off-by: Andy Shevchenko Reviewed-by: Iuliana Prodan --- drivers/crypto/caam

[PATCH 2/2] crypto: caam - support tagged keys for skcipher algorithms

2020-07-12 Thread Iuliana Prodan
, e.g. using dmsetup: dmsetup -v create encrypted --table "0 $(blockdev --getsz /dev/mmcblk2p10) crypt capi:tk(cbc(aes))-plain :32:logon:seckey 0 /dev/mmcblk2p10 0 1 sector_size:512". Signed-off-by: Franck LENORMAND Signed-off-by: Iuliana Prodan --- drivers/cr

[PATCH 0/2] crypto: caam - add tagged keys functionality and tk transformations for skcipher

2020-07-12 Thread Iuliana Prodan
ations will know how to handle tagged keys, by loading the proper settings for KEY command. Iuliana Prodan (2): crypto: caam - add tag object functionality crypto: caam - support tagged keys for skcipher algorithms drivers/crypto/caam/Kconfig| 9 +++ drivers/crypto/caam/Makefile

[PATCH 1/2] crypto: caam - add tag object functionality

2020-07-12 Thread Iuliana Prodan
configuration or tag object data. This API expects that the object (the actual data) from a tag object to be a buffer (defined by address and size). Signed-off-by: Franck LENORMAND Signed-off-by: Iuliana Prodan --- drivers/crypto/caam/Kconfig | 9 +++ drivers/crypto/caam/Makefile

Re: crypto: caam - Fix argument type in handle_imx6_err005766

2020-06-12 Thread Iuliana Prodan
On 6/12/2020 9:00 AM, Herbert Xu wrote: The function handle_imx6_err005766 needs to take an __iomem argument as otherwise sparse will generate two warnings. Fixes: 33d69455e402 ("crypto: caam - limit AXI pipeline to a...") Signed-off-by: Herbert Xu Reviewed-by: Iuliana Proda

[PATCH] crypto: engine - do not requeue in case of fatal error

2020-05-19 Thread Iuliana Prodan
st be pass back and forth between crypto-engine and hardware. Fixes: 6a89f492f8e5 ("crypto: engine - support for parallel requests based on retry mechanism") Signed-off-by: Iuliana Prodan --- crypto/crypto_engine.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff

[PATCH v6 0/3] crypto: engine - support for parallel and batch requests

2020-04-28 Thread Iuliana Prodan
o-engine is used). - added a new patch with support for batch requests. Changes since V0 (RFC): - removed max_no_req and no_req, as the number of request that can be processed in parallel; - added a new callback, can_enqueue_more, to check whether the hardware can process a new request. Iulian

[PATCH v6 3/3] crypto: engine - support for batch requests

2020-04-28 Thread Iuliana Prodan
multiple request. Signed-off-by: Iuliana Prodan --- crypto/crypto_engine.c | 27 ++- include/crypto/engine.h | 5 + 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c index ee19273..412149e 100644 --- a

[PATCH v6 2/3] crypto: engine - support for parallel requests based on retry mechanism

2020-04-28 Thread Iuliana Prodan
e freed, since it will be enqueued back into crypto-engine's queue. When all drivers, that use crypto-engine now, will be updated for retry mechanism, the retry_support variable can be removed. Signed-off-by: Iuliana Prodan --- crypto/crypto_engine.c | 146 +++

[PATCH v6 1/3] crypto: algapi - create function to add request in front of queue

2020-04-28 Thread Iuliana Prodan
Add crypto_enqueue_request_head function that enqueues a request in front of queue. This will be used in crypto-engine, on error path. In case a request was not executed by hardware, enqueue it back in front of queue (to keep the order of requests). Signed-off-by: Iuliana Prodan --- crypto

Re: [PATCH] crypto: caam - fix use after free issue in *_crypt_done

2020-04-28 Thread Iuliana Prodan
On 4/28/2020 8:14 AM, Zhenzhong Duan wrote: > In both aead_crypt_done and skcipher_crypt_done, edesc->bklog is > referenced after the structure pointed by edesc is freed. > > Fix them by moving kfree(edesc) to the end of function call. > > Signed-off-by: Zhenzhong Duan These issues were already

[PATCH v2] crypto: caam - use mapped_{src,dst}_nents for descriptor

2019-09-26 Thread Iuliana Prodan
The mapped_{src,dst}_nents _returned_ from the dma_map_sg call (which could be less than src/dst_nents) have to be used to generate the job descriptors. Signed-off-by: Iuliana Prodan --- Changes since v1: - updated, with mapped_{src,dst}_nents, the set_rsa_pub_pdb, set_rsa_priv_f{1,2,3}_pdb

Re: [PATCH] crypto: caam - use mapped_{src,dst}_nents for descriptor

2019-09-26 Thread Iuliana Prodan
On 9/26/2019 10:17 AM, Horia Geanta wrote: > On 9/25/2019 4:04 PM, Iuliana Prodan wrote: >> @@ -428,17 +433,18 @@ static int set_rsa_priv_f1_pdb(struct akcipher_request >> *req, >> return -ENOMEM; >> } >> >> -if (edesc->src_nents

[PATCH] crypto: caam - use mapped_{src,dst}_nents for descriptor

2019-09-25 Thread Iuliana Prodan
The mapped_{src,dst}_nents _returned_ from the dma_map_sg call (which could be less than src/dst_nents) have to be used to generate the job descriptors. Signed-off-by: Iuliana Prodan --- drivers/crypto/caam/caampkc.c | 54 --- drivers/crypto/caam

Re: [PATCH v8 00/16] crypto: caam - Add i.MX8MQ support

2019-08-30 Thread Iuliana Prodan
On 8/30/2019 4:16 PM, Herbert Xu wrote: > On Fri, Aug 30, 2019 at 09:15:12AM +0000, Iuliana Prodan wrote: >> >> Can you, please, add, also, the device tree patch ("arm64: dts: imx8mq: >> Add CAAM node") in cryptodev tree? >> Unfortunately Shawn Guo wasn&#

Re: [PATCH v8 00/16] crypto: caam - Add i.MX8MQ support

2019-08-30 Thread Iuliana Prodan
On 8/30/2019 11:23 AM, Herbert Xu wrote: > Andrey Smirnov wrote: >> Everyone: >> >> Picking up where Chris left off (I chatted with him privately >> beforehead), this series adds support for i.MX8MQ to CAAM driver. Just >> like [v1], this series is i.MX8MQ only. >> >> Feedback is welcome! >> Thank

Re: [PATCH v8 00/16] crypto: caam - Add i.MX8MQ support

2019-08-26 Thread Iuliana Prodan
Thanks, > Andrey Smirnov > For the series: Reviewed-by: Iuliana Prodan Thanks, Iulia

[PATCH] crypto: caam/qi - use print_hex_dump_debug function to print debug messages

2019-08-20 Thread Iuliana Prodan
Use print_hex_dump_debug function to print debug messages, instead of print_hex_dump inside #ifdef DEBUG. Fixes: 6e005503199b ("crypto: caam - print debug messages at debug level") Signed-off-by: Iuliana Prodan --- drivers/crypto/caam/caamalg_qi.c | 9 - 1 file changed, 4

[PATCH v5] crypto: gcm - restrict assoclen for rfc4543

2019-08-02 Thread Iuliana Prodan
uld be restricted to 16 or 20 bytes, as for rfc4106. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- Changes since v4: - alignment. --- crypto/gcm.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crypto/gcm.c b/crypto/gcm.c index 2f3b50f..7388420 100644 --

[PATCH v5 07/14] crypto: caam - check zero-length input

2019-07-31 Thread Iuliana Prodan
Check zero-length input, for skcipher algorithm, to solve the extra tests. This is a valid operation, therefore the API will return no error. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caamalg.c | 6 ++ drivers/crypto/caam/caamalg_qi.c | 3

[PATCH v5 14/14] crypto: caam - change return value in case CAAM has no MDHA

2019-07-31 Thread Iuliana Prodan
d. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caamhash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index ed1931f..8a07edb 100644 --- a/drivers/crypto/caam/caamhash.c +++

[PATCH v5 08/14] crypto: caam - update rfc4106 sh desc to support zero length input

2019-07-31 Thread Iuliana Prodan
Update share descriptor for rfc4106 to skip instructions in case cryptlen is zero. If no instructions are jumped the DECO hangs and a timeout error is thrown. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caamalg_desc.c | 47

[PATCH v5 03/14] crypto: caam - update IV only when crypto operation succeeds

2019-07-31 Thread Iuliana Prodan
From: Horia Geantă skcipher encryption might fail and in some cases, like (invalid) input length smaller then block size, updating the IV would lead to a useless IV copy in case hardware issued an error. Signed-off-by: Horia Geantă Signed-off-by: Iuliana Prodan --- drivers/crypto/caam

[PATCH v5 09/14] crypto: caam - keep both virtual and dma key addresses

2019-07-31 Thread Iuliana Prodan
: Horia Geantă Reviewed-by: Iuliana Prodan --- drivers/crypto/caam/caamhash.c | 37 + drivers/crypto/caam/caamhash_desc.c | 5 ++--- drivers/crypto/caam/caamhash_desc.h | 2 +- drivers/crypto/caam/desc_constr.h | 10 -- 4 files changed, 24

[PATCH v5 02/14] crypto: caam - fix return code in completion callbacks

2019-07-31 Thread Iuliana Prodan
Note: in most error cases caam/qi and caam/qi2 returned -EIO; align all caam drivers to return -EINVAL. While here, ratelimit prints triggered by fuzz testing, such that console is not flooded. Signed-off-by: Horia Geantă Signed-off-by: Iuliana Prodan --- drivers/crypto/caam/caamalg.

[PATCH v5 13/14] crypto: caam - unregister algorithm only if the registration succeeded

2019-07-31 Thread Iuliana Prodan
aries") Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caampkc.c | 49 ++- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c index e00a470..5b12

[PATCH v5 04/14] crypto: caam - check key length

2019-07-31 Thread Iuliana Prodan
Check key length to solve the extra tests that expect -EINVAL to be returned when the key size is not valid. Validated AES keylen for skcipher, ahash and aead. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- Changes since v4: - use, newly renamed, helper aes function, to validate

[PATCH v5 11/14] crypto: caam - free resources in case caam_rng registration failed

2019-07-31 Thread Iuliana Prodan
Check the return value of the hardware registration for caam_rng and free resources in case of failure. Fixes: e24f7c9e87d4 ("crypto: caam - hwrng support") Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caamrng.c | 5 - 1 file changed, 4 insert

[PATCH v5 10/14] crypto: caam - fix MDHA key derivation for certain user key lengths

2019-07-31 Thread Iuliana Prodan
e (|user key| > |derived key|) fails when DKP is not available. Make sure gen_split_key() dma maps max(|user key|, |derived key|), since this is an in-place (bidirectional) operation. Signed-off-by: Horia Geantă Reviewed-by: Iuliana Prodan --- drivers/crypto/caam/caa

[PATCH v5 12/14] crypto: caam - execute module exit point only if necessary

2019-07-31 Thread Iuliana Prodan
rt top level drivers to libraries") Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caampkc.c | 11 +++ drivers/crypto/caam/caamrng.c | 14 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/caam/caampk

[PATCH v5 00/14] crypto: caam - fixes for kernel v5.3

2019-07-31 Thread Iuliana Prodan
and dma key addresses crypto: caam - fix MDHA key derivation for certain user key lengths Iuliana Prodan (9): crypto: caam - check key length crypto: caam - check authsize crypto: caam - check assoclen crypto: caam - check zero-length input crypto: caam - update rfc4106 sh desc to

[PATCH v5 06/14] crypto: caam - check assoclen

2019-07-31 Thread Iuliana Prodan
, extended seq_no) and IV len. This can be 16 or 20 bytes. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caamalg.c | 10 ++ drivers/crypto/caam/caamalg_qi.c | 12 drivers/crypto/caam/caamalg_qi2.c | 10 ++ 3 files changed, 8

[PATCH v5 05/14] crypto: caam - check authsize

2019-07-31 Thread Iuliana Prodan
Check authsize to solve the extra tests that expect -EINVAL to be returned when the authentication tag size is not valid. Validated authsize for GCM, RFC4106 and RFC4543. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caamalg.c | 13 + drivers

[PATCH v5 01/14] crypto: caam/qi - fix error handling in ERN handler

2019-07-31 Thread Iuliana Prodan
ovides details about the cause of failure Cc: # v5.1+ Fixes: 67c2315def06 ("crypto: caam - add Queue Interface (QI) backend support") Signed-off-by: Horia Geantă Reviewed-by: Iuliana Prodan --- drivers/crypto/caam/error.c | 1 + drivers/crypto/caam/qi.c| 5 - drivers/cryp

[PATCH v3 0/2] crypto: validate inputs for gcm and aes

2019-07-31 Thread Iuliana Prodan
without crypto_ prefix; - change include for gcm.h. Iuliana Prodan (2): crypto: gcm - helper functions for assoclen/authsize check crypto: aes - helper function to validate key length for AES algorithms crypto/gcm.c | 41 ++- include/crypto/aes.h

[PATCH v3 2/2] crypto: aes - helper function to validate key length for AES algorithms

2019-07-31 Thread Iuliana Prodan
Add inline helper function to check key length for AES algorithms. The key can be 128, 192 or 256 bits size. This function is used in the generic aes implementation. Signed-off-by: Iuliana Prodan --- include/crypto/aes.h | 17 + lib/crypto/aes.c | 8 2 files

[PATCH v3 1/2] crypto: gcm - helper functions for assoclen/authsize check

2019-07-31 Thread Iuliana Prodan
Added inline helper functions to check authsize and assoclen for gcm, rfc4106 and rfc4543. These are used in the generic implementation of gcm, rfc4106 and rfc4543. Signed-off-by: Iuliana Prodan --- crypto/gcm.c | 41 ++- include/crypto/gcm.h | 55

Re: [PATCH v2 2/2] crypto: aes - helper function to validate key length for AES algorithms

2019-07-31 Thread Iuliana Prodan
On 7/31/2019 8:33 AM, Ard Biesheuvel wrote: > On Tue, 30 Jul 2019 at 13:33, Iuliana Prodan wrote: >> >> Add inline helper function to check key length for AES algorithms. >> The key can be 128, 192 or 256 bits size. >> This function is used in the generic aes implemen

[PATCH v4] crypto: gcm - restrict assoclen for rfc4543

2019-07-30 Thread Iuliana Prodan
uld be restricted to 16 or 20 bytes, as for rfc4106. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- Changes since v3: - use ternary operator for return. Patch depends on series: https://patchwork.kernel.org/project/linux-crypto/list/?series=152649 --- crypto/gcm.c | 6 -- 1 f

Re: [PATCH v4 10/14] crypto: caam - fix MDHA key derivation for certain user key lengths

2019-07-30 Thread Iuliana Prodan
On 7/30/2019 2:06 PM, Iuliana Prodan wrote: > From: Horia Geantă > > Fuzz testing uncovered an issue when |user key| > |derived key|. > Derived key generation has to be fixed in two cases: > > 1. Era >= 6 (DKP is available) > DKP cannot be used with immediate input k

Re: [PATCH v4 09/14] crypto: caam - keep both virtual and dma key addresses

2019-07-30 Thread Iuliana Prodan
On 7/30/2019 2:06 PM, Iuliana Prodan wrote: > From: Horia Geantă > > Update alginfo struct to keep both virtual and dma key addresses, > so that descriptors have them at hand. > One example where this is needed is in the xcbc(aes) shared descriptors, > which are update

Re: [PATCH v4 01/14] crypto: caam/qi - fix error handling in ERN handler

2019-07-30 Thread Iuliana Prodan
On 7/30/2019 2:06 PM, Iuliana Prodan wrote: > From: Horia Geantă > > ERN handler calls the caam/qi frontend "done" callback with a status > of -EIO. This is incorrect, since the callback expects a status value > meaningful for the crypto engine - hence the cryptic mess

[PATCH v4 05/14] crypto: caam - check authsize

2019-07-30 Thread Iuliana Prodan
Check authsize to solve the extra tests that expect -EINVAL to be returned when the authentication tag size is not valid. Validated authsize for GCM, RFC4106 and RFC4543. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caamalg.c | 13 + drivers

[PATCH v4 07/14] crypto: caam - check zero-length input

2019-07-30 Thread Iuliana Prodan
Check zero-length input, for skcipher algorithm, to solve the extra tests. This is a valid operation, therefore the API will return no error. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caamalg.c | 6 ++ drivers/crypto/caam/caamalg_qi.c | 3

[PATCH v4 10/14] crypto: caam - fix MDHA key derivation for certain user key lengths

2019-07-30 Thread Iuliana Prodan
From: Horia Geantă Fuzz testing uncovered an issue when |user key| > |derived key|. Derived key generation has to be fixed in two cases: 1. Era >= 6 (DKP is available) DKP cannot be used with immediate input key if |user key| > |derived key|, since the resulting descriptor (after DKP execution)

[PATCH v4 11/14] crypto: caam - free resources in case caam_rng registration failed

2019-07-30 Thread Iuliana Prodan
Check the return value of the hardware registration for caam_rng and free resources in case of failure. Fixes: e24f7c9e87d4 ("crypto: caam - hwrng support") Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- Changes since v3: - update Fixes tag with 12 characters o

[PATCH v4 14/14] crypto: caam - change return value in case CAAM has no MDHA

2019-07-30 Thread Iuliana Prodan
d. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caamhash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index 2ce5a79..262be3a 100644 --- a/drivers/crypto/caam/caamhash.c +++

[PATCH v4 02/14] crypto: caam - fix return code in completion callbacks

2019-07-30 Thread Iuliana Prodan
Note: in most error cases caam/qi and caam/qi2 returned -EIO; align all caam drivers to return -EINVAL. While here, ratelimit prints triggered by fuzz testing, such that console is not flooded. Signed-off-by: Horia Geantă Signed-off-by: Iuliana Prodan --- drivers/crypto/caam/caamalg.

[PATCH v4 09/14] crypto: caam - keep both virtual and dma key addresses

2019-07-30 Thread Iuliana Prodan
From: Horia Geantă Update alginfo struct to keep both virtual and dma key addresses, so that descriptors have them at hand. One example where this is needed is in the xcbc(aes) shared descriptors, which are updated in current patch. Another example is the upcoming fix for DKP. Signed-off-by: Hor

[PATCH v4 01/14] crypto: caam/qi - fix error handling in ERN handler

2019-07-30 Thread Iuliana Prodan
From: Horia Geantă ERN handler calls the caam/qi frontend "done" callback with a status of -EIO. This is incorrect, since the callback expects a status value meaningful for the crypto engine - hence the cryptic messages like the one below: platform caam_qi: 15: unknown error source Fix this by p

[PATCH v4 08/14] crypto: caam - update rfc4106 sh desc to support zero length input

2019-07-30 Thread Iuliana Prodan
Update share descriptor for rfc4106 to skip instructions in case cryptlen is zero. If no instructions are jumped the DECO hangs and a timeout error is thrown. Signed-off-by: Iuliana Prodan --- Changes since v3: - move the erratum workaround to reduce the chances of DECO stalling. --- drivers

[PATCH v4 06/14] crypto: caam - check assoclen

2019-07-30 Thread Iuliana Prodan
, extended seq_no) and IV len. This can be 16 or 20 bytes. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caamalg.c | 10 ++ drivers/crypto/caam/caamalg_qi.c | 12 drivers/crypto/caam/caamalg_qi2.c | 10 ++ 3 files changed, 8

[PATCH v4 13/14] crypto: caam - unregister algorithm only if the registration succeeded

2019-07-30 Thread Iuliana Prodan
aries") Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caampkc.c | 49 ++- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c index e00a470..5b12

[PATCH v4 00/14] crypto: caam - fixes for kernel v5.3

2019-07-30 Thread Iuliana Prodan
: caam - update IV only when crypto operation succeeds crypto: caam - keep both virtual and dma key addresses crypto: caam - fix MDHA key derivation for certain user key lengths Iuliana Prodan (9): crypto: caam - check key length crypto: caam - check authsize crypto: caam - check assoclen

[PATCH v4 03/14] crypto: caam - update IV only when crypto operation succeeds

2019-07-30 Thread Iuliana Prodan
From: Horia Geantă skcipher encryption might fail and in some cases, like (invalid) input length smaller then block size, updating the IV would lead to a useless IV copy in case hardware issued an error. Signed-off-by: Horia Geantă Signed-off-by: Iuliana Prodan --- Changes since v3: - update

[PATCH v4 04/14] crypto: caam - check key length

2019-07-30 Thread Iuliana Prodan
Check key length to solve the extra tests that expect -EINVAL to be returned when the key size is not valid. Validated AES keylen for skcipher, ahash and aead. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/Kconfig | 2 + drivers/crypto/caam/caamalg.c

[PATCH v4 12/14] crypto: caam - execute module exit point only if necessary

2019-07-30 Thread Iuliana Prodan
rt top level drivers to libraries") Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caampkc.c | 11 +++ drivers/crypto/caam/caamrng.c | 14 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/caam/caampk

[PATCH v3] crypto: gcm - restrict assoclen for rfc4543

2019-07-30 Thread Iuliana Prodan
uld be restricted to 16 or 20 bytes, as for rfc4106. Signed-off-by: Iuliana Prodan --- Changes since v2: - use, newly renamed, helper functions added in crypto API, in series: https://patchwork.kernel.org/project/linux-crypto/list/?series=152649 crypto/gcm.c | 12 1 file changed,

[PATCH v2 0/2] crypto: validate inputs for gcm and aes

2019-07-30 Thread Iuliana Prodan
crypto_ prefix; - update aes after it was moved to lib/crypto. Iuliana Prodan (2): crypto: gcm - helper functions for assoclen/authsize check crypto: aes - helper function to validate key length for AES algorithms crypto/gcm.c | 41 ++- include

[PATCH v2 2/2] crypto: aes - helper function to validate key length for AES algorithms

2019-07-30 Thread Iuliana Prodan
Add inline helper function to check key length for AES algorithms. The key can be 128, 192 or 256 bits size. This function is used in the generic aes implementation. Signed-off-by: Iuliana Prodan --- include/crypto/aes.h | 17 + lib/crypto/aes.c | 8 2 files

[PATCH v2 1/2] crypto: gcm - helper functions for assoclen/authsize check

2019-07-30 Thread Iuliana Prodan
Added inline helper functions to check authsize and assoclen for gcm, rfc4106 and rfc4543. These are used in the generic implementation of gcm, rfc4106 and rfc4543. Signed-off-by: Iuliana Prodan --- crypto/gcm.c | 41 ++- include/crypto/gcm.h | 55

[PATCH v3 06/14] crypto: caam - check assoclen

2019-07-25 Thread Iuliana Prodan
, extended seq_no) and IV len. This can be 16 or 20 bytes. Signed-off-by: Iuliana Prodan --- drivers/crypto/caam/caamalg.c | 10 ++ drivers/crypto/caam/caamalg_qi.c | 10 ++ drivers/crypto/caam/caamalg_qi2.c | 10 ++ 3 files changed, 6 insertions(+), 24 deletions(-) diff

[PATCH v3 07/14] crypto: caam - check zero-length input

2019-07-25 Thread Iuliana Prodan
Check zero-length input, for skcipher algorithm, to solve the extra tests. This is a valid operation, therefore the API will return no error. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caamalg.c | 6 ++ drivers/crypto/caam/caamalg_qi.c | 3

[PATCH v3 02/14] crypto: caam - fix return code in completion callbacks

2019-07-25 Thread Iuliana Prodan
Note: in most error cases caam/qi and caam/qi2 returned -EIO; align all caam drivers to return -EINVAL. While here, ratelimit prints triggered by fuzz testing, such that console is not flooded. Signed-off-by: Horia Geantă Signed-off-by: Iuliana Prodan --- drivers/crypto/caam/caamalg.

[PATCH v3 00/14] crypto: caam - fixes for kernel v5.3

2019-07-25 Thread Iuliana Prodan
- fix error handling in ERN handler crypto: caam - fix return code in completion callbacks crypto: caam - update IV only when crypto operation succeeds crypto: caam - keep both virtual and dma key addresses crypto: caam - fix MDHA key derivation for certain user key lengths Iuliana Pro

[PATCH v3 05/14] crypto: caam - check authsize

2019-07-25 Thread Iuliana Prodan
Check authsize to solve the extra tests that expect -EINVAL to be returned when the authentication tag size is not valid. Validated authsize for GCM, RFC4106 and RFC4543. Signed-off-by: Iuliana Prodan --- drivers/crypto/caam/caamalg.c | 13 + drivers/crypto/caam/caamalg_qi.c

[PATCH v3 10/14] crypto: caam - fix MDHA key derivation for certain user key lengths

2019-07-25 Thread Iuliana Prodan
From: Horia Geantă Fuzz testing uncovered an issue when |user key| > |derived key|. Derived key generation has to be fixed in two cases: 1. Era >= 6 (DKP is available) DKP cannot be used with immediate input key if |user key| > |derived key|, since the resulting descriptor (after DKP execution)

[PATCH v3 09/14] crypto: caam - keep both virtual and dma key addresses

2019-07-25 Thread Iuliana Prodan
From: Horia Geantă Update alginfo struct to keep both virtual and dma key addresses, so that descriptors have them at hand. One example where this is needed is in the xcbc(aes) shared descriptors, which are updated in current patch. Another example is the upcoming fix for DKP. Signed-off-by: Hor

[PATCH v3 12/14] crypto: caam - execute module exit point only if necessary

2019-07-25 Thread Iuliana Prodan
rt top level drivers to libraries") Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caampkc.c | 11 +++ drivers/crypto/caam/caamrng.c | 14 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/caam/caampk

[PATCH v3 04/14] crypto: caam - check key length

2019-07-25 Thread Iuliana Prodan
Check key length to solve the extra tests that expect -EINVAL to be returned when the key size is not valid. Validated AES keylen for skcipher, ahash and aead. Signed-off-by: Iuliana Prodan --- Changes since v2: - remove check for keylen < 4, since is included in check_aes_keylen; - upd

[PATCH v3 11/14] crypto: caam - free resources in case caam_rng registration failed

2019-07-25 Thread Iuliana Prodan
Check the return value of the hardware registration for caam_rng and free resources in case of failure. Fixes: e24f7c9 ("crypto: caam - hwrng support") Signed-off-by: Iuliana Prodan --- Changes since v2: - update Fixes tag. --- drivers/crypto/caam/caamrng.c | 5 - 1 file

[PATCH v3 08/14] crypto: caam - update rfc4106 sh desc to support zero length input

2019-07-25 Thread Iuliana Prodan
Update share descriptor for rfc4106 to skip instructions in case cryptlen is zero. If no instructions are jumped the DECO hangs and a timeout error is thrown. Signed-off-by: Iuliana Prodan --- Changes since v2: - update shared descriptor with the erratum workaround. --- drivers/crypto/caam

[PATCH v3 13/14] crypto: caam - unregister algorithm only if the registration succeeded

2019-07-25 Thread Iuliana Prodan
aries") Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caampkc.c | 49 ++- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c index cfdf7a2..a669

[PATCH v3 03/14] crypto: caam - update IV only when crypto operation succeeds

2019-07-25 Thread Iuliana Prodan
From: Horia Geantă skcipher encryption might fail and in some cases, like (invalid) input length smaller then block size, updating the IV would lead to panic due to copying from a negative offset (req->cryptlen - ivsize). Signed-off-by: Horia Geantă Signed-off-by: Iuliana Prodan --- driv

[PATCH v3 14/14] crypto: caam - change return value in case CAAM has no MDHA

2019-07-25 Thread Iuliana Prodan
d. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caamhash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index 7147190..3a1dfd2 100644 --- a/drivers/crypto/caam/caamhash.c +++

[PATCH v3 01/14] crypto: caam/qi - fix error handling in ERN handler

2019-07-25 Thread Iuliana Prodan
From: Horia Geantă ERN handler calls the caam/qi frontend "done" callback with a status of -EIO. This is incorrect, since the callback expects a status value meaningful for the crypto engine - hence the cryptic messages like the one below: platform caam_qi: 15: unknown error source Fix this by p

[PATCH v2] crypto: gcm - restrict assoclen for rfc4543

2019-07-25 Thread Iuliana Prodan
uld be restricted to 16 or 20 bytes, as for rfc4106. Signed-off-by: Iuliana Prodan --- Changes since v1: - use helper functions added in crypto API, in series: https://patchwork.kernel.org/project/linux-crypto/list/?series=150651 crypto/gcm.c | 12 1 file changed, 12 inserti

[PATCH 1/2] crypto: gcm - helper functions for assoclen/authsize check

2019-07-25 Thread Iuliana Prodan
Added inline helper functions to check authsize and assoclen for gcm and rfc4106. These are used in the generic implementation of gcm and rfc4106. Signed-off-by: Iuliana Prodan --- crypto/gcm.c | 41 +++- include/crypto/gcm.h | 53

  1   2   >