History log of /optee_os/lib/libutee/tee_api_arith_mpi.c (Results 1 – 21 of 21)
Revision Date Author Comments
# 703ebb79 13-Jan-2025 Etienne Carriere <etienne.carriere@foss.st.com>

libtuee: allow NULL output coefficients in TEE_BigIntComputeExtendedGcd()

Fix TEE_BigIntComputeExtendedGcd() for when only one of u and v output
coefficients reference is NULL as allowed by the GP T

libtuee: allow NULL output coefficients in TEE_BigIntComputeExtendedGcd()

Fix TEE_BigIntComputeExtendedGcd() for when only one of u and v output
coefficients reference is NULL as allowed by the GP TEE Internal Core API
specification.

Reported-by: Stefan Schmidt <snst@meek.de>
Closes: https://github.com/OP-TEE/optee_os/issues/7217
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# b501c008 10-Nov-2023 Etienne Carriere <etienne.carriere@foss.st.com>

libutee: remove leftover references to libmpa

Removes references to libmpa removed since OP-TEE release tag 3.9.0,
by commit 7fb525f1f8a6 ("Remove libmpa in favor of libmbedtls").

This change remov

libutee: remove leftover references to libmpa

Removes references to libmpa removed since OP-TEE release tag 3.9.0,
by commit 7fb525f1f8a6 ("Remove libmpa in favor of libmbedtls").

This change removes configuration switch CFG_TA_MBEDTLS_MPI
and CFG_TA_MBEDTLS that are no more used by OP-TEE component.

Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>

show more ...


# 32b31808 06-Oct-2023 Jens Wiklander <jens.wiklander@linaro.org>

Squashed commit upgrading to mbedtls-3.4.0

Squash merging branch import/mbedtls-3.4.0

8225713449d3 ("libmbedtls: fix unrecognized compiler option")
f03730842d7b ("core: ltc: configure internal MD5"

Squashed commit upgrading to mbedtls-3.4.0

Squash merging branch import/mbedtls-3.4.0

8225713449d3 ("libmbedtls: fix unrecognized compiler option")
f03730842d7b ("core: ltc: configure internal MD5")
2b0d0c50127c ("core: ltc: configure internal SHA-1 and SHA-224")
0e48a6e17630 ("libmedtls: core: update to mbedTLS 3.4.0 API")
049882b143af ("libutee: update to mbedTLS 3.4.0 API")
982307bf6169 ("core: LTC mpi_desc.c: update to mbedTLS 3.4.0 API")
33218e9eff7b ("ta: pkcs11: update to mbedTLS 3.4.0 API")
6956420cc064 ("libmbedtls: fix cipher_wrap.c for NIST AES Key Wrap mode")
ad67ef0b43fd ("libmbedtls: fix cipher_wrap.c for chacha20 and chachapoly")
7300f4d97bbf ("libmbedtls: add fault mitigation in mbedtls_rsa_rsassa_pkcs1_v15_verify()")
cec89b62a86d ("libmbedtls: add fault mitigation in mbedtls_rsa_rsassa_pss_verify_ext()")
e7e048796c44 ("libmbedtls: add SM2 curve")
096beff2cd31 ("libmbedtls: mbedtls_mpi_exp_mod(): optimize mempool usage")
7108668efd3f ("libmbedtls: mbedtls_mpi_exp_mod(): reduce stack usage")
0ba4eb8d0572 ("libmbedtls: mbedtls_mpi_exp_mod() initialize W")
3fd6ecf00382 ("libmbedtls: fix no CRT issue")
d5ea7e9e9aa7 ("libmbedtls: add interfaces in mbedtls for context memory operation")
2b0fb3f1fa3d ("libmedtls: mpi_miller_rabin: increase count limit")
2c3301ab99bb ("libmbedtls: add mbedtls_mpi_init_mempool()")
9a111f0da04b ("libmbedtls: make mbedtls_mpi_mont*() available")
804fe3a374f5 ("mbedtls: configure mbedtls to reach for config")
b28a41531427 ("mbedtls: remove default include/mbedtls/config.h")
dfafe507bbef ("Import mbedtls-3.4.0")

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (vexpress-qemu_armv8a)

show more ...


# 28849def 13-Mar-2023 Jeffrey Kardatzke <jkardatzke@google.com>

libutee: increase MPI_MEMPOOL_SIZE to 14Kb

With the Widevine v17/v18 OPKs using their new Provisioning 4.0
technique, this pool size needs to be increased to 14Kb from 12Kb.

The sequence that is be

libutee: increase MPI_MEMPOOL_SIZE to 14Kb

With the Widevine v17/v18 OPKs using their new Provisioning 4.0
technique, this pool size needs to be increased to 14Kb from 12Kb.

The sequence that is being executed that requires this is as follows:
1. TEE_GenerateKey(key_handle, 2048, NULL, 0)
2. TEE_GetObjectBufferAttribute(key, TEE_ATTR_RSA_MODULUS,
modulus_data, &modulus_len),
same for TEE_ATTR_RSA_PUBLIC_EXPONENT and
TEE_ATTR_RSA_PRIVATE_EXPONENT.
3. mbedtls_rsa_complete() on a pk object created from the extracted
modulus, public exp and private exp.

Signed-off-by: Jeffrey Kardatzke <jkardatzke@google.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>

show more ...


# 6214424f 15-Dec-2022 Jens Wiklander <jens.wiklander@linaro.org>

GP131: add TEE_BigIntExpMod()

Adds the function TEE_BigIntExpMod() introduced in TEE Internal Core API
v1.2.

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklande

GP131: add TEE_BigIntExpMod()

Adds the function TEE_BigIntExpMod() introduced in TEE Internal Core API
v1.2.

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 3be980f7 15-Dec-2022 Jens Wiklander <jens.wiklander@linaro.org>

GP131: add TEE_BigIntAbs()

Adds the function TEE_BigIntAbs() introduced in TEE Internal Core API
v1.2.

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jen

GP131: add TEE_BigIntAbs()

Adds the function TEE_BigIntAbs() introduced in TEE Internal Core API
v1.2.

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 42023295 15-Dec-2022 Jens Wiklander <jens.wiklander@linaro.org>

GP131: add TEE_BigIntSetBit()

Adds the function TEE_BigIntSetBit() introduced in TEE Internal Core API
v1.2.

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklande

GP131: add TEE_BigIntSetBit()

Adds the function TEE_BigIntSetBit() introduced in TEE Internal Core API
v1.2.

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# af4bcf34 15-Dec-2022 Jens Wiklander <jens.wiklander@linaro.org>

GP131: add TEE_BigIntAssign()

Adds the function TEE_BigIntAssign() introduced in TEE Internal Core API
v1.2.

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklande

GP131: add TEE_BigIntAssign()

Adds the function TEE_BigIntAssign() introduced in TEE Internal Core API
v1.2.

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# fe03ed8b 02-Dec-2022 Jens Wiklander <jens.wiklander@linaro.org>

GP131: Update TEE_BigInt*() functions

Updates the following functions:
- TEE_BigIntInitFMMContext()
- TEE_BigIntFMMContextSizeInU32()
- TEE_BigIntFMMSizeInU32()
- TEE_BigIntInitFMMContext()
- TEE_Bi

GP131: Update TEE_BigInt*() functions

Updates the following functions:
- TEE_BigIntInitFMMContext()
- TEE_BigIntFMMContextSizeInU32()
- TEE_BigIntFMMSizeInU32()
- TEE_BigIntInitFMMContext()
- TEE_BigIntInitFMM()
- TEE_BigIntShiftRight()
according to TEE Internal Core API version 1.3.1. The modulusSizeInBits,
len, and bufferLen parameters are changed to use size_t instead of
uint32_t.

TEE_BigIntInitFMMContext1() is added.

TEE_BigIntInit() checks that supplied length isn't larger than
"gpd.tee.arith.maxBigIntSize", based on CFG_TA_BIGNUM_MAX_BITS.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 5bb4e062 24-Nov-2021 Jens Wiklander <jens.wiklander@linaro.org>

libutee: Fix warning in TEE_BigIntInvMod()

Fixes a -Wdeclaration-after-statement warning in TEE_BigIntInvMod:
lib/libutee/tee_api_arith_mpi.c: In function ‘TEE_BigIntInvMod’:
lib/libutee/tee_api_ari

libutee: Fix warning in TEE_BigIntInvMod()

Fixes a -Wdeclaration-after-statement warning in TEE_BigIntInvMod:
lib/libutee/tee_api_arith_mpi.c: In function ‘TEE_BigIntInvMod’:
lib/libutee/tee_api_arith_mpi.c:539:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
mbedtls_mpi mpi_dest;
^~~~~~~~~~~

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 66e18280 24-Nov-2021 Jens Wiklander <jens.wiklander@linaro.org>

libutee: Fix warning in bigint_binary_mod()

Fixes a -Wdeclaration-after-statement warning in bigint_binary_mod:
lib/libutee/tee_api_arith_mpi.c: In function ‘bigint_binary_mod’:
lib/libutee/tee_api_

libutee: Fix warning in bigint_binary_mod()

Fixes a -Wdeclaration-after-statement warning in bigint_binary_mod:
lib/libutee/tee_api_arith_mpi.c: In function ‘bigint_binary_mod’:
lib/libutee/tee_api_arith_mpi.c:358:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
mbedtls_mpi mpi_dest;
^~~~~~~~~~~
lib/libutee/tee_api_arith_mpi.c: In function ‘TEE_BigIntInvMod’:
lib/libutee/tee_api_arith_mpi.c:539:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
mbedtls_mpi mpi_dest;

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 13218059 01-Mar-2021 Matthieu BERTIN <matthieu.bertin@viaccess-orca.com>

libutee: fix memory leak in bigint_binary_mod()

The modulus variable (mpi_n) in bigint_binary_mod() is never released,
causing a memory leak in TEE_BigIntAddMod(), TEE_BigIntSubMod(),
TEE_BigIntMulM

libutee: fix memory leak in bigint_binary_mod()

The modulus variable (mpi_n) in bigint_binary_mod() is never released,
causing a memory leak in TEE_BigIntAddMod(), TEE_BigIntSubMod(),
TEE_BigIntMulMod() and TEE_BigIntSquareMod(). Add the missing call.

Signed-off-by: Matthieu BERTIN <matthieu.bertin@viaccess-orca.com>
Reviewed-by: Jerome Forissier <jerome@forissier.org>

show more ...


# b6fa905f 19-Feb-2021 Jens Wiklander <jens.wiklander@linaro.org>

libutee: remove redundant NULL check in TEE_BigIntComputeExtendedGcd()

The gcd parameter passed to TEE_BigIntComputeExtendedGcd() must not
be NULL so skip the unnecessary NULL check.

This fixes cov

libutee: remove redundant NULL check in TEE_BigIntComputeExtendedGcd()

The gcd parameter passed to TEE_BigIntComputeExtendedGcd() must not
be NULL so skip the unnecessary NULL check.

This fixes coverity scan:
CID 1501842 (#1 of 1): Dereference after null check (FORWARD_NULL)

Reviewed-by: Jerome Forissier <jerome@forissier.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# e6e7781f 14-Dec-2020 Jens Wiklander <jens.wiklander@linaro.org>

libutee: fix TEE_BigIntInit() memset()

The TEE_BigIntInit() supplied length is the number of words allocated
for the bigint, including headers. Prior to this patch it seems it was
assumed that lengt

libutee: fix TEE_BigIntInit() memset()

The TEE_BigIntInit() supplied length is the number of words allocated
for the bigint, including headers. Prior to this patch it seems it was
assumed that length was number of bits given the call to
TEE_BigIntSizeInU32(). With this patch correct this by removing the
TEE_BigIntSizeInU32() call.

Fixes: 062e3d01c039 ("ta: switch to to mbedtls for bignum")
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# a874dbbd 25-Aug-2020 Jens Wiklander <jens.wiklander@linaro.org>

libutee: fix TEE_BigIntDiv(): dest_q or dest_r may be NULL

Fixes TEE_BigIntDiv() to allow NULL values for dest_q and dest_r as
required by the GlobalPlatform spec.

Reviewed-by: Jerome Forissier <je

libutee: fix TEE_BigIntDiv(): dest_q or dest_r may be NULL

Fixes TEE_BigIntDiv() to allow NULL values for dest_q and dest_r as
required by the GlobalPlatform spec.

Reviewed-by: Jerome Forissier <jerome@forissier.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 2c028fde 23-Jun-2020 Jerome Forissier <jerome@forissier.org>

libutee, ldelf: add leading underscore to syscall wrappers

libutee defines assembler wrapper functions for each OP-TEE system call.
These wrappers have a utee_ prefix. This commit adds a leading
und

libutee, ldelf: add leading underscore to syscall wrappers

libutee defines assembler wrapper functions for each OP-TEE system call.
These wrappers have a utee_ prefix. This commit adds a leading
underscore so that the names cannot clash with user-defined symbols.
Doing so is common practice for "system" libraries, as defined by the C
standard in a set of requirements that can be summarized as follows
(excerpt from the GNU libc documentation [1]):

[R]eserved names include all external identifiers (global functions
and variables) that begin with an underscore (‘_’) and all identifiers
regardless of use that begin with either two underscores or an
underscore followed by a capital letter are reserved names. This is so
that the library and header files can define functions, variables, and
macros for internal purposes without risk of conflict with names in
user programs.

The utee_*() wrappers are internal to OP-TEE and are not supposed to be
called directly by TAs so this should not have any user-visible impact.

Link: [1] https://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html
Signed-off-by: Jerome Forissier <jerome@forissier.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>

show more ...


# 628e1eb0 22-May-2019 Jens Wiklander <jens.wiklander@linaro.org>

libutee: increase MPI mempool size

Increases MPI mempool size from 8Kb to 12Kb to be compensate for changes
in the (future) commit "libmbedtls: mbedtls_mpi_exp_mod(): reduce stack
usage" where mbedt

libutee: increase MPI mempool size

Increases MPI mempool size from 8Kb to 12Kb to be compensate for changes
in the (future) commit "libmbedtls: mbedtls_mpi_exp_mod(): reduce stack
usage" where mbedtls_mpi_exp_mod() is allocating an additional ~3Kb.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 7696ab7f 14-Mar-2019 Jens Wiklander <jens.wiklander@linaro.org>

libutee: lessen dependency on mbedtls internals

Until now tee_api_arith_mpi.c assumed that for instance
TEE_BigIntConvertFromOctetString() wouldn't do a
mbedtls_mpi_free(mpi);
mbedtls_mpi_init(mpi);

libutee: lessen dependency on mbedtls internals

Until now tee_api_arith_mpi.c assumed that for instance
TEE_BigIntConvertFromOctetString() wouldn't do a
mbedtls_mpi_free(mpi);
mbedtls_mpi_init(mpi);
sequence on the supplied mpi argument. Doing so replaces the special
allocation type MBEDTLS_MPI_ALLOC_TYPE_STATIC with
MBEDTLS_MPI_ALLOC_TYPE_MALLOC. This results in the value of the mpi
argument isn't propagated further to the dest argument of
TEE_BigIntConvertFromOctetString().

With this patch we're instead explicitly copying the value of
mbedtls_mpi to a TEE_BigInt when the value should be returned.

This patch is also needed when upgrading to mbedtls-2.16 or there will
be errors.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (QEMU, GP)
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# b2dd8747 05-Feb-2019 Jens Wiklander <jens.wiklander@linaro.org>

Fix alignment of data for mempool_alloc_pool()

Prior to this patch was _TEE_MathAPI_Init() in
lib/libutee/tee_api_arith_mpi.c supplying a data buffer which was only 4
byte aligned while mempool_allo

Fix alignment of data for mempool_alloc_pool()

Prior to this patch was _TEE_MathAPI_Init() in
lib/libutee/tee_api_arith_mpi.c supplying a data buffer which was only 4
byte aligned while mempool_alloc_pool() requires the alignment of long.
This will work in 32-bit mode, but could lead to alignment problem in
64-bit mode. The same problem can happen with
lib/libutee/tee_api_arith_mpa.c, but so far it has remained hidden.

Incorrect alignment can result in errors like:
E/TA: assertion '!((vaddr_t)data & (POOL_ALIGN - 1))' failed at lib/libutils/ext/mempool.c:134 in mempool_alloc_pool()

This fix introduces MEMPOOL_ALIGN which specifies required alignment of
data supplied to mempool_alloc_pool().

Fixes: 062e3d01c039 ("ta: switch to to mbedtls for bignum")
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Tested-by: Joakim Bech <joakim.bech@linaro.org> (QEMU v8)
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 98efc118 17-Jan-2019 Jerome Forissier <jerome.forissier@linaro.org>

mbedtls: TEE_BigIntMul(): use temporary

mbedtls_mpi_mul_mpi() checks the allocated size of the output number
before starting to multiply the numbers. It makes a conservative guess
by requiring the r

mbedtls: TEE_BigIntMul(): use temporary

mbedtls_mpi_mul_mpi() checks the allocated size of the output number
before starting to multiply the numbers. It makes a conservative guess
by requiring the result to be at least as large as the sum of the sizes
of the input numbers. For instance, if A fits in one "limb" and B fits
in two, then the result is expected to have nblimbs = 3 at least.
This is sometimes too restrictive. Consider A = 1 (can be represented
with nblimbs == 1 32-bit words) and B = 0x0FFFFFFFFFFFFFFF (fits in a
bignum with nblimbs == 2 32-bit words). A * B is equal to B and fits
in 2 limbs, but the current code requires 3.
This patch fixes the problem by allocating a big enough temporary
result.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 062e3d01 13-Nov-2018 Jens Wiklander <jens.wiklander@linaro.org>

ta: switch to to mbedtls for bignum

Adds tee_api_arith_mpi.c wrapper providing the TEE Arithmetical API around
the big (mpi) routines from mbedtls.

CFG_TA_MBEDTLS_MPI=y (default y) enables the usag

ta: switch to to mbedtls for bignum

Adds tee_api_arith_mpi.c wrapper providing the TEE Arithmetical API around
the big (mpi) routines from mbedtls.

CFG_TA_MBEDTLS_MPI=y (default y) enables the usage of the bignum routines
in libutee.

Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...