aboutsummaryrefslogtreecommitdiff
path: root/drivers/crypto/ccree
AgeCommit message (Collapse)AuthorFilesLines
2020-02-13crypto: ccree - remove set but not used variable 'du_size'YueHaibing1-8/+0
Fixes gcc '-Wunused-but-set-variable' warning: drivers/crypto/ccree/cc_cipher.c: In function 'cc_setup_state_desc': drivers/crypto/ccree/cc_cipher.c:536:15: warning: variable 'du_size' set but not used [-Wunused-but-set-variable] commit 5c83e8ec4d51 ("crypto: ccree - fix FDE descriptor sequence") involved this unused variable, so remove it. Reported-by: Hulk Robot <[email protected]> Signed-off-by: YueHaibing <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-02-13crypto: ccree - dec auth tag size from cryptlen mapGilad Ben-Yossef1-2/+6
Remove the auth tag size from cryptlen before mapping the destination in out-of-place AEAD decryption thus resolving a crash with extended testmgr tests. Signed-off-by: Gilad Ben-Yossef <[email protected]> Reported-by: Geert Uytterhoeven <[email protected]> Cc: [email protected] # v4.19+ Tested-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-02-13crypto: ccree - fix AEAD blocksize registrationGilad Ben-Yossef1-0/+1
Fix an error causing no block sizes to be reported during all AEAD registrations. Signed-off-by: Gilad Ben-Yossef <[email protected]> Tested-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-02-13crypto: ccree - fix some reported cipher block sizesGilad Ben-Yossef1-2/+6
OFB and CTR modes block sizes were wrongfully reported as the underlying block sizes. Fix it to 1 bytes as they turn the block ciphers into stream ciphers. Also document why our XTS differes from the generic implementation. Signed-off-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-02-13crypto: ccree - only try to map auth tag if neededGilad Ben-Yossef1-2/+4
Make sure to only add the size of the auth tag to the source mapping for encryption if it is an in-place operation. Failing to do this previously caused us to try and map auth size len bytes from a NULL mapping and crashing if both the cryptlen and assoclen are zero. Reported-by: Geert Uytterhoeven <[email protected]> Tested-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Gilad Ben-Yossef <[email protected]> Cc: [email protected] # v4.19+ Signed-off-by: Herbert Xu <[email protected]>
2020-02-13crypto: ccree - protect against empty or NULL scatterlistsGilad Ben-Yossef2-35/+28
Deal gracefully with a NULL or empty scatterlist which can happen if both cryptlen and assoclen are zero and we're doing in-place AEAD encryption. This fixes a crash when this causes us to try and map a NULL page, at least with some platforms / DMA mapping configs. Cc: [email protected] # v4.19+ Reported-by: Geert Uytterhoeven <[email protected]> Tested-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-01-22crypto: ccree - erase unneeded inline funcsGilad Ben-Yossef1-10/+0
These inline versions of PM function for the case of CONFIG_PM is not set are never used. Erase them. Signed-off-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-01-22crypto: ccree - make cc_pm_put_suspend() voidGilad Ben-Yossef2-10/+4
cc_pm_put_suspend() return value was never checked and is not useful. Turn it into a void functions. Signed-off-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-01-22crypto: ccree - split overloaded usage of irq fieldGilad Ben-Yossef2-11/+9
We were using the irq field of the drvdata struct in an overloaded fahsion - saving the IRQ number during init and then storing the pending itnerrupt sources during interrupt in the same field. This worked because these usage are mutually exclusive but are confusing. So simplify the code and change the init use case to use a simple local variable. Signed-off-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-01-22crypto: ccree - fix PM race conditionGilad Ben-Yossef4-80/+7
The PM code was racy, possibly causing the driver to submit requests to a powered down device. Fix the race and while at it simplify the PM code. Signed-off-by: Gilad Ben-Yossef <[email protected]> Fixes: 1358c13a48c4 ("crypto: ccree - fix resume race condition on init") Cc: [email protected] # v4.20 Signed-off-by: Herbert Xu <[email protected]>
2020-01-22crypto: ccree - fix FDE descriptor sequenceOfir Drang1-3/+45
In FDE mode (xts, essiv and bitlocker) the cryptocell hardware requires that the the XEX key will be loaded after Key1. Signed-off-by: Ofir Drang <[email protected]> Cc: [email protected] Signed-off-by: Herbert Xu <[email protected]>
2020-01-22crypto: ccree - cc_do_send_request() is void funcGilad Ben-Yossef1-25/+11
cc_do_send_request() cannot fail and always returns -EINPROGRESS. Turn it into a void function and simplify code. Signed-off-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-01-22crypto: ccree - fix pm wrongful error reportingGilad Ben-Yossef1-1/+1
pm_runtime_get_sync() can return 1 as a valid (none error) return code. Treat it as such. Signed-off-by: Gilad Ben-Yossef <[email protected]> Cc: [email protected] # v4.19+ Signed-off-by: Herbert Xu <[email protected]>
2020-01-22crypto: ccree - turn errors to debug msgsGilad Ben-Yossef2-13/+13
We have several loud error log messages that are already reported via the normal return code mechanism and produce a lot of noise when the new testmgr extra test are enabled. Turn these into debug only messages Signed-off-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-01-22crypto: ccree - fix AEAD decrypt auth failGilad Ben-Yossef1-1/+1
On AEAD decryption authentication failure we are suppose to zero out the output plaintext buffer. However, we've missed skipping the optional associated data that may prefix the ciphertext. This commit fixes this issue. Signed-off-by: Gilad Ben-Yossef <[email protected]> Fixes: e88b27c8eaa8 ("crypto: ccree - use std api sg_zero_buffer") Cc: [email protected] Signed-off-by: Herbert Xu <[email protected]>
2020-01-22crypto: ccree - fix typo in commentHadar Gat1-1/+1
Fixed a typo in a commnet. Signed-off-by: Hadar Gat <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-01-22crypto: ccree - fix typos in error msgsHadar Gat1-2/+2
Fixed typos in ccree error msgs. Signed-off-by: Hadar Gat <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-01-09crypto: remove CRYPTO_TFM_RES_BAD_KEY_LENEric Biggers3-23/+6
The CRYPTO_TFM_RES_BAD_KEY_LEN flag was apparently meant as a way to make the ->setkey() functions provide more information about errors. However, no one actually checks for this flag, which makes it pointless. Also, many algorithms fail to set this flag when given a bad length key. Reviewing just the generic implementations, this is the case for aes-fixed-time, cbcmac, echainiv, nhpoly1305, pcrypt, rfc3686, rfc4309, rfc7539, rfc7539esp, salsa20, seqiv, and xcbc. But there are probably many more in arch/*/crypto/ and drivers/crypto/. Some algorithms can even set this flag when the key is the correct length. For example, authenc and authencesn set it when the key payload is malformed in any way (not just a bad length), the atmel-sha and ccree drivers can set it if a memory allocation fails, and the chelsio driver sets it for bad auth tag lengths, not just bad key lengths. So even if someone actually wanted to start checking this flag (which seems unlikely, since it's been unused for a long time), there would be a lot of work needed to get it working correctly. But it would probably be much better to go back to the drawing board and just define different return values, like -EINVAL if the key is invalid for the algorithm vs. -EKEYREJECTED if the key was rejected by a policy like "no weak keys". That would be much simpler, less error-prone, and easier to test. So just remove this flag. Signed-off-by: Eric Biggers <[email protected]> Reviewed-by: Horia Geantă <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-01-09crypto: remove CRYPTO_TFM_RES_BAD_BLOCK_LENEric Biggers2-2/+0
The flag CRYPTO_TFM_RES_BAD_BLOCK_LEN is never checked for, and it's only set by one driver. And even that single driver's use is wrong because the driver is setting the flag from ->encrypt() and ->decrypt() with no locking, which is unsafe because ->encrypt() and ->decrypt() can be executed by many threads in parallel on the same tfm. Just remove this flag. Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-12-11crypto: ccree - fix backlog memory leakGilad Ben-Yossef1-0/+1
Fix brown paper bag bug of not releasing backlog list item buffer when backlog was consumed causing a memory leak when backlog is used. Signed-off-by: Gilad Ben-Yossef <[email protected]> Cc: [email protected] # v4.19+ Signed-off-by: Herbert Xu <[email protected]>
2019-12-11crypto: ccree - fix typos in error msgsHadar Gat1-3/+3
Fix some typos in error message text. Signed-off-by: Hadar Gat <[email protected]> Signed-off-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-12-11crypto: ccree - fix typos in commentsHadar Gat4-9/+9
Fix some typos in code comments. Signed-off-by: Hadar Gat <[email protected]> Signed-off-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-12-11crypto: ccree - remove useless defineGilad Ben-Yossef2-3/+0
The define of CC_DEV_SHA_MAX is not needed since we moved to runtime detection of capabilities. Remove it. Signed-off-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-11-17crypto: ccree - update a stale reference to ablkcipherArd Biesheuvel1-2/+2
The ccree driver does not use the ablkcipher interface but contains a rudimentary reference to it in the naming of an unrelated macro. Let's rename it to avoid confusion. Acked-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-10-26crypto: ccree - fix comparison of unsigned expression warningTian Tao1-1/+2
This patch fixes the following warnings: drivers/crypto/ccree/cc_aead.c:630:5-12: WARNING: Unsigned expression compared with zero: seq_len > 0 Signed-off-by: Tian Tao <[email protected]> v2: change hmac_setkey() return type to unsigned int to fix the warning. Acked-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-09-13crypto: ccree - enable CTS support in AES-XTSUri Shir1-10/+6
In XTS encryption/decryption the plaintext byte size can be >= AES_BLOCK_SIZE. This patch enable the AES-XTS ciphertext stealing implementation in ccree driver. Signed-off-by: Uri Shir <[email protected]> Acked-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-09-05crypto: ccree - Rename arrays to avoid conflict with crypto/sha256.hHans de Goede1-76/+77
Rename the algo_init arrays to cc_algo_init so that they do not conflict with the functions declared in crypto/sha256.h. This is a preparation patch for folding crypto/sha256.h into crypto/sha.h. Signed-off-by: Hans de Goede <[email protected]> Acked-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-08-22crypto: ccree/des - switch to new verification routinesArd Biesheuvel2-31/+8
Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-08-09crypto: drivers - Remove dev_err() usage after platform_get_irq()Stephen Boyd1-3/+1
We don't need dev_err() messages when platform_get_irq() fails now that platform_get_irq() prints an error message itself when something goes wrong. Let's remove these prints with a simple semantic patch. // <smpl> @@ expression ret; struct platform_device *E; @@ ret = ( platform_get_irq(E, ...) | platform_get_irq_byname(E, ...) ); if ( \( ret < 0 \| ret <= 0 \) ) { ( -if (ret != -EPROBE_DEFER) -{ ... -dev_err(...); -... } | ... -dev_err(...); ) ... } // </smpl> While we're here, remove braces on if statements that only have one statement (manually). Cc: Greg Kroah-Hartman <[email protected]> Cc: Herbert Xu <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-08-09crypto: ccree - use std api sg_zero_bufferGilad Ben-Yossef3-24/+2
Replace internal cc_zero_sgl() with kernel API of the same function sg_zero_buffer(). Signed-off-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-08-09crypto: ccree - use the full crypt length valueGilad Ben-Yossef1-1/+1
In case of AEAD decryption verifcation error we were using the wrong value to zero out the plaintext buffer leaving the end of the buffer with the false plaintext. Signed-off-by: Gilad Ben-Yossef <[email protected]> Fixes: ff27e85a85bb ("crypto: ccree - add AEAD support") CC: [email protected] # v4.17+ Signed-off-by: Herbert Xu <[email protected]>
2019-07-27crypto: ccree - check assoclen for rfc4543Iuliana Prodan1-6/+20
Check assoclen to solve the extra tests that expect -EINVAL to be returned when the associated data size is not valid. Validated assoclen for RFC4543 which expects an assoclen of 16 or 20, the same as RFC4106. Based on seqiv, IPsec ESP and RFC4543/RFC4106 the assoclen is sizeof IP Header (spi, seq_no, extended seq_no) and IV len. This can be 16 or 20 bytes. Signed-off-by: Iuliana Prodan <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-07-26crypto: ccree - notify TEE on FIPS tests errorsGilad Ben-Yossef1-0/+23
Register a FIPS test failure notifier and use it to notify TEE side of FIPS test failures on our side prior to panic. Signed-off-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-07-26crypto: ccree - account for TEE not ready to reportGilad Ben-Yossef1-1/+7
When ccree driver runs it checks the state of the Trusted Execution Environment CryptoCell driver before proceeding. We did not account for cases where the TEE side is not ready or not available at all. Fix it by only considering TEE error state after sync with the TEE side driver. Signed-off-by: Gilad Ben-Yossef <[email protected]> Fixes: ab8ec9658f5a ("crypto: ccree - add FIPS support") CC: [email protected] # v4.17+ Signed-off-by: Herbert Xu <[email protected]>
2019-07-26crypto: ccree - drop legacy ivgen supportGilad Ben-Yossef9-466/+17
ccree had a mechanism for IV generation which was not compatible with the Linux seqiv or echainiv iv generator and was never used in any of the upstream versions so drop all the code implementing it. Signed-off-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-07-26crypto: ccree - fix spelling mistake "configration" -> "configuration"Colin Ian King1-1/+1
There is a spelling mistake in a dev_err message. Fix it. Signed-off-by: Colin Ian King <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-06-27crypto: ccree - add HW engine config checkGilad Ben-Yossef3-0/+38
Add check to verify the stated device tree HW configuration matches the HW. Signed-off-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-06-27crypto: ccree - prevent isr handling in case driver is suspendedOfir Drang3-0/+16
ccree irq may be shared with other devices, in order to prevent ccree isr handling while device maybe suspended we added a check to verify that the device is not suspended. Signed-off-by: Ofir Drang <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-06-27crypto: ccree - check that cryptocell reset completedOfir Drang4-1/+43
In case of driver probe and pm resume we need to check that the cryptocell hardware reset cycle is completed. during the reset cycle that Cryptocell provide read only access to the APB interface which allows to verify through the CC registers that the reset is completed. Until reset completion we assume that any write/crypto operation is blocked. Signed-off-by: Ofir Drang <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-06-27crypto: ccree - Relocate driver irq registration after clk init[email protected]1-9/+9
Signed-off-by: Ofir Drang <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-05-03crypto: ccree - use a proper le32 type for le32 valGilad Ben-Yossef1-1/+1
We build an explicit little endian value from the IDR register values. Use a proper le32 type to mark the var as such to satisfy Sparse. Signed-off-by: Gilad Ben-Yossef <[email protected]> Reported-by: kbuild test robot <[email protected]> Fixes: dcf6285d18ea1 ("crypto: ccree - add CID and PID support") Signed-off-by: Herbert Xu <[email protected]>
2019-05-03crypto: ccree - remove set but not used variable 'du_size'YueHaibing1-8/+0
Fixes gcc '-Wunused-but-set-variable' warning: drivers/crypto/ccree/cc_cipher.c: In function cc_setup_key_desc: drivers/crypto/ccree/cc_cipher.c:645:15: warning: variable du_size set but not used [-Wunused-but-set-variable] It is never used since introduction in commit dd8486c75085 ("crypto: ccree - move key load desc. before flow desc.") Signed-off-by: YueHaibing <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-05-03crypto: ccree - Make cc_sec_disable staticYueHaibing1-1/+1
Fix sparse warning: drivers/crypto/ccree/cc_driver.c:37:6: warning: symbol 'cc_sec_disable' was not declared. Should it be static? Signed-off-by: YueHaibing <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-05-03crypto: ccree - fix spelling mistake "protedcted" -> "protected"Colin Ian King1-1/+1
There is a spelling mistake in a dev_dbg message, fix it. Signed-off-by: Colin Ian King <[email protected]> Acked-By: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-04-25crypto: ccree - handle tee fips error during power management resumeOfir Drang1-1/+3
in order to support cryptocell tee fips error that may occurs while cryptocell ree is suspended, an cc_tee_handle_fips_error call added to the cc_pm_resume function. Signed-off-by: Ofir Drang <[email protected]> Signed-off-by: Gilad Ben-Yossef <[email protected]> Cc: [email protected] # v4.19+ Signed-off-by: Herbert Xu <[email protected]>
2019-04-25crypto: ccree - add function to handle cryptocell tee fips errorOfir Drang2-8/+17
Adds function that checks if cryptocell tee fips error occurred and in such case triggers system error through kernel panic. Change fips function to use this new routine. Signed-off-by: Ofir Drang <[email protected]> Signed-off-by: Gilad Ben-Yossef <[email protected]> Cc: [email protected] # v4.19+ Signed-off-by: Herbert Xu <[email protected]>
2019-04-25crypto: ccree - HOST_POWER_DOWN_EN should be the last CC access during suspendOfir Drang1-1/+1
During power management suspend the driver need to prepare the device for the power down operation and as a last indication write to the HOST_POWER_DOWN_EN register which signals to the hardware that The ccree is ready for power down. Signed-off-by: Ofir Drang <[email protected]> Signed-off-by: Gilad Ben-Yossef <[email protected]> Cc: [email protected] # v4.19+ Signed-off-by: Herbert Xu <[email protected]>
2019-04-25crypto: ccree - remove cc7x3 obsoleted AXIM configsOfir Drang1-5/+8
AXIM configuration register modified in cc7x3 and no longer includes AXI interrupt masking fields. Signed-off-by: Ofir Drang <[email protected]> Signed-off-by: Gilad Ben-Yossef <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-04-25crypto: ccree - pm resume first enable the source clkOfir Drang1-2/+3
On power management resume function first enable the device clk source to allow access to the device registers. Signed-off-by: Ofir Drang <[email protected]> Signed-off-by: Gilad Ben-Yossef <[email protected]> Cc: [email protected] # v4.19+ Signed-off-by: Herbert Xu <[email protected]>
2019-04-25crypto: ccree - don't map AEAD key and IV on stackGilad Ben-Yossef3-4/+23
The AEAD authenc key and IVs might be passed to us on stack. Copy it to a slab buffer before mapping to gurantee proper DMA mapping. Signed-off-by: Gilad Ben-Yossef <[email protected]> Cc: [email protected] # v4.19+ Signed-off-by: Herbert Xu <[email protected]>