Commit Graph

2159 Commits

Author SHA1 Message Date
Steffen Jaeckel
33a26c4959 introduce separate aes_desc
`aes_desc` and `aes_enc_desc` now do auto-detection of the best suitable
AES implementation for the platform.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Steffen Jaeckel
2a8e6a229c Disable warnings from clang
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Steffen Jaeckel
a0388ef11f add CI testrun with AESNI
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Steffen Jaeckel
13fd324a3b add support for AES-NI instructions
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Steffen Jaeckel
1bfb07a0c8 Add LTC_TMPVAR() macro
Use unique names for variables declared in macros.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Steffen Jaeckel
a27da4aa22 cmake: add ccache support
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
a5249753ce Add correct MPI provider defines to pkg-config cflags
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
ce021c898c cmake: Add TomsFastMath support
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
a8081c5641 also update pkg-config file generated by cmake
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
046443467d update Libs part of pkg-config file with configured MPI providers
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
e9c0b9f34c Remove pre-installed libtommath
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
c2e27cf9a5 More error logs on CI failure
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
2156b240e8 Fix missing include paths of ltm and tfm
Default include paths of ltm and tfm have changed.
Try to get include paths from pkg-config.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
410bd9188f Fix Valgrind CI run when building with Clang
Clang creates now DWARFv5 debug infos which isn't supported in old Valgrind
versions. Instruct Clang to create DWARFv4 debug infos, so we can run our
tests in Valgrind.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
bebf2ffd65 Calm scan-build static analyser
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
024392e941 Update base OS version of CI
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
4e8fc0e04e ensure that input-data pointer is non-NULL
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
effe0e8e21 allow input-data pointer to be NULL
If we allow the length to be 0, we should also prepare for the case where
the user doesn't want to provide a valid input-data pointer.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Safae Ouajih
af5fffb8a7 fix pkcs_1_v1_5_decode() when empty message
In case of EME-PKCS1-v1_5 decoding, the encoded message
format is as follow : EM = 0x00 || 0x02 || PS || 0x00 || M.
When using an empty message, the 0x00 octet that separates
the padding string and message is located at the end. Thus,
update the condition to pass the check in case of empty message.

This fixes the following AOSP cts test:
Module: CtsKeystoreTestCases
Test: testEmptyPlaintextEncryptsAndDecrypts
Link: https://android.googlesource.com/platform/cts/+/refs/tags/android-cts-12.0_r6/tests/tests/keystore/src/android/keystore/cts/CipherTest.java

Signed-off-by: Safae Ouajih <souajih@baylibre.com>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
299a9eb565 fix help message of aesgcm demo
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steve Manley
316c07b31c Fix CMakeLists.txt which still used variables from the ltm port
It still used `LTM_{C,LD}_FLAGS` instead of `LTC_{C,LD}_FLAGS`.
2024-02-18 17:02:09 +00:00
Jin
9bb2608aa1 Added gcm_reset() to gcm_memory() to avoid key leakage 2024-02-18 17:02:09 +00:00
Steffen Jaeckel
f37aad3f06 create developer manual in CI
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
c9348e43a0 use correct Build Status badge in README
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
5a33be0dbc improve MPI providers section in documentation
.. also add a checkbox regarding MPI providers to the issue template

This closes #605

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
97d0f61491 port cmake integration changes from libtommath
... also enable building of tests.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Adrian Antonana
d07a66f9b2 introduce initial cmake support 2024-02-18 17:02:09 +00:00
Steffen Jaeckel
82ec3fea54 remove camellia tests if LTC_TEST is not defined
Fixes #600

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
3c05f2b65a fix incompatibility issues with LLP64 data models
This is also a fixup of a921112fe32fce1d5cce386ab09d3edcaa004c51

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
791e5e7098 don't overwrite arguments
There's no need to store those values first somewhere else.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
1c303e8c13 optimize stack arrays
* minimize stack usage
* no need to zero-initialize the arrays

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
bb7712bd64 ensure that ctx is non-NULL
The code-path via the `ed25519ph_*()` APIs would have allowed to get here
and de-reference `ctx` even if it is `NULL`.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
fd41f04026 re-factor tweetnacl_crypto_hash[_ctx]()
@etienne-lms remarked in [0] that the stack usage could be minimized
by using `hash_memory_multi()` instead of copying the data, so let's do
that.

[0] https://github.com/OP-TEE/optee_os/pull/5486#discussion_r955095821

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
25b724e0d8 Update makefiles 2024-02-18 17:02:08 +00:00
Steffen Jaeckel
df529c3cbc add test-case that uses LTC_NO_NULL_TERMINATION_CHECK
It's a compile-only test, but we run it anyways so we can finally get
`crypt_fsa()` included in the coverage report. It's not really useful but
also doesn't hurt.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
f73a6893ef fix possible UB
A user isn't guaranteed to use the `der_..._multi()` in a correct fashion.
Therefor change the pattern in the library and terminate further vararg
processing immediately after the `EOL` marker is hit.

The previous changes introducing the function-`attribute(sentinel)` would
allow detecting this, but not all compilers have support for the attribute.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
ae1c26842b use LTC_NULL in the library code
`NULL` as defined by the standard is not guaranteed to be of a pointer
type. In order to make sure that in vararg API's a pointer type is used,
define our own version and use that one internally.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
1277dab32a introduce LTC_NULL_TERMINATED function attribute
In order to be able to check at compile time whether a vararg function
is correctly NULL-terminated.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
0507657b07 Update makefiles 2024-02-18 17:02:08 +00:00
Steffen Jaeckel
57c90507ae re-factor some parts of the Ed25519ctx and Ed25519ph implementation
* The RFC doesn't limit the context to be a string.
  It talks about `octets` which means it could be any binary data.
* Move the context-preprocessing function out of tweetnacl.c
* Fix potential segfaults when Ed25519 signature verification fails and
  `LTC_CLEAN_STACK` is enabled.
* Fix all the warnings.
* Update documentation.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Valerii Chubar
3f91f261ff Add ed25519ctx and ed25519ph support
Signed-off-by: Valerii Chubar <valerii_chubar@epam.com>
Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
2024-02-18 17:02:08 +00:00
Valerii Chubar
a37f4ca5df ed25519: Add testcase for segfault on verify
In case when the signature is not verified the "mlen" variable
is equal to ULONG_MAX. When LTC_CLEAN_STACK has been defined
this results in a segmentation fault.

Signed-off-by: Valerii Chubar <valerii_chubar@epam.com>
Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
142d5033f1 Ensure that hash overflow is detected
Previously it was not detected if `inlen` itself was too big and would
overflow the multiplication by 8.

Related to #592

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
243099fee7 also build with MSVC 2019 & 2022
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Oliver Schneider
aa6dcd8de6 Spelling fix in tomcrypt_cfg.h 2024-02-18 17:02:08 +00:00
Steffen Jaeckel
8059e5a097 fix sporadically failing tests when built with pthreads support
... I hope ... :)

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Steffen Jaeckel
599d4861a3 make sure to check yarrow_read() return values
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Steffen Jaeckel
64010a939b pack up failed build to be able to investigate
Sometimes it's hard to reproduce an issue as they happen on CI, so let's
pack-up what we can on failure and upload it as artifact.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Steffen Jaeckel
2af7e7e65d add hash Id to docs 2024-02-18 17:02:07 +00:00
Steffen Jaeckel
fdd96a7fbc add cipher Id to docs
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00