Commit Graph

35 Commits (b08ddaad8b9db97eba3fea4e6b0caf6eb36943be)

Author SHA1 Message Date
David Saada 41eb5cbfd9 Implement PSA protected storage & restructure PSA storage implementation
- Move all PSA storage code under psa/storage directory
- Create a global PSA error codes header, eliminating ITS specific ones
- Create a common header file for PSA storage type definitions,
  eliminating ITS specific ones
- Create a common implementation for PS & ITS
- Implement protected storage feature
- Change ITS test to be common to PS as well
2019-02-21 20:58:59 +02:00
Ron Eldor 77f9faf46c Use a mutex in platform setup \ teardown functions
Use a singleton Mutex in platforms_alt functions, to be shared
with the trng function, to save RAM. Rename `platform_alt.c`
to `platform_alt.cpp` as the mutex is in a `singletonPtr`
template class.
2019-02-18 11:43:32 +02:00
Alexander Zilberkant 4a204015ac Simplify entropy seed injection configuration
Move NVSEED callbacks configuration to a header file
2019-02-05 15:48:41 +02:00
Alexander Zilberkant 0622cc9865 Add header guard 2019-02-05 15:48:41 +02:00
Alexander Zilberkant 6e87615dc4 Fix compilation warning
Fix warning in entropy.c caused by injecting seed read & write callbacks
2019-02-05 15:48:41 +02:00
Martin Kojtal dcba5ffa3c
Merge pull request #9529 from kfnta/its_crypto
RollUp PR Crypto with ITS
2019-02-04 17:14:05 +01:00
Oren Cohen 156d3b785b Replace psa_prot_internal_storage.h with psa/internal_trusted_storage.h 2019-01-31 17:17:54 +02:00
Kevin Bracey 983503f9ee Mutex-protect mbedtls_hardware_poll
Like all HAL APIs, the calls in trng_api.h are not expected to
be thread-safe.

All current accesses to the TRNG HAL are currently via
`mbedtls_hardware_poll`.  Mbed TLS does not currently serialise these
calls itself, as `MBEDTLS_THREADING_C` is not enabled. But even if
Mbed TLS's own accesses were serialised, there are other direct
users of `mbedtls_hardware_poll` such as randLIB, that need to use
direct calls due to lack of API to extract entropy from Mbed TLS.

As such it makes sense to treat `mbedtls_hardware_poll` as a de facto
public Mbed OS API, akin to the C++ veneers on top of the HAL, and add a
PlatformMutex there so that it is safe for multithreaded use.
2019-01-29 12:45:48 +02:00
Ron Eldor cad40e1633 Rename the platform context varaiable
Rename the generic name `ctx` of `mbedtls_platform_context`
in `platform_alt.c` to a specific name `plat_ctx`, to avoid conflicts
when used as external in crypto modules.
2019-01-22 13:57:32 +02:00
Ron Eldor 4ea68829c5 Rename the platform specific crypto_platform
To avoid collisions between the psa `crypto_platform.h` file and the
platform specific `crypto_platform.h` file, for the init \ terminate
functions, rename the latter to `crypto_device_platform`.
2019-01-22 13:56:59 +02:00
Alastair D'Silva 2617c5d55b Don't use define checks on DEVICE_FOO macros (mbed code)
The DEVICE_FOO macros are always defined (either 0 or 1).

This patch replaces any instances of a define check on a DEVICE_FOO
macro with value test instead.

Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
2018-12-20 10:16:42 +11:00
Netanel Gonen f1c5aeb70e add MBEDTLS_PSA_CRYPTO_C defined to K64F PSA target 2018-11-27 14:02:55 +02:00
Mohammad AboMokh 819594477c Refactor trng_get_bytes() 2018-11-27 12:15:52 +02:00
Mohammad AboMokh b9ea334f1f Change __WEAK to MBED_WEAK 2018-11-27 12:15:26 +02:00
mohammad1603 4cef73d2eb Update output_length in trng_get_bytes() provided by psa. 2018-11-27 11:56:58 +02:00
Danny Shavit e72d910754 Add a weak implementation for trng_get_bytes() 2018-11-27 11:56:49 +02:00
Netanel Gonen 4816266205 add comment to explain why (-1 * rc) is returned 2018-11-27 11:56:44 +02:00
Netanel Gonen ae0fa609a9 remove psa_its_get_info from seed read function 2018-11-27 11:56:42 +02:00
Mohammad AboMokh 0fde6af120 change MBEDTLS_RANDOM_SEED_ITS_UID define to be PSA_CRYPTO_ITS_RANDOM_SEED_UID 2018-11-27 11:56:36 +02:00
Mohammad AboMokh 7b2c924ac7 Adding defualt behaviour for platforms without TRNG.
If setting the MBEDTLS_PLATFORM_NV_SEED_ALT and MBEDTLS_ENTROPY_NV_SEED flags and not
setting MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO and MBEDTLS_PLATFORM_NV_SEED_READ_MACRO flags
mbed-os will add an entropy source to the relevent partition - SPE in case of daul core or
in case of single core V7 to the main partition.

The defualt behaviour will be to read or write the data from the ITS.
2018-11-27 11:56:31 +02:00
Ron Eldor 2620508e12 Change Mbed TLS platform error code and value
Change error from `MBEDTLS_PLATFORM_HW_FAILED` to
`MBEDTLS_PLATFORM_HW_ACCEL_FAILED` and the value to 0x70,
as the previous value cannot be used as a low level error code.
2018-10-15 16:21:54 +03:00
Ron Eldor a2531b5674 Fix build error on IAR
IAR fails to build when a variable is initialized with empty curly braces.
Added `{ { 0 } }` to fix that.
2018-09-02 10:48:31 +03:00
Ron Eldor c1b6fdc5af Rename parameter name
Rename `obsolete_ctx` to `unused_ctx` as it is simply unused.
2018-08-31 13:53:29 +03:00
Ron Eldor 666ebe392a Change the terminate limit check
Check for counter to be `< 1` instead of `<= 0` before terminating.
2018-08-30 13:51:58 +03:00
Ron Eldor 1f5cee967d Address concurrency and style issues
1. Use atomic operations to increase and decrease counter.
2. Style fixes.
Remove unused function declaration.
2018-08-30 11:18:23 +03:00
Ron Eldor 479438953f Rename error codes
1. Rename error codes to fit Mbed TLS error code names.
2. Remove the Invalid input error code, as it's not used anymore.
2018-08-29 19:02:57 +03:00
Ron Eldor 127b68fbbc Make the platform context a global variable
Make the platform context a global variable,
adding the refernce counter to it.
2018-08-28 20:29:26 +03:00
Ron Eldor c3b31bc500 Add Mbed TLS Platform module errors
1. Add error codes for platform setup \ teardown.
2. Reassign `reference_count` to 0 after terminating platform,
and remove condition for 0
2018-06-04 14:01:59 +03:00
Ron Eldor ca94a49eff Add reference counter for platform context
1. Move the `mbedtls_platform_context` to be platform code, in `features/mbedtls/platfrom/`.
2. Add static refernce counter, to setup and teardown the platform code only once.
3. Adjust Cryptocell porting accordingly.
2018-06-04 10:38:49 +03:00
Janos Follath e9144ad771 Apply new naming convention to mbed TLS macros 2016-11-18 15:01:01 +00:00
Janos Follath 9137574e4d Move mbed TLS configuration symbol to macro section
The configuration option for the mbed TLS specific hardware acceleration
has to be in the macro section and not in the device capabilities
section in targets.json.

The option has also been renamed to better reflect its function.
2016-11-18 09:55:16 +00:00
Janos Follath 80aedd2f39 Move crypto hardware acceleration configuration
The crypto hardware acceleration might require defining a lot of mbed
TLS specific macros. Enumerating all of them in `targets.json` creates
too much noise, therefore we move it into a target specific mbed TLS
header.

The target with crypto hardware acceleration has to
        - indicate its capability in `targets.json` by adding "CRYPTO"
          to the "device_has" section
        - has to define his crypto hardware acceleration related macros
          in an `mbedtls_device.h` header
        - place the `mbedtls_device.h` file in the
          `features/mbedtls/targets/TARGET_XXXX`
          directory specific to the target
2016-11-17 14:38:04 +00:00
Andres AG 21a7b1de04 Modify mbedtls scripts to add config-no-entropy.h 2016-09-27 16:19:39 +01:00
Martin Kojtal 1b95c67dd2 mbedtls trng - remove MBEDTLS_ENTROPY_HARDWARE_ALT
MBEDTLS_ENTROPY_HARDWARE_ALT will be defined via config in mbedtls,
the mbed wrapper should use DEVICE_TRNG.
2016-09-27 09:16:28 +01:00
Martin Kojtal 1f8da7da34 mbedtls - move TRNG mbed impl into platform folder 2016-09-27 09:14:42 +01:00