Skip to content

Mark PSA as an experimental API #13003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .astyleignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
^BUILD
^cmsis
^components/TARGET_PSA/services/attestation/attestation.h
^components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/tfm_impl
^components/TARGET_PSA/services/attestation/qcbor
^components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/crypto_struct_ipc.h
^components/TARGET_PSA/TARGET_TFM
^components/TARGET_PSA/TESTS
^features/cryptocell
^features/FEATURE_BLE
^features/FEATURE_EXPERIMENTAL_API/TARGET_MBED_PSA_SRV
^features/FEATURE_EXPERIMENTAL_API/TARGET_PSA/TARGET_MBED_PSA_SRV/services/attestation/attestation.h
^features/FEATURE_EXPERIMENTAL_API/TARGET_PSA/TARGET_MBED_PSA_SRV/services/attestation/COMPONENT_PSA_SRV_IMPL/tfm_impl
^features/FEATURE_EXPERIMENTAL_API/TARGET_PSA/TARGET_MBED_PSA_SRV/services/attestation/qcbor
^features/FEATURE_EXPERIMENTAL_API/TARGET_PSA/TARGET_MBED_PSA_SRV/services/crypto/COMPONENT_PSA_SRV_IPC/crypto_struct_ipc.h
^features/FEATURE_EXPERIMENTAL_API/TARGET_PSA/TARGET_MBED_PSA_SRV/TARGET_TFM
^features/FEATURE_EXPERIMENTAL_API/TARGET_PSA/TARGET_MBED_PSA_SRV/TESTS
^features/frameworks
^features/lwipstack/lwip
^features/lwipstack/lwip-sys
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Folders containing files under different permissive license than Apache 2.0 are
- [cmsis](./cmsis) - MIT, BSD-3-Clause
- [components/802.15.4_RF/mcr20a-rf-driver](./components/802.15.4_RF/mcr20a-rf-driver) - BSD-3-Clause
- [components/TARGET_PSA/TARGET_TFM](./components/TARGET_PSA/TARGET_TFM) - BSD-3-Clause
- [components/TARGET_PSA/TARGET_PSA/services/attestation](./components/TARGET_PSA/services/attestation) - BSD-3-Clause
- [components/TARGET_PSA/TARGET_MBED_PSA_SRV/services/attestation](./components/TARGET_PSA/TARGET_MBED_PSA_SRV/services/attestation) - BSD-3-Clause
- [features/cryptocell/FEATURE_CRYPTOCELL310](./features/cryptocell/FEATURE_CRYPTOCELL310) - ARM Object Code and Header Files License
- [features/FEATURE_BOOTLOADER](./features/FEATURE_BOOTLOADER) - PBL
- [features/FEATURE_BLE/targets](./features/FEATURE_BLE/targets) - BSD-style, PBL, MIT-style
Expand Down
4 changes: 2 additions & 2 deletions TESTS/mbedtls/sanity/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* limitations under the License.
*/

#include "psa/crypto.h"

#if ((!defined(TARGET_PSA)) || (!defined(MBEDTLS_PSA_CRYPTO_C)))
#error [NOT_SUPPORTED] Mbed Crypto is OFF - skipping.
#else

#include "psa/crypto.h"

#include <stdio.h>
#include "mbed.h"
#include "greentea-client/test_env.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ MBED_WEAK void trng_free(trng_t *obj)

MBED_WEAK int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_length)
{
((void)(obj));
if (output == NULL || output_length == NULL){
((void)(obj));
if (output == NULL || output_length == NULL) {
return -1;
}

psa_status_t status = psa_crypto_init();
if(status != PSA_SUCCESS) {
if (status != PSA_SUCCESS) {
return -1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ int mbed_default_seed_read(unsigned char *buf, size_t buf_len)
{
size_t actual_size;
psa_status_t rc = psa_its_get(PSA_CRYPTO_ITS_RANDOM_SEED_UID, 0, buf_len, buf, &actual_size);
return ( rc );
return (rc);
}

int mbed_default_seed_write(unsigned char *buf, size_t buf_len)
{
psa_status_t rc = psa_its_set(PSA_CRYPTO_ITS_RANDOM_SEED_UID, buf_len, buf, 0);
return ( rc );
return (rc);
}

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,21 @@ int32_t pal_attestation_function(int type, va_list valist)
uint8_t *challenge, *token;
uint32_t challenge_size, *token_size, verify_token_size;

switch (type)
{
switch (type) {
case PAL_INITIAL_ATTEST_GET_TOKEN:
challenge = va_arg(valist, uint8_t*);
challenge = va_arg(valist, uint8_t *);
challenge_size = va_arg(valist, uint32_t);
token = va_arg(valist, uint8_t*);
token_size = va_arg(valist, uint32_t*);
token = va_arg(valist, uint8_t *);
token_size = va_arg(valist, uint32_t *);
return psa_initial_attest_get_token(challenge, challenge_size, token, token_size);
case PAL_INITIAL_ATTEST_GET_TOKEN_SIZE:
challenge_size = va_arg(valist, uint32_t);
token_size = va_arg(valist, uint32_t*);
token_size = va_arg(valist, uint32_t *);
return psa_initial_attest_get_token_size(challenge_size, token_size);
case PAL_INITIAL_ATTEST_VERIFY_TOKEN:
challenge = va_arg(valist, uint8_t*);
challenge = va_arg(valist, uint8_t *);
challenge_size = va_arg(valist, uint32_t);
token = va_arg(valist, uint8_t*);
token = va_arg(valist, uint8_t *);
verify_token_size = va_arg(valist, uint32_t);
return pal_initial_attest_verify_token(challenge, challenge_size,
token, verify_token_size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ psa_handle_t pal_ipc_connect(uint32_t sid, uint32_t minor_version)
*/

psa_status_t pal_ipc_call(psa_handle_t handle,
const psa_invec *in_vec,
size_t in_len,
psa_outvec *out_vec,
size_t out_len)
const psa_invec *in_vec,
size_t in_len,
psa_outvec *out_vec,
size_t out_len)
{
return (PSA_SUCCESS - 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ psa_handle_t pal_ipc_connect(uint32_t sid, uint32_t minor_version)
*/

psa_status_t pal_ipc_call(psa_handle_t handle,
const psa_invec *in_vec,
size_t in_len,
psa_outvec *out_vec,
size_t out_len)
const psa_invec *in_vec,
size_t in_len,
psa_outvec *out_vec,
size_t out_len)
{
return (psa_call(handle, in_vec, in_len, out_vec, out_len));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ uint32_t pal_ipc_framework_version(void);
uint32_t pal_ipc_version(uint32_t sid);
psa_handle_t pal_ipc_connect(uint32_t sid, uint32_t minor_version);
psa_status_t pal_ipc_call(psa_handle_t handle,
const psa_invec *in_vec,
size_t in_len,
psa_outvec *out_vec,
size_t out_len);
const psa_invec *in_vec,
size_t in_len,
psa_outvec *out_vec,
size_t out_len);
void pal_ipc_close(psa_handle_t handle);
#endif /* _PAL_CLIENT_API_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ typedef uint32_t cfg_id_t;

#define PAL_STATUS_UNSUPPORTED_FUNC 0xFF

typedef enum
{
typedef enum {
PAL_STATUS_SUCCESS = 0x0,
PAL_STATUS_ERROR = 0x80
} pal_status_t;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/** @file
* Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved.
* SPDX-License-Identifier : Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/


#include "pal_internal_trusted_storage_intf.h"

/**
@brief - This API will call the requested internal trusted storage function
@param - type : function code
valist : variable argument list
@return - error status
**/
uint32_t pal_its_function(int type, va_list valist)
{
#if PSA_INTERNAL_TRUSTED_STORAGE_IMPLEMENTED
uint32_t uid, data_length, offset;
const void *p_write_data;
void *p_read_data;
psa_storage_create_flags_t its_create_flags;
//psa_ps_create_flags_t ps_create_flags;
struct psa_its_info_t *its_p_info;
//struct psa_eps_info_t *ps_p_info;
/* TODO: Actual size argument is currently not supported by the testing framework.
* Changes need to be implemented in the actual tests.
* Should be fixed by the next import of the tests.
*/
size_t actual_size;

switch (type) {
case PAL_ITS_SET:
uid = va_arg(valist, psa_storage_uid_t);
data_length = va_arg(valist, uint32_t);
p_write_data = va_arg(valist, const void *);
its_create_flags = va_arg(valist, psa_storage_create_flags_t);
return psa_its_set(uid, data_length, p_write_data, its_create_flags);
case PAL_ITS_GET:
uid = va_arg(valist, psa_storage_uid_t);
offset = va_arg(valist, uint32_t);
data_length = va_arg(valist, uint32_t);
p_read_data = va_arg(valist, void *);
/* TODO: Actual size argument is currently not supported by the testing framework.
* Changes need to be implemented in the actual tests.
* Should be fixed by the next import of the tests.
*/
return psa_its_get(uid, offset, data_length, p_read_data, &actual_size);
case PAL_ITS_GET_INFO:
uid = va_arg(valist, psa_storage_uid_t);
its_p_info = va_arg(valist, struct psa_its_info_t *);
return psa_its_get_info(uid, (struct psa_storage_info_t *)its_p_info);
case PAL_ITS_REMOVE:
uid = va_arg(valist, psa_storage_uid_t);
return psa_its_remove(uid);
/* case PAL_PS_SET: */
/* uid = va_arg(valist, uint32_t); */
/* data_length = va_arg(valist, uint32_t); */
/* p_write_data = va_arg(valist, const void*); */
/* ps_create_flags = va_arg(valist, psa_ps_create_flags_t); */
/* return psa_ps_set(uid, data_length, p_write_data, ps_create_flags); */
/* case PAL_PS_GET: */
/* uid = va_arg(valist, uint32_t); */
/* offset = va_arg(valist, uint32_t); */
/* data_length = va_arg(valist, uint32_t); */
/* p_read_data = va_arg(valist, void*); */
/* return psa_ps_get(uid, offset, data_length, p_read_data); */
/* case PAL_PS_GET_INFO: */
/* uid = va_arg(valist, uint32_t); */
/* ps_p_info = va_arg(valist, struct psa_eps_info_t*); */
/* return psa_ps_get_info(uid, ps_p_info); */
/* case PAL_PS_REMOVE: */
/* uid = va_arg(valist, uint32_t); */
/* return psa_ps_remove(uid); */
default:
return PAL_STATUS_UNSUPPORTED_FUNC;
}
#else
return PAL_STATUS_ERROR;
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ test_entry_f test_g = NULL;
compliance_test_type type_g = COMPLIANCE_TEST_UNDEFINED;

// randomly generated attestation key used for testing the attestation feature.
// The specific key chosen shouldn't matter to the attestation test
// The specific key chosen shouldn't matter to the attestation test
// the test just needs a key to be injected before it is run.
static const uint8_t private_key_data[] = {
0x49, 0xc9, 0xa8, 0xc1, 0x8c, 0x4b, 0x88, 0x56,
0x38, 0xc4, 0x31, 0xcf, 0x1d, 0xf1, 0xc9, 0x94,
0x13, 0x16, 0x09, 0xb5, 0x80, 0xd4, 0xfd, 0x43,
0xa0, 0xca, 0xb1, 0x7d, 0xb2, 0xf1, 0x3e, 0xee
0x49, 0xc9, 0xa8, 0xc1, 0x8c, 0x4b, 0x88, 0x56,
0x38, 0xc4, 0x31, 0xcf, 0x1d, 0xf1, 0xc9, 0x94,
0x13, 0x16, 0x09, 0xb5, 0x80, 0xd4, 0xfd, 0x43,
0xa0, 0xca, 0xb1, 0x7d, 0xb2, 0xf1, 0x3e, 0xee
};

static const uint8_t public_key_data[] = {
0x04, 0x77, 0x72, 0x65, 0x6f, 0x81, 0x4b, 0x39,
0x92, 0x79, 0xd5, 0xe1, 0xf1, 0x78, 0x1f, 0xac,
0x6f, 0x09, 0x9a, 0x3c, 0x5c, 0xa1, 0xb0, 0xe3,
0x53, 0x51, 0x83, 0x4b, 0x08, 0xb6, 0x5e, 0x0b,
0x57, 0x25, 0x90, 0xcd, 0xaf, 0x8f, 0x76, 0x93,
0x61, 0xbc, 0xf3, 0x4a, 0xcf, 0xc1, 0x1e, 0x5e,
0x07, 0x4e, 0x84, 0x26, 0xbd, 0xde, 0x04, 0xbe,
0x6e, 0x65, 0x39, 0x45, 0x44, 0x96, 0x17, 0xde,
0x45
0x04, 0x77, 0x72, 0x65, 0x6f, 0x81, 0x4b, 0x39,
0x92, 0x79, 0xd5, 0xe1, 0xf1, 0x78, 0x1f, 0xac,
0x6f, 0x09, 0x9a, 0x3c, 0x5c, 0xa1, 0xb0, 0xe3,
0x53, 0x51, 0x83, 0x4b, 0x08, 0xb6, 0x5e, 0x0b,
0x57, 0x25, 0x90, 0xcd, 0xaf, 0x8f, 0x76, 0x93,
0x61, 0xbc, 0xf3, 0x4a, 0xcf, 0xc1, 0x1e, 0x5e,
0x07, 0x4e, 0x84, 0x26, 0xbd, 0xde, 0x04, 0xbe,
0x6e, 0x65, 0x39, 0x45, 0x44, 0x96, 0x17, 0xde,
0x45
};

static void psa_attestation_destroy_key_for_test()
Expand Down Expand Up @@ -108,16 +108,11 @@ void main_wrapper(void)

void pal_mbed_os_compliance_test_initialize(void)
{
if (COMPLIANCE_TEST_CRYPTO == type_g)
{
if (COMPLIANCE_TEST_CRYPTO == type_g) {
inject_entropy();
}
else if (COMPLIANCE_TEST_STORAGE == type_g)
{
} else if (COMPLIANCE_TEST_STORAGE == type_g) {
reset_storage_for_compliance_test();
}
else if (COMPLIANCE_TEST_ATTESTATION == type_g)
{
} else if (COMPLIANCE_TEST_ATTESTATION == type_g) {
reset_storage_for_compliance_test();
inject_entropy();
psa_crypto_init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
extern "C" {
#endif

typedef enum _compliance_test_type{
typedef enum _compliance_test_type {
COMPLIANCE_TEST_UNDEFINED,
COMPLIANCE_TEST_START = COMPLIANCE_TEST_UNDEFINED,
COMPLIANCE_TEST_CRYPTO,
COMPLIANCE_TEST_ATTESTATION,
COMPLIANCE_TEST_STORAGE,
COMPLIANCE_TEST_END
}compliance_test_type;
} compliance_test_type;

typedef void (*test_entry_f)(val_api_t *val_api, psa_api_t *psa_api);
int test_start(test_entry_f test_f, compliance_test_type type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,28 @@ uint32_t pal_ps_function(int type, va_list valist)
psa_storage_create_flags_t ps_create_flags;
struct psa_ps_info_t *ps_p_info;

switch (type)
{
case PAL_PS_SET:
uid = va_arg(valist, psa_storage_uid_t);
data_length = va_arg(valist, uint32_t);
p_write_data = va_arg(valist, const void*);
ps_create_flags = va_arg(valist, psa_storage_create_flags_t);
return psa_ps_set(uid, data_length, p_write_data, ps_create_flags);
case PAL_PS_GET:
uid = va_arg(valist, psa_storage_uid_t);
offset = va_arg(valist, uint32_t);
data_length = va_arg(valist, uint32_t);
p_read_data = va_arg(valist, void*);
return psa_ps_get(uid, offset, data_length, p_read_data, &actual_length);
case PAL_PS_GET_INFO:
uid = va_arg(valist, psa_storage_uid_t);
ps_p_info = va_arg(valist, struct psa_ps_info_t*);
return psa_ps_get_info(uid, ps_p_info);
case PAL_PS_REMOVE:
uid = va_arg(valist, psa_storage_uid_t);
return psa_ps_remove(uid);
default:
return PAL_STATUS_UNSUPPORTED_FUNC;
switch (type) {
case PAL_PS_SET:
uid = va_arg(valist, psa_storage_uid_t);
data_length = va_arg(valist, uint32_t);
p_write_data = va_arg(valist, const void *);
ps_create_flags = va_arg(valist, psa_storage_create_flags_t);
return psa_ps_set(uid, data_length, p_write_data, ps_create_flags);
case PAL_PS_GET:
uid = va_arg(valist, psa_storage_uid_t);
offset = va_arg(valist, uint32_t);
data_length = va_arg(valist, uint32_t);
p_read_data = va_arg(valist, void *);
return psa_ps_get(uid, offset, data_length, p_read_data, &actual_length);
case PAL_PS_GET_INFO:
uid = va_arg(valist, psa_storage_uid_t);
ps_p_info = va_arg(valist, struct psa_ps_info_t *);
return psa_ps_get_info(uid, ps_p_info);
case PAL_PS_REMOVE:
uid = va_arg(valist, psa_storage_uid_t);
return psa_ps_remove(uid);
default:
return PAL_STATUS_UNSUPPORTED_FUNC;
}
#else
return PAL_STATUS_ERROR;
Expand Down
Loading