Commit Graph

2172 Commits

Author SHA1 Message Date
Steffen Jaeckel
9a05c23516 Add Testcase for #627
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:03:01 +00:00
Steffen Jaeckel
17372d2e88 Fix build for Windows ARM (UWP)
This fixes #576

Patch inspired by the same, but modified.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:03:01 +00:00
Steffen Jaeckel
29d29ca170 Add support for reading random data from "bcrypt" on Windows
This fixes #577

Patch inspired by the same, but simplified after reading the docs.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:03:01 +00:00
Steffen Jaeckel
c3a9a04c1b Add empty stub for s_der_tests_print_flexi()
So we don't have to `#ifdef` whether it's available or not.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Steffen Jaeckel
d463dab6d6 Fix DER decoding of UTF-8 Strings
Don't read more than the length indicated by the length field.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Steffen Jaeckel
d8d99887b5 Add Testcase that UTF-8 decoding respects the ASN.1 length
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Steffen Jaeckel
fc6be6b4f5 Fix some pkg-config related things
* use a separate `libtomcrypt` folder to install the headers to
* use `INCPATH` and `LIBPATH` when installing `libtomcrypt.pc`
* fix `libtomcrypt.pc` generation for `makefile.unix`

This fixes #625

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Steffen Jaeckel
d4cc1e5214 Port CMake changes from libtommath for Debian packaging
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
ycaibb
6741c76089 fix missing mutex unlock
Fixes a missing mutex unlock on an out of memory error
in ltc_ecc_fp_save_state().

Originates from: 4af447d408

Fixes #571

Comment by sj:
This patch version slightly deviates from the original patch to OP-TEE
since we don't call `XFREE(NULL)` as there exist implementations of
`free()` that don't support it.

Signed-off-by: Ryan Cai <ycaibb@gmail.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Modified-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Ulrich Koschella
03b3538830 Fixed size check in ecc_get_key, Fixes #630 2024-02-18 17:02:10 +00:00
Steffen Jaeckel
71c93ed301 Add Testcase for #630
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Ulrich Koschella
a96794c9c5 Fixed wrong sign in docu of ECC Extended Key Generation, Fixes #628 2024-02-18 17:02:10 +00:00
Steffen Jaeckel
0920839c68 Update makefiles
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
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