Move crypto modules

Move all the modules that constitute
the crypto library as well as the
associated headers to tf-psa-crypto/core
for the PSA core modules and to
tf-psa-crypto/drivers/builtin/src for
the others.

The common.h file is copied instead of
being just moved as eventually they
will be different in mbedtls and
TF-PSA-Crypto. Some parts of it can be
shared though but this will be done later,
probably when adding the CMake build
system in tf-psa-crypto.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/library/.gitignore b/library/.gitignore
index c6a39f5..9794129 100644
--- a/library/.gitignore
+++ b/library/.gitignore
@@ -6,6 +6,4 @@
 /error.c
 /version_features.c
 /ssl_debug_helpers_generated.c
-/psa_crypto_driver_wrappers.h
-/psa_crypto_driver_wrappers_no_static.c
 ###END_GENERATED_FILES###
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index e2562df..69bd6f5 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -324,11 +324,9 @@
 
 foreach(target IN LISTS target_libraries)
     add_library(MbedTLS::${target} ALIAS ${target})  # add_subdirectory support
-    # Include public header files from /include and other directories
-    # declared by /3rdparty/**/CMakeLists.txt. Include private header files
-    # from /library and others declared by /3rdparty/**/CMakeLists.txt.
-    # /library needs to be listed explicitly when building .c files outside
-    # of /library (which currently means: under /3rdparty).
+    # Include public header files from /include, tf-psa-crypto/include/ and
+    # /tf-psa-crypto/drivers/builtin/include/. Include private header files
+    # from /library.
     target_include_directories(${target}
         PUBLIC $<BUILD_INTERFACE:${MBEDTLS_DIR}/include/>
                $<BUILD_INTERFACE:${MBEDTLS_DIR}/tf-psa-crypto/include/>
diff --git a/tf-psa-crypto/core/.gitignore b/tf-psa-crypto/core/.gitignore
new file mode 100644
index 0000000..70d9d04
--- /dev/null
+++ b/tf-psa-crypto/core/.gitignore
@@ -0,0 +1,4 @@
+###START_GENERATED_FILES###
+/psa_crypto_driver_wrappers.h
+/psa_crypto_driver_wrappers_no_static.c
+###END_GENERATED_FILES###
diff --git a/library/alignment.h b/tf-psa-crypto/core/alignment.h
similarity index 100%
rename from library/alignment.h
rename to tf-psa-crypto/core/alignment.h
diff --git a/tf-psa-crypto/core/common.h b/tf-psa-crypto/core/common.h
new file mode 100644
index 0000000..3936ffd
--- /dev/null
+++ b/tf-psa-crypto/core/common.h
@@ -0,0 +1,435 @@
+/**
+ * \file common.h
+ *
+ * \brief Utility macros for internal use in the library
+ */
+/*
+ *  Copyright The Mbed TLS Contributors
+ *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
+ */
+
+#ifndef MBEDTLS_LIBRARY_COMMON_H
+#define MBEDTLS_LIBRARY_COMMON_H
+
+#include "mbedtls/build_info.h"
+#include "alignment.h"
+
+#include <assert.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stddef.h>
+
+#if defined(__ARM_NEON)
+#include <arm_neon.h>
+#define MBEDTLS_HAVE_NEON_INTRINSICS
+#elif defined(MBEDTLS_PLATFORM_IS_WINDOWS_ON_ARM64)
+#include <arm64_neon.h>
+#define MBEDTLS_HAVE_NEON_INTRINSICS
+#endif
+
+/** Helper to define a function as static except when building invasive tests.
+ *
+ * If a function is only used inside its own source file and should be
+ * declared `static` to allow the compiler to optimize for code size,
+ * but that function has unit tests, define it with
+ * ```
+ * MBEDTLS_STATIC_TESTABLE int mbedtls_foo(...) { ... }
+ * ```
+ * and declare it in a header in the `library/` directory with
+ * ```
+ * #if defined(MBEDTLS_TEST_HOOKS)
+ * int mbedtls_foo(...);
+ * #endif
+ * ```
+ */
+#if defined(MBEDTLS_TEST_HOOKS)
+#define MBEDTLS_STATIC_TESTABLE
+#else
+#define MBEDTLS_STATIC_TESTABLE static
+#endif
+
+#if defined(MBEDTLS_TEST_HOOKS)
+extern void (*mbedtls_test_hook_test_fail)(const char *test, int line, const char *file);
+#define MBEDTLS_TEST_HOOK_TEST_ASSERT(TEST) \
+    do { \
+        if ((!(TEST)) && ((*mbedtls_test_hook_test_fail) != NULL)) \
+        { \
+            (*mbedtls_test_hook_test_fail)( #TEST, __LINE__, __FILE__); \
+        } \
+    } while (0)
+#else
+#define MBEDTLS_TEST_HOOK_TEST_ASSERT(TEST)
+#endif /* defined(MBEDTLS_TEST_HOOKS) */
+
+/** \def ARRAY_LENGTH
+ * Return the number of elements of a static or stack array.
+ *
+ * \param array         A value of array (not pointer) type.
+ *
+ * \return The number of elements of the array.
+ */
+/* A correct implementation of ARRAY_LENGTH, but which silently gives
+ * a nonsensical result if called with a pointer rather than an array. */
+#define ARRAY_LENGTH_UNSAFE(array)            \
+    (sizeof(array) / sizeof(*(array)))
+
+#if defined(__GNUC__)
+/* Test if arg and &(arg)[0] have the same type. This is true if arg is
+ * an array but not if it's a pointer. */
+#define IS_ARRAY_NOT_POINTER(arg)                                     \
+    (!__builtin_types_compatible_p(__typeof__(arg),                \
+                                   __typeof__(&(arg)[0])))
+/* A compile-time constant with the value 0. If `const_expr` is not a
+ * compile-time constant with a nonzero value, cause a compile-time error. */
+#define STATIC_ASSERT_EXPR(const_expr)                                \
+    (0 && sizeof(struct { unsigned int STATIC_ASSERT : 1 - 2 * !(const_expr); }))
+
+/* Return the scalar value `value` (possibly promoted). This is a compile-time
+ * constant if `value` is. `condition` must be a compile-time constant.
+ * If `condition` is false, arrange to cause a compile-time error. */
+#define STATIC_ASSERT_THEN_RETURN(condition, value)   \
+    (STATIC_ASSERT_EXPR(condition) ? 0 : (value))
+
+#define ARRAY_LENGTH(array)                                           \
+    (STATIC_ASSERT_THEN_RETURN(IS_ARRAY_NOT_POINTER(array),         \
+                               ARRAY_LENGTH_UNSAFE(array)))
+
+#else
+/* If we aren't sure the compiler supports our non-standard tricks,
+ * fall back to the unsafe implementation. */
+#define ARRAY_LENGTH(array) ARRAY_LENGTH_UNSAFE(array)
+#endif
+/** Allow library to access its structs' private members.
+ *
+ * Although structs defined in header files are publicly available,
+ * their members are private and should not be accessed by the user.
+ */
+#define MBEDTLS_ALLOW_PRIVATE_ACCESS
+
+/**
+ * \brief       Securely zeroize a buffer then free it.
+ *
+ *              Similar to making consecutive calls to
+ *              \c mbedtls_platform_zeroize() and \c mbedtls_free(), but has
+ *              code size savings, and potential for optimisation in the future.
+ *
+ *              Guaranteed to be a no-op if \p buf is \c NULL and \p len is 0.
+ *
+ * \param buf   Buffer to be zeroized then freed.
+ * \param len   Length of the buffer in bytes
+ */
+void mbedtls_zeroize_and_free(void *buf, size_t len);
+
+/** Return an offset into a buffer.
+ *
+ * This is just the addition of an offset to a pointer, except that this
+ * function also accepts an offset of 0 into a buffer whose pointer is null.
+ * (`p + n` has undefined behavior when `p` is null, even when `n == 0`.
+ * A null pointer is a valid buffer pointer when the size is 0, for example
+ * as the result of `malloc(0)` on some platforms.)
+ *
+ * \param p     Pointer to a buffer of at least n bytes.
+ *              This may be \p NULL if \p n is zero.
+ * \param n     An offset in bytes.
+ * \return      Pointer to offset \p n in the buffer \p p.
+ *              Note that this is only a valid pointer if the size of the
+ *              buffer is at least \p n + 1.
+ */
+static inline unsigned char *mbedtls_buffer_offset(
+    unsigned char *p, size_t n)
+{
+    return p == NULL ? NULL : p + n;
+}
+
+/** Return an offset into a read-only buffer.
+ *
+ * Similar to mbedtls_buffer_offset(), but for const pointers.
+ *
+ * \param p     Pointer to a buffer of at least n bytes.
+ *              This may be \p NULL if \p n is zero.
+ * \param n     An offset in bytes.
+ * \return      Pointer to offset \p n in the buffer \p p.
+ *              Note that this is only a valid pointer if the size of the
+ *              buffer is at least \p n + 1.
+ */
+static inline const unsigned char *mbedtls_buffer_offset_const(
+    const unsigned char *p, size_t n)
+{
+    return p == NULL ? NULL : p + n;
+}
+
+/* Always inline mbedtls_xor() for similar reasons as mbedtls_xor_no_simd(). */
+#if defined(__IAR_SYSTEMS_ICC__)
+#pragma inline = forced
+#elif defined(__GNUC__)
+__attribute__((always_inline))
+#endif
+/**
+ * Perform a fast block XOR operation, such that
+ * r[i] = a[i] ^ b[i] where 0 <= i < n
+ *
+ * \param   r Pointer to result (buffer of at least \p n bytes). \p r
+ *            may be equal to either \p a or \p b, but behaviour when
+ *            it overlaps in other ways is undefined.
+ * \param   a Pointer to input (buffer of at least \p n bytes)
+ * \param   b Pointer to input (buffer of at least \p n bytes)
+ * \param   n Number of bytes to process.
+ *
+ * \note      Depending on the situation, it may be faster to use either mbedtls_xor() or
+ *            mbedtls_xor_no_simd() (these are functionally equivalent).
+ *            If the result is used immediately after the xor operation in non-SIMD code (e.g, in
+ *            AES-CBC), there may be additional latency to transfer the data from SIMD to scalar
+ *            registers, and in this case, mbedtls_xor_no_simd() may be faster. In other cases where
+ *            the result is not used immediately (e.g., in AES-CTR), mbedtls_xor() may be faster.
+ *            For targets without SIMD support, they will behave the same.
+ */
+static inline void mbedtls_xor(unsigned char *r,
+                               const unsigned char *a,
+                               const unsigned char *b,
+                               size_t n)
+{
+    size_t i = 0;
+#if defined(MBEDTLS_EFFICIENT_UNALIGNED_ACCESS)
+#if defined(MBEDTLS_HAVE_NEON_INTRINSICS) && \
+    (!(defined(MBEDTLS_COMPILER_IS_GCC) && MBEDTLS_GCC_VERSION < 70300))
+    /* Old GCC versions generate a warning here, so disable the NEON path for these compilers */
+    for (; (i + 16) <= n; i += 16) {
+        uint8x16_t v1 = vld1q_u8(a + i);
+        uint8x16_t v2 = vld1q_u8(b + i);
+        uint8x16_t x = veorq_u8(v1, v2);
+        vst1q_u8(r + i, x);
+    }
+#if defined(__IAR_SYSTEMS_ICC__)
+    /* This if statement helps some compilers (e.g., IAR) optimise out the byte-by-byte tail case
+     * where n is a constant multiple of 16.
+     * For other compilers (e.g. recent gcc and clang) it makes no difference if n is a compile-time
+     * constant, and is a very small perf regression if n is not a compile-time constant. */
+    if (n % 16 == 0) {
+        return;
+    }
+#endif
+#elif defined(MBEDTLS_ARCH_IS_X64) || defined(MBEDTLS_ARCH_IS_ARM64)
+    /* This codepath probably only makes sense on architectures with 64-bit registers */
+    for (; (i + 8) <= n; i += 8) {
+        uint64_t x = mbedtls_get_unaligned_uint64(a + i) ^ mbedtls_get_unaligned_uint64(b + i);
+        mbedtls_put_unaligned_uint64(r + i, x);
+    }
+#if defined(__IAR_SYSTEMS_ICC__)
+    if (n % 8 == 0) {
+        return;
+    }
+#endif
+#else
+    for (; (i + 4) <= n; i += 4) {
+        uint32_t x = mbedtls_get_unaligned_uint32(a + i) ^ mbedtls_get_unaligned_uint32(b + i);
+        mbedtls_put_unaligned_uint32(r + i, x);
+    }
+#if defined(__IAR_SYSTEMS_ICC__)
+    if (n % 4 == 0) {
+        return;
+    }
+#endif
+#endif
+#endif
+    for (; i < n; i++) {
+        r[i] = a[i] ^ b[i];
+    }
+}
+
+/* Always inline mbedtls_xor_no_simd() as we see significant perf regressions when it does not get
+ * inlined (e.g., observed about 3x perf difference in gcm_mult_largetable with gcc 7 - 12) */
+#if defined(__IAR_SYSTEMS_ICC__)
+#pragma inline = forced
+#elif defined(__GNUC__)
+__attribute__((always_inline))
+#endif
+/**
+ * Perform a fast block XOR operation, such that
+ * r[i] = a[i] ^ b[i] where 0 <= i < n
+ *
+ * In some situations, this can perform better than mbedtls_xor() (e.g., it's about 5%
+ * better in AES-CBC).
+ *
+ * \param   r Pointer to result (buffer of at least \p n bytes). \p r
+ *            may be equal to either \p a or \p b, but behaviour when
+ *            it overlaps in other ways is undefined.
+ * \param   a Pointer to input (buffer of at least \p n bytes)
+ * \param   b Pointer to input (buffer of at least \p n bytes)
+ * \param   n Number of bytes to process.
+ *
+ * \note      Depending on the situation, it may be faster to use either mbedtls_xor() or
+ *            mbedtls_xor_no_simd() (these are functionally equivalent).
+ *            If the result is used immediately after the xor operation in non-SIMD code (e.g, in
+ *            AES-CBC), there may be additional latency to transfer the data from SIMD to scalar
+ *            registers, and in this case, mbedtls_xor_no_simd() may be faster. In other cases where
+ *            the result is not used immediately (e.g., in AES-CTR), mbedtls_xor() may be faster.
+ *            For targets without SIMD support, they will behave the same.
+ */
+static inline void mbedtls_xor_no_simd(unsigned char *r,
+                                       const unsigned char *a,
+                                       const unsigned char *b,
+                                       size_t n)
+{
+    size_t i = 0;
+#if defined(MBEDTLS_EFFICIENT_UNALIGNED_ACCESS)
+#if defined(MBEDTLS_ARCH_IS_X64) || defined(MBEDTLS_ARCH_IS_ARM64)
+    /* This codepath probably only makes sense on architectures with 64-bit registers */
+    for (; (i + 8) <= n; i += 8) {
+        uint64_t x = mbedtls_get_unaligned_uint64(a + i) ^ mbedtls_get_unaligned_uint64(b + i);
+        mbedtls_put_unaligned_uint64(r + i, x);
+    }
+#if defined(__IAR_SYSTEMS_ICC__)
+    /* This if statement helps some compilers (e.g., IAR) optimise out the byte-by-byte tail case
+     * where n is a constant multiple of 8.
+     * For other compilers (e.g. recent gcc and clang) it makes no difference if n is a compile-time
+     * constant, and is a very small perf regression if n is not a compile-time constant. */
+    if (n % 8 == 0) {
+        return;
+    }
+#endif
+#else
+    for (; (i + 4) <= n; i += 4) {
+        uint32_t x = mbedtls_get_unaligned_uint32(a + i) ^ mbedtls_get_unaligned_uint32(b + i);
+        mbedtls_put_unaligned_uint32(r + i, x);
+    }
+#if defined(__IAR_SYSTEMS_ICC__)
+    if (n % 4 == 0) {
+        return;
+    }
+#endif
+#endif
+#endif
+    for (; i < n; i++) {
+        r[i] = a[i] ^ b[i];
+    }
+}
+
+/* Fix MSVC C99 compatible issue
+ *      MSVC support __func__ from visual studio 2015( 1900 )
+ *      Use MSVC predefine macro to avoid name check fail.
+ */
+#if (defined(_MSC_VER) && (_MSC_VER <= 1900))
+#define /*no-check-names*/ __func__ __FUNCTION__
+#endif
+
+/* Define `asm` for compilers which don't define it. */
+/* *INDENT-OFF* */
+#ifndef asm
+#if defined(__IAR_SYSTEMS_ICC__)
+#define asm __asm
+#else
+#define asm __asm__
+#endif
+#endif
+/* *INDENT-ON* */
+
+/*
+ * Define the constraint used for read-only pointer operands to aarch64 asm.
+ *
+ * This is normally the usual "r", but for aarch64_32 (aka ILP32,
+ * as found in watchos), "p" is required to avoid warnings from clang.
+ *
+ * Note that clang does not recognise '+p' or '=p', and armclang
+ * does not recognise 'p' at all. Therefore, to update a pointer from
+ * aarch64 assembly, it is necessary to use something like:
+ *
+ * uintptr_t uptr = (uintptr_t) ptr;
+ * asm( "ldr x4, [%x0], #8" ... : "+r" (uptr) : : )
+ * ptr = (void*) uptr;
+ *
+ * Note that the "x" in "%x0" is neccessary; writing "%0" will cause warnings.
+ */
+#if defined(__aarch64__) && defined(MBEDTLS_HAVE_ASM)
+#if UINTPTR_MAX == 0xfffffffful
+/* ILP32: Specify the pointer operand slightly differently, as per #7787. */
+#define MBEDTLS_ASM_AARCH64_PTR_CONSTRAINT "p"
+#elif UINTPTR_MAX == 0xfffffffffffffffful
+/* Normal case (64-bit pointers): use "r" as the constraint for pointer operands to asm */
+#define MBEDTLS_ASM_AARCH64_PTR_CONSTRAINT "r"
+#else
+#error "Unrecognised pointer size for aarch64"
+#endif
+#endif
+
+/* Always provide a static assert macro, so it can be used unconditionally.
+ * It will expand to nothing on some systems.
+ * Can be used outside functions (but don't add a trailing ';' in that case:
+ * the semicolon is included here to avoid triggering -Wextra-semi when
+ * MBEDTLS_STATIC_ASSERT() expands to nothing).
+ * Can't use the C11-style `defined(static_assert)` on FreeBSD, since it
+ * defines static_assert even with -std=c99, but then complains about it.
+ */
+#if defined(static_assert) && !defined(__FreeBSD__)
+#define MBEDTLS_STATIC_ASSERT(expr, msg)    static_assert(expr, msg);
+#else
+#define MBEDTLS_STATIC_ASSERT(expr, msg)
+#endif
+
+#if defined(__has_builtin)
+#define MBEDTLS_HAS_BUILTIN(x) __has_builtin(x)
+#else
+#define MBEDTLS_HAS_BUILTIN(x) 0
+#endif
+
+/* Define compiler branch hints */
+#if MBEDTLS_HAS_BUILTIN(__builtin_expect)
+#define MBEDTLS_LIKELY(x)       __builtin_expect(!!(x), 1)
+#define MBEDTLS_UNLIKELY(x)     __builtin_expect(!!(x), 0)
+#else
+#define MBEDTLS_LIKELY(x)       x
+#define MBEDTLS_UNLIKELY(x)     x
+#endif
+
+/* MBEDTLS_ASSUME may be used to provide additional information to the compiler
+ * which can result in smaller code-size. */
+#if MBEDTLS_HAS_BUILTIN(__builtin_assume)
+/* clang provides __builtin_assume */
+#define MBEDTLS_ASSUME(x)       __builtin_assume(x)
+#elif MBEDTLS_HAS_BUILTIN(__builtin_unreachable)
+/* gcc and IAR can use __builtin_unreachable */
+#define MBEDTLS_ASSUME(x)       do { if (!(x)) __builtin_unreachable(); } while (0)
+#elif defined(_MSC_VER)
+/* Supported by MSVC since VS 2005 */
+#define MBEDTLS_ASSUME(x)       __assume(x)
+#else
+#define MBEDTLS_ASSUME(x)       do { } while (0)
+#endif
+
+/* For gcc -Os, override with -O2 for a given function.
+ *
+ * This will not affect behaviour for other optimisation settings, e.g. -O0.
+ */
+#if defined(MBEDTLS_COMPILER_IS_GCC) && defined(__OPTIMIZE_SIZE__)
+#define MBEDTLS_OPTIMIZE_FOR_PERFORMANCE __attribute__((optimize("-O2")))
+#else
+#define MBEDTLS_OPTIMIZE_FOR_PERFORMANCE
+#endif
+
+/* Suppress compiler warnings for unused functions and variables. */
+#if !defined(MBEDTLS_MAYBE_UNUSED) && defined(__has_attribute)
+#    if __has_attribute(unused)
+#        define MBEDTLS_MAYBE_UNUSED __attribute__((unused))
+#    endif
+#endif
+#if !defined(MBEDTLS_MAYBE_UNUSED) && defined(__GNUC__)
+#    define MBEDTLS_MAYBE_UNUSED __attribute__((unused))
+#endif
+#if !defined(MBEDTLS_MAYBE_UNUSED) && defined(__IAR_SYSTEMS_ICC__) && defined(__VER__)
+/* IAR does support __attribute__((unused)), but only if the -e flag (extended language support)
+ * is given; the pragma always works.
+ * Unfortunately the pragma affects the rest of the file where it is used, but this is harmless.
+ * Check for version 5.2 or later - this pragma may be supported by earlier versions, but I wasn't
+ * able to find documentation).
+ */
+#    if (__VER__ >= 5020000)
+#        define MBEDTLS_MAYBE_UNUSED _Pragma("diag_suppress=Pe177")
+#    endif
+#endif
+#if !defined(MBEDTLS_MAYBE_UNUSED) && defined(_MSC_VER)
+#    define MBEDTLS_MAYBE_UNUSED __pragma(warning(suppress:4189))
+#endif
+#if !defined(MBEDTLS_MAYBE_UNUSED)
+#    define MBEDTLS_MAYBE_UNUSED
+#endif
+
+#endif /* MBEDTLS_LIBRARY_COMMON_H */
diff --git a/library/psa_crypto.c b/tf-psa-crypto/core/psa_crypto.c
similarity index 100%
rename from library/psa_crypto.c
rename to tf-psa-crypto/core/psa_crypto.c
diff --git a/library/psa_crypto_aead.c b/tf-psa-crypto/core/psa_crypto_aead.c
similarity index 100%
rename from library/psa_crypto_aead.c
rename to tf-psa-crypto/core/psa_crypto_aead.c
diff --git a/library/psa_crypto_aead.h b/tf-psa-crypto/core/psa_crypto_aead.h
similarity index 100%
rename from library/psa_crypto_aead.h
rename to tf-psa-crypto/core/psa_crypto_aead.h
diff --git a/library/psa_crypto_cipher.c b/tf-psa-crypto/core/psa_crypto_cipher.c
similarity index 100%
rename from library/psa_crypto_cipher.c
rename to tf-psa-crypto/core/psa_crypto_cipher.c
diff --git a/library/psa_crypto_cipher.h b/tf-psa-crypto/core/psa_crypto_cipher.h
similarity index 100%
rename from library/psa_crypto_cipher.h
rename to tf-psa-crypto/core/psa_crypto_cipher.h
diff --git a/library/psa_crypto_client.c b/tf-psa-crypto/core/psa_crypto_client.c
similarity index 100%
rename from library/psa_crypto_client.c
rename to tf-psa-crypto/core/psa_crypto_client.c
diff --git a/library/psa_crypto_core.h b/tf-psa-crypto/core/psa_crypto_core.h
similarity index 100%
rename from library/psa_crypto_core.h
rename to tf-psa-crypto/core/psa_crypto_core.h
diff --git a/library/psa_crypto_core_common.h b/tf-psa-crypto/core/psa_crypto_core_common.h
similarity index 100%
rename from library/psa_crypto_core_common.h
rename to tf-psa-crypto/core/psa_crypto_core_common.h
diff --git a/library/psa_crypto_driver_wrappers_no_static.h b/tf-psa-crypto/core/psa_crypto_driver_wrappers_no_static.h
similarity index 100%
rename from library/psa_crypto_driver_wrappers_no_static.h
rename to tf-psa-crypto/core/psa_crypto_driver_wrappers_no_static.h
diff --git a/library/psa_crypto_ecp.c b/tf-psa-crypto/core/psa_crypto_ecp.c
similarity index 100%
rename from library/psa_crypto_ecp.c
rename to tf-psa-crypto/core/psa_crypto_ecp.c
diff --git a/library/psa_crypto_ecp.h b/tf-psa-crypto/core/psa_crypto_ecp.h
similarity index 100%
rename from library/psa_crypto_ecp.h
rename to tf-psa-crypto/core/psa_crypto_ecp.h
diff --git a/library/psa_crypto_ffdh.c b/tf-psa-crypto/core/psa_crypto_ffdh.c
similarity index 100%
rename from library/psa_crypto_ffdh.c
rename to tf-psa-crypto/core/psa_crypto_ffdh.c
diff --git a/library/psa_crypto_ffdh.h b/tf-psa-crypto/core/psa_crypto_ffdh.h
similarity index 100%
rename from library/psa_crypto_ffdh.h
rename to tf-psa-crypto/core/psa_crypto_ffdh.h
diff --git a/library/psa_crypto_hash.c b/tf-psa-crypto/core/psa_crypto_hash.c
similarity index 100%
rename from library/psa_crypto_hash.c
rename to tf-psa-crypto/core/psa_crypto_hash.c
diff --git a/library/psa_crypto_hash.h b/tf-psa-crypto/core/psa_crypto_hash.h
similarity index 100%
rename from library/psa_crypto_hash.h
rename to tf-psa-crypto/core/psa_crypto_hash.h
diff --git a/library/psa_crypto_invasive.h b/tf-psa-crypto/core/psa_crypto_invasive.h
similarity index 100%
rename from library/psa_crypto_invasive.h
rename to tf-psa-crypto/core/psa_crypto_invasive.h
diff --git a/library/psa_crypto_its.h b/tf-psa-crypto/core/psa_crypto_its.h
similarity index 100%
rename from library/psa_crypto_its.h
rename to tf-psa-crypto/core/psa_crypto_its.h
diff --git a/library/psa_crypto_mac.c b/tf-psa-crypto/core/psa_crypto_mac.c
similarity index 100%
rename from library/psa_crypto_mac.c
rename to tf-psa-crypto/core/psa_crypto_mac.c
diff --git a/library/psa_crypto_mac.h b/tf-psa-crypto/core/psa_crypto_mac.h
similarity index 100%
rename from library/psa_crypto_mac.h
rename to tf-psa-crypto/core/psa_crypto_mac.h
diff --git a/library/psa_crypto_pake.c b/tf-psa-crypto/core/psa_crypto_pake.c
similarity index 100%
rename from library/psa_crypto_pake.c
rename to tf-psa-crypto/core/psa_crypto_pake.c
diff --git a/library/psa_crypto_pake.h b/tf-psa-crypto/core/psa_crypto_pake.h
similarity index 100%
rename from library/psa_crypto_pake.h
rename to tf-psa-crypto/core/psa_crypto_pake.h
diff --git a/library/psa_crypto_random_impl.h b/tf-psa-crypto/core/psa_crypto_random_impl.h
similarity index 100%
rename from library/psa_crypto_random_impl.h
rename to tf-psa-crypto/core/psa_crypto_random_impl.h
diff --git a/library/psa_crypto_rsa.c b/tf-psa-crypto/core/psa_crypto_rsa.c
similarity index 100%
rename from library/psa_crypto_rsa.c
rename to tf-psa-crypto/core/psa_crypto_rsa.c
diff --git a/library/psa_crypto_rsa.h b/tf-psa-crypto/core/psa_crypto_rsa.h
similarity index 100%
rename from library/psa_crypto_rsa.h
rename to tf-psa-crypto/core/psa_crypto_rsa.h
diff --git a/library/psa_crypto_se.c b/tf-psa-crypto/core/psa_crypto_se.c
similarity index 100%
rename from library/psa_crypto_se.c
rename to tf-psa-crypto/core/psa_crypto_se.c
diff --git a/library/psa_crypto_se.h b/tf-psa-crypto/core/psa_crypto_se.h
similarity index 100%
rename from library/psa_crypto_se.h
rename to tf-psa-crypto/core/psa_crypto_se.h
diff --git a/library/psa_crypto_slot_management.c b/tf-psa-crypto/core/psa_crypto_slot_management.c
similarity index 100%
rename from library/psa_crypto_slot_management.c
rename to tf-psa-crypto/core/psa_crypto_slot_management.c
diff --git a/library/psa_crypto_slot_management.h b/tf-psa-crypto/core/psa_crypto_slot_management.h
similarity index 100%
rename from library/psa_crypto_slot_management.h
rename to tf-psa-crypto/core/psa_crypto_slot_management.h
diff --git a/library/psa_crypto_storage.c b/tf-psa-crypto/core/psa_crypto_storage.c
similarity index 100%
rename from library/psa_crypto_storage.c
rename to tf-psa-crypto/core/psa_crypto_storage.c
diff --git a/library/psa_crypto_storage.h b/tf-psa-crypto/core/psa_crypto_storage.h
similarity index 100%
rename from library/psa_crypto_storage.h
rename to tf-psa-crypto/core/psa_crypto_storage.h
diff --git a/library/psa_its_file.c b/tf-psa-crypto/core/psa_its_file.c
similarity index 100%
rename from library/psa_its_file.c
rename to tf-psa-crypto/core/psa_its_file.c
diff --git a/library/psa_util.c b/tf-psa-crypto/core/psa_util.c
similarity index 100%
rename from library/psa_util.c
rename to tf-psa-crypto/core/psa_util.c
diff --git a/library/psa_util_internal.h b/tf-psa-crypto/core/psa_util_internal.h
similarity index 100%
rename from library/psa_util_internal.h
rename to tf-psa-crypto/core/psa_util_internal.h
diff --git a/tf-psa-crypto/drivers/builtin/src/.gitignore b/tf-psa-crypto/drivers/builtin/src/.gitignore
new file mode 100644
index 0000000..f3923b1
--- /dev/null
+++ b/tf-psa-crypto/drivers/builtin/src/.gitignore
@@ -0,0 +1,4 @@
+###START_GENERATED_FILES###
+/error.c
+/version_features.c
+###END_GENERATED_FILES###
diff --git a/library/aes.c b/tf-psa-crypto/drivers/builtin/src/aes.c
similarity index 100%
rename from library/aes.c
rename to tf-psa-crypto/drivers/builtin/src/aes.c
diff --git a/library/aesce.c b/tf-psa-crypto/drivers/builtin/src/aesce.c
similarity index 100%
rename from library/aesce.c
rename to tf-psa-crypto/drivers/builtin/src/aesce.c
diff --git a/library/aesce.h b/tf-psa-crypto/drivers/builtin/src/aesce.h
similarity index 100%
rename from library/aesce.h
rename to tf-psa-crypto/drivers/builtin/src/aesce.h
diff --git a/library/aesni.c b/tf-psa-crypto/drivers/builtin/src/aesni.c
similarity index 100%
rename from library/aesni.c
rename to tf-psa-crypto/drivers/builtin/src/aesni.c
diff --git a/library/aesni.h b/tf-psa-crypto/drivers/builtin/src/aesni.h
similarity index 100%
rename from library/aesni.h
rename to tf-psa-crypto/drivers/builtin/src/aesni.h
diff --git a/library/aria.c b/tf-psa-crypto/drivers/builtin/src/aria.c
similarity index 100%
rename from library/aria.c
rename to tf-psa-crypto/drivers/builtin/src/aria.c
diff --git a/library/asn1parse.c b/tf-psa-crypto/drivers/builtin/src/asn1parse.c
similarity index 100%
rename from library/asn1parse.c
rename to tf-psa-crypto/drivers/builtin/src/asn1parse.c
diff --git a/library/asn1write.c b/tf-psa-crypto/drivers/builtin/src/asn1write.c
similarity index 100%
rename from library/asn1write.c
rename to tf-psa-crypto/drivers/builtin/src/asn1write.c
diff --git a/library/base64.c b/tf-psa-crypto/drivers/builtin/src/base64.c
similarity index 100%
rename from library/base64.c
rename to tf-psa-crypto/drivers/builtin/src/base64.c
diff --git a/library/base64_internal.h b/tf-psa-crypto/drivers/builtin/src/base64_internal.h
similarity index 100%
rename from library/base64_internal.h
rename to tf-psa-crypto/drivers/builtin/src/base64_internal.h
diff --git a/library/bignum.c b/tf-psa-crypto/drivers/builtin/src/bignum.c
similarity index 100%
rename from library/bignum.c
rename to tf-psa-crypto/drivers/builtin/src/bignum.c
diff --git a/library/bignum_core.c b/tf-psa-crypto/drivers/builtin/src/bignum_core.c
similarity index 100%
rename from library/bignum_core.c
rename to tf-psa-crypto/drivers/builtin/src/bignum_core.c
diff --git a/library/bignum_core.h b/tf-psa-crypto/drivers/builtin/src/bignum_core.h
similarity index 100%
rename from library/bignum_core.h
rename to tf-psa-crypto/drivers/builtin/src/bignum_core.h
diff --git a/library/bignum_mod.c b/tf-psa-crypto/drivers/builtin/src/bignum_mod.c
similarity index 100%
rename from library/bignum_mod.c
rename to tf-psa-crypto/drivers/builtin/src/bignum_mod.c
diff --git a/library/bignum_mod.h b/tf-psa-crypto/drivers/builtin/src/bignum_mod.h
similarity index 100%
rename from library/bignum_mod.h
rename to tf-psa-crypto/drivers/builtin/src/bignum_mod.h
diff --git a/library/bignum_mod_raw.c b/tf-psa-crypto/drivers/builtin/src/bignum_mod_raw.c
similarity index 100%
rename from library/bignum_mod_raw.c
rename to tf-psa-crypto/drivers/builtin/src/bignum_mod_raw.c
diff --git a/library/bignum_mod_raw.h b/tf-psa-crypto/drivers/builtin/src/bignum_mod_raw.h
similarity index 100%
rename from library/bignum_mod_raw.h
rename to tf-psa-crypto/drivers/builtin/src/bignum_mod_raw.h
diff --git a/library/bignum_mod_raw_invasive.h b/tf-psa-crypto/drivers/builtin/src/bignum_mod_raw_invasive.h
similarity index 100%
rename from library/bignum_mod_raw_invasive.h
rename to tf-psa-crypto/drivers/builtin/src/bignum_mod_raw_invasive.h
diff --git a/library/block_cipher.c b/tf-psa-crypto/drivers/builtin/src/block_cipher.c
similarity index 100%
rename from library/block_cipher.c
rename to tf-psa-crypto/drivers/builtin/src/block_cipher.c
diff --git a/library/block_cipher_internal.h b/tf-psa-crypto/drivers/builtin/src/block_cipher_internal.h
similarity index 100%
rename from library/block_cipher_internal.h
rename to tf-psa-crypto/drivers/builtin/src/block_cipher_internal.h
diff --git a/library/bn_mul.h b/tf-psa-crypto/drivers/builtin/src/bn_mul.h
similarity index 100%
rename from library/bn_mul.h
rename to tf-psa-crypto/drivers/builtin/src/bn_mul.h
diff --git a/library/camellia.c b/tf-psa-crypto/drivers/builtin/src/camellia.c
similarity index 100%
rename from library/camellia.c
rename to tf-psa-crypto/drivers/builtin/src/camellia.c
diff --git a/library/ccm.c b/tf-psa-crypto/drivers/builtin/src/ccm.c
similarity index 100%
rename from library/ccm.c
rename to tf-psa-crypto/drivers/builtin/src/ccm.c
diff --git a/library/chacha20.c b/tf-psa-crypto/drivers/builtin/src/chacha20.c
similarity index 100%
rename from library/chacha20.c
rename to tf-psa-crypto/drivers/builtin/src/chacha20.c
diff --git a/library/chachapoly.c b/tf-psa-crypto/drivers/builtin/src/chachapoly.c
similarity index 100%
rename from library/chachapoly.c
rename to tf-psa-crypto/drivers/builtin/src/chachapoly.c
diff --git a/library/check_crypto_config.h b/tf-psa-crypto/drivers/builtin/src/check_crypto_config.h
similarity index 100%
rename from library/check_crypto_config.h
rename to tf-psa-crypto/drivers/builtin/src/check_crypto_config.h
diff --git a/library/cipher.c b/tf-psa-crypto/drivers/builtin/src/cipher.c
similarity index 100%
rename from library/cipher.c
rename to tf-psa-crypto/drivers/builtin/src/cipher.c
diff --git a/library/cipher_wrap.c b/tf-psa-crypto/drivers/builtin/src/cipher_wrap.c
similarity index 100%
rename from library/cipher_wrap.c
rename to tf-psa-crypto/drivers/builtin/src/cipher_wrap.c
diff --git a/library/cipher_wrap.h b/tf-psa-crypto/drivers/builtin/src/cipher_wrap.h
similarity index 100%
rename from library/cipher_wrap.h
rename to tf-psa-crypto/drivers/builtin/src/cipher_wrap.h
diff --git a/library/cmac.c b/tf-psa-crypto/drivers/builtin/src/cmac.c
similarity index 100%
rename from library/cmac.c
rename to tf-psa-crypto/drivers/builtin/src/cmac.c
diff --git a/library/constant_time.c b/tf-psa-crypto/drivers/builtin/src/constant_time.c
similarity index 100%
rename from library/constant_time.c
rename to tf-psa-crypto/drivers/builtin/src/constant_time.c
diff --git a/library/constant_time_impl.h b/tf-psa-crypto/drivers/builtin/src/constant_time_impl.h
similarity index 100%
rename from library/constant_time_impl.h
rename to tf-psa-crypto/drivers/builtin/src/constant_time_impl.h
diff --git a/library/constant_time_internal.h b/tf-psa-crypto/drivers/builtin/src/constant_time_internal.h
similarity index 100%
rename from library/constant_time_internal.h
rename to tf-psa-crypto/drivers/builtin/src/constant_time_internal.h
diff --git a/library/ctr.h b/tf-psa-crypto/drivers/builtin/src/ctr.h
similarity index 100%
rename from library/ctr.h
rename to tf-psa-crypto/drivers/builtin/src/ctr.h
diff --git a/library/ctr_drbg.c b/tf-psa-crypto/drivers/builtin/src/ctr_drbg.c
similarity index 100%
rename from library/ctr_drbg.c
rename to tf-psa-crypto/drivers/builtin/src/ctr_drbg.c
diff --git a/library/des.c b/tf-psa-crypto/drivers/builtin/src/des.c
similarity index 100%
rename from library/des.c
rename to tf-psa-crypto/drivers/builtin/src/des.c
diff --git a/library/dhm.c b/tf-psa-crypto/drivers/builtin/src/dhm.c
similarity index 100%
rename from library/dhm.c
rename to tf-psa-crypto/drivers/builtin/src/dhm.c
diff --git a/library/ecdh.c b/tf-psa-crypto/drivers/builtin/src/ecdh.c
similarity index 100%
rename from library/ecdh.c
rename to tf-psa-crypto/drivers/builtin/src/ecdh.c
diff --git a/library/ecdsa.c b/tf-psa-crypto/drivers/builtin/src/ecdsa.c
similarity index 100%
rename from library/ecdsa.c
rename to tf-psa-crypto/drivers/builtin/src/ecdsa.c
diff --git a/library/ecjpake.c b/tf-psa-crypto/drivers/builtin/src/ecjpake.c
similarity index 100%
rename from library/ecjpake.c
rename to tf-psa-crypto/drivers/builtin/src/ecjpake.c
diff --git a/library/ecp.c b/tf-psa-crypto/drivers/builtin/src/ecp.c
similarity index 100%
rename from library/ecp.c
rename to tf-psa-crypto/drivers/builtin/src/ecp.c
diff --git a/library/ecp_curves.c b/tf-psa-crypto/drivers/builtin/src/ecp_curves.c
similarity index 100%
rename from library/ecp_curves.c
rename to tf-psa-crypto/drivers/builtin/src/ecp_curves.c
diff --git a/library/ecp_curves_new.c b/tf-psa-crypto/drivers/builtin/src/ecp_curves_new.c
similarity index 100%
rename from library/ecp_curves_new.c
rename to tf-psa-crypto/drivers/builtin/src/ecp_curves_new.c
diff --git a/library/ecp_invasive.h b/tf-psa-crypto/drivers/builtin/src/ecp_invasive.h
similarity index 100%
rename from library/ecp_invasive.h
rename to tf-psa-crypto/drivers/builtin/src/ecp_invasive.h
diff --git a/library/entropy.c b/tf-psa-crypto/drivers/builtin/src/entropy.c
similarity index 100%
rename from library/entropy.c
rename to tf-psa-crypto/drivers/builtin/src/entropy.c
diff --git a/library/entropy_poll.c b/tf-psa-crypto/drivers/builtin/src/entropy_poll.c
similarity index 100%
rename from library/entropy_poll.c
rename to tf-psa-crypto/drivers/builtin/src/entropy_poll.c
diff --git a/library/entropy_poll.h b/tf-psa-crypto/drivers/builtin/src/entropy_poll.h
similarity index 100%
rename from library/entropy_poll.h
rename to tf-psa-crypto/drivers/builtin/src/entropy_poll.h
diff --git a/library/gcm.c b/tf-psa-crypto/drivers/builtin/src/gcm.c
similarity index 100%
rename from library/gcm.c
rename to tf-psa-crypto/drivers/builtin/src/gcm.c
diff --git a/library/hkdf.c b/tf-psa-crypto/drivers/builtin/src/hkdf.c
similarity index 100%
rename from library/hkdf.c
rename to tf-psa-crypto/drivers/builtin/src/hkdf.c
diff --git a/library/hmac_drbg.c b/tf-psa-crypto/drivers/builtin/src/hmac_drbg.c
similarity index 100%
rename from library/hmac_drbg.c
rename to tf-psa-crypto/drivers/builtin/src/hmac_drbg.c
diff --git a/library/lmots.c b/tf-psa-crypto/drivers/builtin/src/lmots.c
similarity index 100%
rename from library/lmots.c
rename to tf-psa-crypto/drivers/builtin/src/lmots.c
diff --git a/library/lmots.h b/tf-psa-crypto/drivers/builtin/src/lmots.h
similarity index 100%
rename from library/lmots.h
rename to tf-psa-crypto/drivers/builtin/src/lmots.h
diff --git a/library/lms.c b/tf-psa-crypto/drivers/builtin/src/lms.c
similarity index 100%
rename from library/lms.c
rename to tf-psa-crypto/drivers/builtin/src/lms.c
diff --git a/library/md.c b/tf-psa-crypto/drivers/builtin/src/md.c
similarity index 100%
rename from library/md.c
rename to tf-psa-crypto/drivers/builtin/src/md.c
diff --git a/library/md5.c b/tf-psa-crypto/drivers/builtin/src/md5.c
similarity index 100%
rename from library/md5.c
rename to tf-psa-crypto/drivers/builtin/src/md5.c
diff --git a/library/md_psa.h b/tf-psa-crypto/drivers/builtin/src/md_psa.h
similarity index 100%
rename from library/md_psa.h
rename to tf-psa-crypto/drivers/builtin/src/md_psa.h
diff --git a/library/md_wrap.h b/tf-psa-crypto/drivers/builtin/src/md_wrap.h
similarity index 100%
rename from library/md_wrap.h
rename to tf-psa-crypto/drivers/builtin/src/md_wrap.h
diff --git a/library/memory_buffer_alloc.c b/tf-psa-crypto/drivers/builtin/src/memory_buffer_alloc.c
similarity index 100%
rename from library/memory_buffer_alloc.c
rename to tf-psa-crypto/drivers/builtin/src/memory_buffer_alloc.c
diff --git a/library/nist_kw.c b/tf-psa-crypto/drivers/builtin/src/nist_kw.c
similarity index 100%
rename from library/nist_kw.c
rename to tf-psa-crypto/drivers/builtin/src/nist_kw.c
diff --git a/library/oid.c b/tf-psa-crypto/drivers/builtin/src/oid.c
similarity index 100%
rename from library/oid.c
rename to tf-psa-crypto/drivers/builtin/src/oid.c
diff --git a/library/pem.c b/tf-psa-crypto/drivers/builtin/src/pem.c
similarity index 100%
rename from library/pem.c
rename to tf-psa-crypto/drivers/builtin/src/pem.c
diff --git a/library/pk.c b/tf-psa-crypto/drivers/builtin/src/pk.c
similarity index 100%
rename from library/pk.c
rename to tf-psa-crypto/drivers/builtin/src/pk.c
diff --git a/library/pk_ecc.c b/tf-psa-crypto/drivers/builtin/src/pk_ecc.c
similarity index 100%
rename from library/pk_ecc.c
rename to tf-psa-crypto/drivers/builtin/src/pk_ecc.c
diff --git a/library/pk_internal.h b/tf-psa-crypto/drivers/builtin/src/pk_internal.h
similarity index 100%
rename from library/pk_internal.h
rename to tf-psa-crypto/drivers/builtin/src/pk_internal.h
diff --git a/library/pk_wrap.c b/tf-psa-crypto/drivers/builtin/src/pk_wrap.c
similarity index 100%
rename from library/pk_wrap.c
rename to tf-psa-crypto/drivers/builtin/src/pk_wrap.c
diff --git a/library/pk_wrap.h b/tf-psa-crypto/drivers/builtin/src/pk_wrap.h
similarity index 100%
rename from library/pk_wrap.h
rename to tf-psa-crypto/drivers/builtin/src/pk_wrap.h
diff --git a/library/pkcs12.c b/tf-psa-crypto/drivers/builtin/src/pkcs12.c
similarity index 100%
rename from library/pkcs12.c
rename to tf-psa-crypto/drivers/builtin/src/pkcs12.c
diff --git a/library/pkcs5.c b/tf-psa-crypto/drivers/builtin/src/pkcs5.c
similarity index 100%
rename from library/pkcs5.c
rename to tf-psa-crypto/drivers/builtin/src/pkcs5.c
diff --git a/library/pkparse.c b/tf-psa-crypto/drivers/builtin/src/pkparse.c
similarity index 100%
rename from library/pkparse.c
rename to tf-psa-crypto/drivers/builtin/src/pkparse.c
diff --git a/library/pkwrite.c b/tf-psa-crypto/drivers/builtin/src/pkwrite.c
similarity index 100%
rename from library/pkwrite.c
rename to tf-psa-crypto/drivers/builtin/src/pkwrite.c
diff --git a/library/pkwrite.h b/tf-psa-crypto/drivers/builtin/src/pkwrite.h
similarity index 100%
rename from library/pkwrite.h
rename to tf-psa-crypto/drivers/builtin/src/pkwrite.h
diff --git a/library/platform.c b/tf-psa-crypto/drivers/builtin/src/platform.c
similarity index 100%
rename from library/platform.c
rename to tf-psa-crypto/drivers/builtin/src/platform.c
diff --git a/library/platform_util.c b/tf-psa-crypto/drivers/builtin/src/platform_util.c
similarity index 100%
rename from library/platform_util.c
rename to tf-psa-crypto/drivers/builtin/src/platform_util.c
diff --git a/library/poly1305.c b/tf-psa-crypto/drivers/builtin/src/poly1305.c
similarity index 100%
rename from library/poly1305.c
rename to tf-psa-crypto/drivers/builtin/src/poly1305.c
diff --git a/library/ripemd160.c b/tf-psa-crypto/drivers/builtin/src/ripemd160.c
similarity index 100%
rename from library/ripemd160.c
rename to tf-psa-crypto/drivers/builtin/src/ripemd160.c
diff --git a/library/rsa.c b/tf-psa-crypto/drivers/builtin/src/rsa.c
similarity index 100%
rename from library/rsa.c
rename to tf-psa-crypto/drivers/builtin/src/rsa.c
diff --git a/library/rsa_alt_helpers.c b/tf-psa-crypto/drivers/builtin/src/rsa_alt_helpers.c
similarity index 100%
rename from library/rsa_alt_helpers.c
rename to tf-psa-crypto/drivers/builtin/src/rsa_alt_helpers.c
diff --git a/library/rsa_alt_helpers.h b/tf-psa-crypto/drivers/builtin/src/rsa_alt_helpers.h
similarity index 100%
rename from library/rsa_alt_helpers.h
rename to tf-psa-crypto/drivers/builtin/src/rsa_alt_helpers.h
diff --git a/library/rsa_internal.h b/tf-psa-crypto/drivers/builtin/src/rsa_internal.h
similarity index 100%
rename from library/rsa_internal.h
rename to tf-psa-crypto/drivers/builtin/src/rsa_internal.h
diff --git a/library/sha1.c b/tf-psa-crypto/drivers/builtin/src/sha1.c
similarity index 100%
rename from library/sha1.c
rename to tf-psa-crypto/drivers/builtin/src/sha1.c
diff --git a/library/sha256.c b/tf-psa-crypto/drivers/builtin/src/sha256.c
similarity index 100%
rename from library/sha256.c
rename to tf-psa-crypto/drivers/builtin/src/sha256.c
diff --git a/library/sha3.c b/tf-psa-crypto/drivers/builtin/src/sha3.c
similarity index 100%
rename from library/sha3.c
rename to tf-psa-crypto/drivers/builtin/src/sha3.c
diff --git a/library/sha512.c b/tf-psa-crypto/drivers/builtin/src/sha512.c
similarity index 100%
rename from library/sha512.c
rename to tf-psa-crypto/drivers/builtin/src/sha512.c
diff --git a/library/threading.c b/tf-psa-crypto/drivers/builtin/src/threading.c
similarity index 100%
rename from library/threading.c
rename to tf-psa-crypto/drivers/builtin/src/threading.c
diff --git a/library/timing.c b/tf-psa-crypto/drivers/builtin/src/timing.c
similarity index 100%
rename from library/timing.c
rename to tf-psa-crypto/drivers/builtin/src/timing.c
diff --git a/library/version.c b/tf-psa-crypto/drivers/builtin/src/version.c
similarity index 100%
rename from library/version.c
rename to tf-psa-crypto/drivers/builtin/src/version.c