| 60296dff | 29-Apr-2022 |
Andrew Davis <afd@ti.com> |
core: rng_hw: Add dummy hw_get_random_byte()
This is only used so we can start removing hw_get_random_byte() from platforms without causing compile errors. It is never called.
Signed-off-by: Andrew
core: rng_hw: Add dummy hw_get_random_byte()
This is only used so we can start removing hw_get_random_byte() from platforms without causing compile errors. It is never called.
Signed-off-by: Andrew Davis <afd@ti.com> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 391a3854 | 29-Apr-2022 |
Andrew Davis <afd@ti.com> |
core: Add hw_get_random_bytes()
Currently there are two options for supporting hardware RNG, implementing hw_get_random_byte() or overriding crypto_rng_read().
crypto_rng_read() is provided by eith
core: Add hw_get_random_bytes()
Currently there are two options for supporting hardware RNG, implementing hw_get_random_byte() or overriding crypto_rng_read().
crypto_rng_read() is provided by either a software PRNG or by a hardware RNG through a weak function in rng_hw.c. This weak function repeatedly calls hw_get_random_byte(). This can be an unneeded slowdown for platforms that fetch more than one byte of randomness per call to their HW RNG (all of them). The usual pattern is to store these extra bytes in a FIFO and feed them out one at a time. But since the only two callers of hw_get_random_byte() are themselves users of more than one byte this indirection is unnecessary. To get around this some platforms have also started overriding crypto_rng_read() which makes the API flow a bit less intuitive than it could be.
Plan here is that platforms only need to implement hw_get_random_bytes(). This can be called with length = 1 if we only need a single byte. But in the more common case we get a performance boost and simplify the RNG call flow.
To start we keep hw_get_random_byte() and have the new hw_get_random_bytes() use it to get platform HW RNG byte at a time. When we finish moving all plats over to hw_get_random_bytes() then hw_get_random_byte() can be removed.
Signed-off-by: Andrew Davis <afd@ti.com> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 90040fa4 | 06-May-2022 |
Sohaib ul Hassan <sohaib.ul.hassan@unikie.com> |
core: crypto: add X25519 support
This adds the X25519 core functionality and enables support for Curve25519 key attribute type for OP-TEE crypto syscalls.
Acked-by: Etienne Carriere <etienne.carrie
core: crypto: add X25519 support
This adds the X25519 core functionality and enables support for Curve25519 key attribute type for OP-TEE crypto syscalls.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Sohaib ul Hassan <sohaib.ul.hassan@unikie.com>
show more ...
|
| 44c8e3cb | 17-Sep-2018 |
Cedric Neveux <cedric.neveux@nxp.com> |
core: crypto: fix the RSA public key size for TA signature verification
The size of the RSA public key allocation should be based on the modulus size in bits.
Fixes: 064663e8b ("core: crypto: add s
core: crypto: fix the RSA public key size for TA signature verification
The size of the RSA public key allocation should be based on the modulus size in bits.
Fixes: 064663e8b ("core: crypto: add struct shdr helper functions") Signed-off-by: Cedric Neveux <cedric.neveux@nxp.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| cf23e962 | 09-Nov-2021 |
Jerome Forissier <jerome@forissier.org> |
crypto: build aes-gcm*.c files only when both AES and GCM are enabled
crypto/aes-gcm*.c need building only when both CFG_CRYPTO_AES and CFG_AES_GCM are enabled.
Signed-off-by: Jerome Forissier <jer
crypto: build aes-gcm*.c files only when both AES and GCM are enabled
crypto/aes-gcm*.c need building only when both CFG_CRYPTO_AES and CFG_AES_GCM are enabled.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| e3e4ce47 | 26-Apr-2021 |
Nicolas Toromanoff <nicolas.toromanoff@foss.st.com> |
drivers: crypto: implement crypto driver - AUTHENC
Add a generic cryptographic Authenticated Encryption driver interface connecting TEE Crypto generic APIs to HW driver interface.
Signed-off-by: Ni
drivers: crypto: implement crypto driver - AUTHENC
Add a generic cryptographic Authenticated Encryption driver interface connecting TEE Crypto generic APIs to HW driver interface.
Signed-off-by: Nicolas Toromanoff <nicolas.toromanoff@foss.st.com> Acked-by: Cedric Neveux <cedric.neveux@nxp.com> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| be501eb1 | 05-Oct-2021 |
Jorge Ramirez-Ortiz <jorge@foundries.io> |
util: rename ALIGNMENT_IS_OK to IS_ALIGNED_WITH_TYPE
Implement the renamed macro using the IS_ALIGNED definition.
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io> Reviewed-by: Etienne Carrie
util: rename ALIGNMENT_IS_OK to IS_ALIGNED_WITH_TYPE
Implement the renamed macro using the IS_ALIGNED definition.
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 16a1c178 | 09-Jul-2021 |
Jerome Forissier <jerome@forissier.org> |
crypto: optimize speed of AES CBC MAC
The current AES CBC MAC implementation invokes the AES CBC algorithm via crypto_cipher_update() for each 16-byte block of the input data. This can be inefficien
crypto: optimize speed of AES CBC MAC
The current AES CBC MAC implementation invokes the AES CBC algorithm via crypto_cipher_update() for each 16-byte block of the input data. This can be inefficient especially with hardware accelerated implementations which may have a significant overhead (I am thinking of proprietary implementations of MBed TLS for example).
This commit introduces a new config option: CFG_CRYPTO_CBC_MAC_BUNDLE_BLOCKS (default 64) which allows to bundle several 16-byte blocks of input data when calling the AES CBC function. Therefore with the default value, data are processed 1 KB at a time (assuming the caller provides enough data of course). There is a small memory overhead (malloc) of the same size at most.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| eee637e7 | 10-Feb-2021 |
Alexander Zakharov <uglym8@gmail.com> |
Add 3DES CMAC implementation
CMAC is a Cipher-Based MAC that improves some of the security deficiencies found in CBC-MAC. It is described in NIST SP800-38B as a mode of operation for approved symmet
Add 3DES CMAC implementation
CMAC is a Cipher-Based MAC that improves some of the security deficiencies found in CBC-MAC. It is described in NIST SP800-38B as a mode of operation for approved symmetric block chipers, namely AES and TDEA.
CMAC has similar use cases and security guarantees as HMAC, with the difference that it uses a different primitive (symmetric cipher instead of hash function). CMAC may be appropriate for information systems in which an approved block cipher is more readily available than an approved hash function.
Commonly it is used for symmetric key diversification (ASC X9 TR 31-2018), data integrity assurance (ICV).
CMAC is public domain.
OP-TEE core already supports for AES CMAC, but not TDEA CMAC. This commit adds TDEA CMAC support.
Signed-off-by: Alexander Zakharov <uglym8@gmail.com> Reviewed-by: Jerome Forissier <jerome@forissier.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> [jf: wrap commit description at 75 characters] Signed-off-by: Jerome Forissier <jerome@forissier.org>
show more ...
|
| 1e149c24 | 21-Jan-2021 |
Jerome Forissier <jerome@forissier.org> |
core: ltc: move sm2_kdf() to common core/crypto/sm2-kdf.c
The key derivation function sm2_kdf() is a helper function used by SM2 KEP (Key Exchange Protocol) and PKE (Private Key Encryption). It is c
core: ltc: move sm2_kdf() to common core/crypto/sm2-kdf.c
The key derivation function sm2_kdf() is a helper function used by SM2 KEP (Key Exchange Protocol) and PKE (Private Key Encryption). It is currently implemented in core/lib/libtomcrypt/sm2_kdf.c, next to the SM2 source code based on LibTomCrypt.
In order to provide an MBed TLS implementation of SM2, the helper function shall be outside the LibTomCrypt directory. Move it to core/crypto/sm2-kdf.c.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| 4cfcf345 | 14-Dec-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: copy mode in cts_copy_state()
Fixes cts_copy_state() by copying the "mode" element also for the state to be complete.
Fixes: 96098f011f7c ("core: crypto: introduce struct crypto_cipher_ops")
core: copy mode in cts_copy_state()
Fixes cts_copy_state() by copying the "mode" element also for the state to be complete.
Fixes: 96098f011f7c ("core: crypto: introduce struct crypto_cipher_ops") Acked-by: Jerome Forissier <jerome@forissier.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Reported-by: Tony He <tony.he@armchina.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 5dfe86d0 | 25-Aug-2020 |
Jorge Ramirez-Ortiz <jorge@foundries.io> |
core: svc store: delete keys from secure elements
The cryptographic API provides an interface for the creation of cryptographic keys.
These keys can be stored in secure elements and handlers to the
core: svc store: delete keys from secure elements
The cryptographic API provides an interface for the creation of cryptographic keys.
These keys can be stored in secure elements and handlers to these keys (since the keys themselves can not be read from the secure elements) given back to the caller.
When the object holding a key is being deleted, the cryptographic API must be informed in order to proceed with the deletion of the real key from the secure element.
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| 884fd190 | 02-Nov-2020 |
Cedric Neveux <cedric.neveux@nxp.com> |
core: crypto: add encrypt/decrypt to crypto_ecc_[public/keypair]_ops
Add encypt and decrypt methods to respectively the crypto_ecc_public_ops and the crypto_ecc_keypair_ops structure. Method used fo
core: crypto: add encrypt/decrypt to crypto_ecc_[public/keypair]_ops
Add encypt and decrypt methods to respectively the crypto_ecc_public_ops and the crypto_ecc_keypair_ops structure. Method used for the SM2 PKE algorithms.
Signed-off-by: Cedric Neveux <cedric.neveux@nxp.com> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 08e47d6b | 07-Oct-2020 |
Cedric Neveux <cedric.neveux@nxp.com> |
core: crypto: unify ECC and SM2_DSA sign/verify
Remove the crypto_acipher_sm2_dsa_sign/crypto_acipher_sm2_dsa_verify functions and call the crypto_acipher_ecc_sign/crypto_acipher_ecc_verify function
core: crypto: unify ECC and SM2_DSA sign/verify
Remove the crypto_acipher_sm2_dsa_sign/crypto_acipher_sm2_dsa_verify functions and call the crypto_acipher_ecc_sign/crypto_acipher_ecc_verify functions that are calling the ecc key operations set.
Signed-off-by: Cedric Neveux <cedric.neveux@nxp.com> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| df00cf59 | 06-Oct-2020 |
Cedric Neveux <cedric.neveux@nxp.com> |
core: crypto: add struct crypto_ecc_[public/keypair]_ops
In order to enable one ECC HW driver and one ECC SW library at build and runtime, introduces struct crypto_ecc_public_ops and struct crypto_e
core: crypto: add struct crypto_ecc_[public/keypair]_ops
In order to enable one ECC HW driver and one ECC SW library at build and runtime, introduces struct crypto_ecc_public_ops and struct crypto_ecc_keypair_ops respectively to the struct ecc_public_key and struct ecc_keypair.
At key (public/keypair) allocation, the HW driver is first called and if key type/size not supported, the SW library is then called. When key is allocated with success, the key->ops is set with the cryptographic functions pointer to call when using keys to: - Generate keypair - Sign with keypair - Shared secret with keypair - Verify with public key - Free public key
Signed-off-by: Cedric Neveux <cedric.neveux@nxp.com> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| a1d5c81f | 11-Aug-2020 |
Elias von Däniken <elias.vondaeniken@bluewin.ch> |
crypto: add function to free rsa keypair
There was no function to proper free a rsa kepair from inside a PTA. Now there is crypto_acipher_free_rsa_keypair().
Signed-off-by: Elias von Däniken <elias
crypto: add function to free rsa keypair
There was no function to proper free a rsa kepair from inside a PTA. Now there is crypto_acipher_free_rsa_keypair().
Signed-off-by: Elias von Däniken <elias.vondaeniken@bluewin.ch> Acked-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| b2b27623 | 06-May-2020 |
Sander Visser <github@visser.se> |
core: refactoring to avoid possible NULL_PTR arithmetics
Issue detected by Cppcheck in internal_aes_gcm_ghash_update(). Issue mitigated by adding an argument check that prevents passing a pointer on
core: refactoring to avoid possible NULL_PTR arithmetics
Issue detected by Cppcheck in internal_aes_gcm_ghash_update(). Issue mitigated by adding an argument check that prevents passing a pointer on that is calculated with NULL as base.
Also fixed a cast in the same code lines to keep constness.
Signed-off-by: Sander Visser <github@visser.se> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| f0ead748 | 16-Jun-2020 |
Jerome Forissier <jerome@forissier.org> |
core: crypto: fix invalid SM3 output with Clang -Os
Several crypto tests fail when OP-TEE is built with Clang in non-debug mode, more precisely with -Os. xtest numbers 4001, 4002, 4006 and 4014 are
core: crypto: fix invalid SM3 output with Clang -Os
Several crypto tests fail when OP-TEE is built with Clang in non-debug mode, more precisely with -Os. xtest numbers 4001, 4002, 4006 and 4014 are impacted.
The root cause is the shift operations in the ROTL(x, n) are undefined when n > 32 because the values to shift are uint32_t, but the macro is used with 0 <= n < 64.
By masking n with 0x1F (thus implementing a modulo 32), we continue rotating the bits when n >= 32.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
show more ...
|
| ea9ac29c | 13-Aug-2019 |
Cedric Neveux <cedric.neveux@nxp.com> |
drivers: crypto: generic resources for crypto MAC driver - MAC
Add a generic cryptographic driver MAC interface connecting TEE Crypto generic APIs to HW driver interface
Signed-off-by: Cedric Neveu
drivers: crypto: generic resources for crypto MAC driver - MAC
Add a generic cryptographic driver MAC interface connecting TEE Crypto generic APIs to HW driver interface
Signed-off-by: Cedric Neveux <cedric.neveux@nxp.com> Signed-off-by: Clement Faure <clement.faure@nxp.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| 21282bae | 16-Apr-2020 |
Jerome Forissier <jerome@forissier.org> |
core: crypto: ECC: make sure key_size is consistent with attributes
TEE_GenerateKey() takes a key_size argument and various attributes. If the size derived from the attributes is not key_size, we sh
core: crypto: ECC: make sure key_size is consistent with attributes
TEE_GenerateKey() takes a key_size argument and various attributes. If the size derived from the attributes is not key_size, we should return TEE_ERROR_BAD_PARAMETERS as per the GP TEE Internal Core API specification v1.2.1: "If an incorrect or inconsistent attribute is detected. The checks that are performed depend on the implementation.".
Signed-off-by: Jerome Forissier <jerome@forissier.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 9f4dcefb | 16-Apr-2020 |
Jerome Forissier <jerome@forissier.org> |
core: crypto: DH: make sure key_size is consistent with attributes
TEE_GenerateKey() takes a key_size argument and various attributes. For Diffie-Hellman, if the size of the prime number (TEE_ATTR_D
core: crypto: DH: make sure key_size is consistent with attributes
TEE_GenerateKey() takes a key_size argument and various attributes. For Diffie-Hellman, if the size of the prime number (TEE_ATTR_DH_PRIME) is not key_size, we should return TEE_ERROR_BAD_PARAMETERS as per the GP TEE Internal Core API specification v1.2.1: "If an incorrect or inconsistent attribute is detected. The checks that are performed depend on the implementation.".
Signed-off-by: Jerome Forissier <jerome@forissier.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 80f47278 | 30-Mar-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: drop __weak from internal_aes_gcm_update_payload_blocks()
Removes the __weak attribute from internal_aes_gcm_update_payload_blocks() now that both AArch32 and AArch64 have an optimized replace
core: drop __weak from internal_aes_gcm_update_payload_blocks()
Removes the __weak attribute from internal_aes_gcm_update_payload_blocks() now that both AArch32 and AArch64 have an optimized replacement.
The previous __weak internal_aes_gcm_update_payload_blocks() is now moved into core/crypto/aes-gcm-sw.c with its helper functions.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 1df59751 | 30-Mar-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: crypto: remove internal_aes_gcm_expand_enc_key()
Removes internal_aes_gcm_expand_enc_key() which is replaced by crypto_aes_expand_enc_key().
Reviewed-by: Etienne Carriere <etienne.carriere@li
core: crypto: remove internal_aes_gcm_expand_enc_key()
Removes internal_aes_gcm_expand_enc_key() which is replaced by crypto_aes_expand_enc_key().
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 8a15c688 | 30-Mar-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: update AArch64 GHASH acceleration routines
Update AArch64 GHASH acceleration routines for improved performance.
The core parts of assembly and wrapper updates are written by Ard Biesheuvel <a
core: update AArch64 GHASH acceleration routines
Update AArch64 GHASH acceleration routines for improved performance.
The core parts of assembly and wrapper updates are written by Ard Biesheuvel <ard.biesheuvel@linaro.org>, see [1].
Link: [1] https://github.com/torvalds/linux/commit/22240df7ac6d76a271197571a7be45addef2ba15 Acked-by: Jerome Forissier <jerome@forissier.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 8f848cdb | 30-Mar-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: crypto: add internal_aes_gcm_{en,de}crypt_block()
Adds internal_aes_gcm_encrypt_block() and internal_aes_gcm_decrypt_block() to encrypt or decrypt a well aligned AES-GCM payload block.
Review
core: crypto: add internal_aes_gcm_{en,de}crypt_block()
Adds internal_aes_gcm_encrypt_block() and internal_aes_gcm_decrypt_block() to encrypt or decrypt a well aligned AES-GCM payload block.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|