Page MenuHomePhabricator

Build errors in PSA api tests for initial attestation
Closed, WontfixPublic

Description

psa-arch-tests/api-tests/platform/targets/common/nspe/initial_attestation/pal_attestation_crypto.c: In function 'cose_hash_alg_id_to_psa':
psa-arch-tests/api-tests/platform/targets/common/nspe/initial_attestation/pal_attestation_crypto.c:39:18: error: 'PSA_ALG_MD4' undeclared (first use in this function); did you mean 'PSA_ALG_MD5'?
   39 |         status = PSA_ALG_MD4;
      |                  ^~~~~~~~~~~
      |                  PSA_ALG_MD5
psa-arch-tests/api-tests/platform/targets/common/nspe/initial_attestation/pal_attestation_crypto.c:39:18: note: each undeclared identifier is reported only once for each function it appears in
In file included from app/psa_api_tests/psa_qcbor/inc/qcbor.h:89,
                 from psa-arch-tests/api-tests/platform/targets/common/nspe/initial_attestation/pal_attestation_eat.h:21,
                 from psa-arch-tests/api-tests/platform/targets/common/nspe/initial_attestation/pal_attestation_crypto.h:21,
                 from psa-arch-tests/api-tests/platform/targets/common/nspe/initial_attestation/pal_attestation_crypto.c:18:
psa-arch-tests/api-tests/platform/targets/common/nspe/initial_attestation/pal_attestation_crypto.c: In function 'pal_compute_hash':
psa-arch-tests/api-tests/platform/targets/tgt_dev_apis_tfm_nrf/nspe/pal_attestation_config.h:53:1: error: expected ';' before '}' token
   53 | }
      | ^
app/psa_api_tests/psa_qcbor/inc/UsefulBuf.h:403:30: note: in definition of macro 'UsefulBuf_MAKE_STACK_UB'
  403 |     uint8_t    __pBuf##name[(size)];\
      |                              ^~~~
psa-arch-tests/api-tests/platform/targets/common/nspe/initial_attestation/pal_attestation_crypto.c:133:60: note: in expansion of macro 'T_COSE_SIZE_OF_TBS'
  133 |     UsefulBuf_MAKE_STACK_UB    (buffer_for_TBS_first_part, T_COSE_SIZE_OF_TBS);
      |                                                            ^~~~~~~~~~~~~~~~~~
[88/423] Building C object app/psa_api_tests/CMakeFiles/pal_nspe.dir/psa_qcbor/src/qcbor_decode.o

On 1.4 RC3 with psa-arch-tests, tf-m-tests, mbedtls, and mcuboot checked out at the shas specified in config_default.cmake, building with ninja.

Event Timeline

Hi,

I tested with the following command with TF-Mv1.4.0-RC3:
-DTFM_PLATFORM=nordic_nrf/nrf5340dk_nrf5340_cpuapp -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DCMAKE_BUILD_TYPE=Debug -DTEST_PSA_API=INITIAL_ATTESTATION -DTFM_PSA_API=ON

(Please correct me if the command is wrong~~)

Just found the following error:
psa_arch_tests-src/api-tests/platform/targets/tgt_dev_apis_tfm_nrf/nspe/pal_attestation_config.h:53:1: error: expected ';' before '}' token
}
app/psa_api_tests/psa_qcbor/inc/UsefulBuf.h:403:30: note: in definition of macro 'UsefulBuf_MAKE_STACK_UB'

uint8_t    __pBuf##name[(size)];\

psa_arch_tests-src/api-tests/platform/targets/common/nspe/initial_attestation/pal_attestation_crypto.c:138:60: note: in expansion of macro 'T_COSE_SIZE_OF_TBS'

UsefulBuf_MAKE_STACK_UB    (buffer_for_TBS_first_part, T_COSE_SIZE_OF_TBS);
                                                       ^~~~~~~~~~~~~~~~~~

After investigation, I figured out the root cause is that, nordic specific definition for T_COSE_SIZE_OF_TBS uses wrong format in psa_arch_tests-src/api-tests/platform/targets/tgt_dev_apis_tfm_nrf/nspe/pal_attestation_config.h.

#define T_COSE_SIZE_OF_TBS { \
    1 + /* For opening the array */ \
    sizeof(COSE_SIG_CONTEXT_STRING_SIGNATURE1) + /* "Signature1" */ \
    2 + /* Overhead for encoding string */ \
    T_COSE_SIGN1_MAX_PROT_HEADER + /* entire protected headers */ \
    3 * (/* 3 NULL bstrs for fields not used */ \
        1 /* size of a NULL bstr */  \
    ) \
}

should changes to

#define T_COSE_SIZE_OF_TBS \
    1 + /* For opening the array */ \
    sizeof(COSE_SIG_CONTEXT_STRING_SIGNATURE1) + /* "Signature1" */ \
    2 + /* Overhead for encoding string */ \
    T_COSE_SIGN1_MAX_PROT_HEADER + /* entire protected headers */ \
    3 * (/* 3 NULL bstrs for fields not used */ \
        1 /* size of a NULL bstr */  \
    ) \

This error is specific to nordic platforms in psa arch test, so you can raise a psa arch test issue here

For PSA_ALG_MD4 error, I think it is the mismatch between tfm and psa arch test. We have a patch to workaround this issue in tfm (lib/ext/psa_arch_tests/0004-Align-with-mbedtls-3.0.0.patch).
Suggest you apply these patches if you specify your own psa arch test path.

Summer-ARM closed this task as Wontfix.Nov 26 2021, 6:30 AM
Summer-ARM claimed this task.

It is related with psa arch test issue, so close it.