Alinging return codes and optional PS api support
diff --git a/api-specs/include/protected_storage.h b/api-specs/include/protected_storage.h
index 9fdb1cd..8b13d97 100644
--- a/api-specs/include/protected_storage.h
+++ b/api-specs/include/protected_storage.h
@@ -37,7 +37,7 @@
typedef uint64_t psa_ps_uid_t;
#define PSA_PS_FLAG_NONE 0
-#define PSA_PS_FLAG_WRITE_ONCE (1 << 0) /**< The data associated with the uid will not be able to be modified or deleted. Intended to be used to set bits in `psa_eps_create_flags_t`*/
+#define PSA_PS_FLAG_WRITE_ONCE (1 << 0) /**< The data associated with the uid will not be able to be modified or deleted. Intended to be used to set bits in `psa_ps_create_flags_t`*/
/**
* \brief A container for metadata associated with a specific uid
@@ -57,32 +57,39 @@
#define PSA_PS_ERROR_INSUFFICIENT_SPACE 4 /**< The operation failed because there was insufficient space on the storage medium */
#define PSA_PS_ERROR_STORAGE_FAILURE 6 /**< The operation failed because the physical storage has failed (Fatal error) */
#define PSA_PS_ERROR_BAD_POINTER 7 /**< The operation failed because one of the provided pointers is invalid, for example is `NULL` or references memory the caller cannot access */
-#define PSA_PS_ERROR_KEY_NOT_FOUND 8 /**< The operation failed because the provided key value was not found in the storage */
+#define PSA_PS_ERROR_UID_NOT_FOUND 8 /**< The operation failed because the provided uid value was not found in the storage */
#define PSA_PS_ERROR_INCORRECT_SIZE 9 /**< The operation failed because the data associated with provided key is not the same size as `data_size`, or `offset+data_size` is too large for the data, but `offset` is less than the size */
#define PSA_PS_ERROR_OFFSET_INVALID 10 /**< The operation failed because an offset was supplied that is invalid for the existing data associated with the uid. For example, offset is greater that the size of the data */
+#define PSA_PS_ERROR_INVALID_ARGUMENT 11 /**< The operation failed because one or more of the given arguments were invalid (null pointer, wrong flags etc.) */
+#define PSA_PS_ERROR_DATA_CORRUPT 12 /**< The operation failed because data was corrupt when attempting to get the key */
+#define PSA_PS_ERROR_AUTH_FAILED 13 /**< The operation failed because of an authentication failure when attempting to get the key */
+#define PSA_PS_ERROR_OPERATION_FAILED 14 /**< The operation failed because of an unspecified/internal failure */
+#define PSA_PS_ERROR_INVALID_KEY 15 /**< The associated UID does not exist or the provided properties do no match the existing UID */
+#define PSA_PS_ERROR_NOT_SUPPORTED 16 /**< The returning function is not supported in this implementation of the API */
+/** Flag indicating that \ref psa_ps_create and \ref psa_ps_set_extended are supported */
+#define PSA_PS_SUPPORT_SET_EXTENDED (1 << 0)
/**
* \brief create a new or modify an existing key/value pair
*
* \param[in] uid the identifier for the data
* \param[in] data_length The size in bytes of the data in `p_data`
- * \param[in] p_data A buffer containing the data
+ * \param[in] p_data A buffer containing the data
* \param[in] create_flags The flags indicating the properties of the data
- *
+ *
* \return A status indicating the success/failure of the operation
-
- * \retval PSA_PS_SUCCESS The operation completed successfully
- * \retval PSA_PS_ERROR_WRITE_ONCE The operation failed because the provided uid value was already created with PSA_PS_WRITE_ONCE_FLAG
- * \retval PSA_PS_ERROR_FLAGS_NOT_SUPPORTED The operation failed because one or more of the flags provided in `create_flags` is not supported or is not valid
- * \retval PSA_PS_ERROR_FLAGS_SET_AFTER_CREATE The operation failed because a non-zero `create_flags` was provided for a previously created uid
- * \retval PSA_PS_ERROR_INSUFFICIENT_SPACE The operation failed because there was insufficient space on the storage medium
- * \retval PSA_PS_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
- * \retval PSA_PS_ERROR_BAD_POINTER The operation failed because one of the provided pointers(`p_data`)
- * is invalid, for example is `NULL` or references memory the caller cannot access
+
+ * \retval PSA_PS_SUCCESS The operation completed successfully
+ * \retval PSA_PS_ERROR_WRITE_ONCE The operation failed because the provided uid value was already created with PSA_PS_WRITE_ONCE_FLAG
+ * \retval PSA_PS_ERROR_INVALID_ARGUMENT The operation The operation failed because one or more of the given arguments were invalid.
+ * \retval PSA_PS_ERROR_FLAGS_NOT_SUPPORTED The operation failed because one or more of the flags provided in `create_flags` is not supported or is not valid
+ * \retval PSA_PS_ERROR_INSUFFICIENT_SPACE The operation failed because there was insufficient space on the storage medium
+ * \retval PSA_PS_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
+ * \retval PSA_PS_ERROR_OPERATION_FAILED The operation failed because of an unspecified internal failure
*/
-psa_ps_status_t psa_ps_set( psa_ps_uid_t uid, uint32_t data_length,
- const void *p_data, psa_ps_create_flags_t create_flags );
+psa_ps_status_t psa_ps_set(psa_ps_uid_t uid, uint32_t data_length,
+ const void *p_data, psa_ps_create_flags_t create_flags);
/**
* \brief Retrieve the value for a provided uid
@@ -91,49 +98,51 @@
* \param[in] data_offset The offset within the data associated with the `uid` to start retrieving data
* \param[in] data_length The amount of data to read (and the minimum allocated size of the `p_data` buffer)
* \param[out] p_data The buffer where the data will be placed upon successful completion
- *
+ *
* \return A status indicating the success/failure of the operation
*
- * \retval PSA_PS_SUCCESS The operation completed successfully
- * \retval PSA_PS_ERROR_KEY_NOT_FOUND The operation failed because the provided uid value was not found in the storage
- * \retval PSA_PS_ERROR_INCORRECT_SIZE The operation failed because the data associated with provided uid is not the same size as `data_size`
- * \retval PSA_PS_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
- * \retval PSA_PS_ERROR_BAD_POINTER The operation failed because one of the provided pointers(`p_data`)
- * is invalid, for example is `NULL` or references memory the caller cannot access
- * \retval PSA_PS_ERROR_OFFSET_INVALID The operation failed because an offset was supplied that is invalid for the existing data associated with the
- * uid. For example, offset + size is invalid
- * \retval PSA_PS_ERROR_OFFSET_NOT_SUPPORTED A non-zero offset was supplied, but the implementation does not support offsets
+ * \retval PSA_PS_ERROR_INVALID_ARGUMENT The operation The operation failed because one or more of the given arguments were invalid (null pointer, wrong flags etc.)
+ * \retval PSA_PS_ERROR_UID_NOT_FOUND The operation failed because the provided uid value was not found in the storage
+ * \retval PSA_PS_ERROR_INCORRECT_SIZE The operation failed because the data associated with provided uid is not the same size as `data_size`
+ * \retval PSA_PS_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
+ * \retval PSA_PS_ERROR_OPERATION_FAILED The operation failed because of an unspecified internal failure
+ * \retval PSA_PS_ERROR_DATA_CORRUPT The operation failed because of an authentication failure when attempting to get the key
+ * \retval PSA_PS_ERROR_AUTH_FAILED The operation failed because of an unspecified internal failure
*/
-psa_ps_status_t psa_ps_get( psa_ps_uid_t uid, uint32_t data_offset,
- uint32_t data_length, void *p_data );
+psa_ps_status_t psa_ps_get(psa_ps_uid_t uid, uint32_t data_offset,
+ uint32_t data_length, void *p_data );
/**
* \brief Retrieve the metadata about the provided uid
- *
+ *
* \param[in] uid The identifier for the data
* \param[out] p_info A pointer to the `psa_ps_info_t` struct that will be populated with the metadata
- *
+ *
* \return A status indicating the success/failure of the operation
- *
- * \retval PSA_PS_SUCCESS The operation completed successfully
- * \retval PSA_PS_ERROR_KEY_NOT_FOUND The operation failed because the provided uid value was not found in the storage
+ *
+ * \retval PSA_PS_ERROR_SUCCESS The operation completed successfully
+ * \retval PSA_PS_ERROR_INVALID_ARGUMENT The operation The operation failed because one or more of the given arguments were invalid (null pointer, wrong flags etc.)
+ * \retval PSA_PS_ERROR_UID_NOT_FOUND The operation failed because the provided uid value was not found in the storage
* \retval PSA_PS_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
- * \retval PSA_PS_ERROR_BAD_POINTER The operation failed because one of the provided pointers(`p_info`)
- * is invalid, for example is `NULL` or references memory the caller cannot access
+ * \retval PSA_PS_ERROR_OPERATION_FAILED The operation failed because of an unspecified internal failure
+ * \retval PSA_PS_ERROR_DATA_CORRUPT The operation failed because of an authentication failure when attempting to get the key
+ * \retval PSA_PS_ERROR_AUTH_FAILED The operation failed because of an unspecified internal failure
*/
psa_ps_status_t psa_ps_get_info( psa_ps_uid_t uid, struct psa_ps_info_t *p_info);
/**
* \brief Remove the provided uid and its associated data from the storage
- *
+ *
* \param[in] uid The identifier for the data to be removed
- *
+ *
* \return A status indicating the success/failure of the operation
- *
+ *
* \retval PSA_PS_SUCCESS The operation completed successfully
- * \retval PSA_PS_ERROR_KEY_NOT_FOUND The operation failed because the provided uid value was not found in the storage
+ * \retval PSA_PS_ERROR_INVALID_ARGUMENT The operation The operation failed because one or more of the given arguments were invalid (null pointer, wrong flags etc.)
+ * \retval PSA_PS_ERROR_UID_NOT_FOUND The operation failed because the provided uid value was not found in the storage
* \retval PSA_PS_ERROR_WRITE_ONCE The operation failed because the provided uid value was created with psa_eps_WRITE_ONCE_FLAG
* \retval PSA_PS_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
+ * \retval PSA_PS_ERROR_OPERATION_FAILED The operation failed because of an unspecified internal failure
*/
psa_ps_status_t psa_ps_remove( psa_ps_uid_t uid);
@@ -141,10 +150,14 @@
* Creates an asset based on the given identifier, the maximum size and
* creation flags. This create allocates the space in the secure storage
* area without setting any data in the asset.
+ *
* It is only necessary to call this function for items that will be written
* with the \ref psa_ps_set_extended function. If only the \ref psa_ps_set function
* is needed, calls to this function are redundant.
*
+ * If the \ref PSA_PS_FLAG_WRITE_ONCE flag is passed, implementations should
+ * return \ref PSA_PS_ERROR_FLAGS_NOT_SUPPORTED.
+ *
* This function is optional. Not all PSA Protected Storage Implementations
* will implement this function. Consult the documentation of your chosen
* platform to determine if it is present.
@@ -161,17 +174,18 @@
* \retval PSA_PS_ERROR_STORAGE_FAILURE The create action has a physical storage error
* \retval PSA_PS_ERROR_INSUFFICIENT_SPACE The maximum size is bigger of the current available space
* \retval PSA_PS_ERROR_FLAGS_NOT_SUPPORTED One or more create_flags are not valid or supported
- * \retval PSA_PS_ERROR_INVALID_KEY The the asset exists and the input paramters are not the same as the existing asset
+ * \retval PSA_PS_ERROR_INVALID_KEY The asset exists and the input paramters are not the same as the existing asset
+ * \retval PSA_PS_ERROR_NOT_SUPPORTED The implementation of the API does not support this function
*/
-psa_its_status_t psa_ps_create( psa_ps_uid_t uid, uint32_t size,
- psa_ps_create_flags_t create_flags);
+psa_ps_status_t psa_ps_create( psa_ps_uid_t uid, uint32_t size,
+ psa_ps_create_flags_t create_flags);
/**
* Sets partial data into an asset based on the given identifier, data_offset,
* data length and p_data.
*
- * Before calling this function, the asset must have been created with a cal
- * to \ref psa_ps_create
+ * Before calling this function, the asset must have been created with a call
+ * to \ref psa_ps_create.
*
* This function is optional. Not all PSA Protected Storage Implementations
* will implement this function. Consult the documentation of your chosen
@@ -192,8 +206,18 @@
* is too large
* \retval PSA_PS_ERROR_BAD_POINTER If p_data is NULL or references memory the caller cannot access
* \retval PSA_PS_ERROR_INVALID_KEY If the asset does not exist
+ * \retval PSA_PS_ERROR_NOT_SUPPORTED The implementation of the API does not support this function
*/
-psa_its_status_t psa_ps_set_extended( psa_ps_uid_t uid, uint32_t data_offset,
- uint32_t data_length, const void *p_data);
+psa_ps_status_t psa_ps_set_extended( psa_ps_uid_t uid, uint32_t data_offset,
+ uint32_t data_length, const void *p_data);
+
+/**
+ * Returns a bitmask with flags set for all of the optional features supported
+ * by the implementation.
+ *
+ * Currently defined flags are limited to:
+ * - \ref PSA_PS_SUPPORT_SET_EXTENDED
+ */
+uint32_t psa_ps_get_support();
#endif // __PROTECTED_STORAGE_H__
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s001/test_ps_data.h b/api-tests/dev_apis/internal_trusted_storage/test_s001/test_ps_data.h
index 906cb19..21a1409 100644
--- a/api-tests/dev_apis/internal_trusted_storage/test_s001/test_ps_data.h
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s001/test_ps_data.h
@@ -34,13 +34,13 @@
"This is dummy for index0", 0, 0
},
{
- "Call the get api when no uid is set", VAL_PS_GET, PSA_PS_ERROR_KEY_NOT_FOUND
+ "Call the get api when no uid is set", VAL_PS_GET, PSA_PS_ERROR_UID_NOT_FOUND
},
{
- "Call the get_info api when no uid is set", VAL_PS_GET_INFO, PSA_PS_ERROR_KEY_NOT_FOUND
+ "Call the get_info api when no uid is set", VAL_PS_GET_INFO, PSA_PS_ERROR_UID_NOT_FOUND
},
{
- "Call the remove api when no uid is set", VAL_PS_REMOVE, PSA_PS_ERROR_KEY_NOT_FOUND
+ "Call the remove api when no uid is set", VAL_PS_REMOVE, PSA_PS_ERROR_UID_NOT_FOUND
},
{
"Create a valid storage entity with uid1", VAL_PS_SET, PSA_PS_SUCCESS
@@ -52,25 +52,25 @@
"Remove uid1", VAL_PS_REMOVE, PSA_PS_SUCCESS
},
{
- "Call get api for uid1", VAL_PS_GET, PSA_PS_ERROR_KEY_NOT_FOUND
+ "Call get api for uid1", VAL_PS_GET, PSA_PS_ERROR_UID_NOT_FOUND
},
{
- "Call get_info api for uid1", VAL_PS_GET_INFO, PSA_PS_ERROR_KEY_NOT_FOUND
+ "Call get_info api for uid1", VAL_PS_GET_INFO, PSA_PS_ERROR_UID_NOT_FOUND
},
{
- "Call remove api for uid1", VAL_PS_REMOVE, PSA_PS_ERROR_KEY_NOT_FOUND
+ "Call remove api for uid1", VAL_PS_REMOVE, PSA_PS_ERROR_UID_NOT_FOUND
},
{
"Create a valid storage entity again with uid1", VAL_PS_SET, PSA_PS_SUCCESS
},
{
- "Call get api for uid not same as uid1 or uid2", VAL_PS_GET, PSA_PS_ERROR_KEY_NOT_FOUND
+ "Call get api for uid not same as uid1 or uid2", VAL_PS_GET, PSA_PS_ERROR_UID_NOT_FOUND
},
{
- "Call get_info for uid not same as uid1 or uid2", VAL_PS_GET_INFO, PSA_PS_ERROR_KEY_NOT_FOUND
+ "Call get_info for uid not same as uid1 or uid2", VAL_PS_GET_INFO, PSA_PS_ERROR_UID_NOT_FOUND
},
{
- "Call remove api for uid not same as uid1 or uid2", VAL_PS_REMOVE, PSA_PS_ERROR_KEY_NOT_FOUND
+ "Call remove api for uid not same as uid1 or uid2", VAL_PS_REMOVE, PSA_PS_ERROR_UID_NOT_FOUND
},
{
"Remove uid1", VAL_PS_REMOVE, PSA_PS_SUCCESS
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s002/test_its_data.h b/api-tests/dev_apis/internal_trusted_storage/test_s002/test_its_data.h
index 0179c96..51f0478 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s002/test_its_data.h
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s002/test_its_data.h
@@ -48,7 +48,7 @@
"Index not used as check for get info flag",0,0
},
{
- "validate the data using get api", VAL_ITS_GET, PSA_ITS_SUCCESS
+ "Validate the data using get api", VAL_ITS_GET, PSA_ITS_SUCCESS
},
{
"Index not used",0,0
@@ -72,16 +72,16 @@
"Index not used",0,0
},
{
- " storage should not be removed after WRITE_ONCE flag", VAL_ITS_REMOVE, PSA_ITS_ERROR_WRITE_ONCE
+ "Storage should not be removed after WRITE_ONCE flag", VAL_ITS_REMOVE, PSA_ITS_ERROR_WRITE_ONCE
},
{
"Create a valid storage with different uid and flag value WRITE_ONCE ", VAL_ITS_SET, PSA_ITS_SUCCESS
},
{
- "storage should not be removed", VAL_ITS_REMOVE, PSA_ITS_ERROR_WRITE_ONCE
+ "Storage should not be removed", VAL_ITS_REMOVE, PSA_ITS_ERROR_WRITE_ONCE
},
{
- "validate the data using get api after flag change", VAL_ITS_GET, PSA_ITS_SUCCESS
+ "Validate the data using get api after flag change", VAL_ITS_GET, PSA_ITS_SUCCESS
},
{
"Index not used",0,0
@@ -96,10 +96,10 @@
"Index not used as check for get info flag",0,0
},
{
- "try to set different size for same uid and flag value ", VAL_ITS_SET, PSA_ITS_ERROR_WRITE_ONCE
+ "Try to set different size for same uid and flag value ", VAL_ITS_SET, PSA_ITS_ERROR_WRITE_ONCE
},
{
- "storage should not be removed", VAL_ITS_REMOVE, PSA_ITS_ERROR_WRITE_ONCE
+ "Storage should not be removed", VAL_ITS_REMOVE, PSA_ITS_ERROR_WRITE_ONCE
},
{
"Call the get_info api to validate the flag change", VAL_ITS_GET_INFO, PSA_ITS_SUCCESS
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s002/test_ps_data.h b/api-tests/dev_apis/internal_trusted_storage/test_s002/test_ps_data.h
index df4ce83..8d09551 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s002/test_ps_data.h
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s002/test_ps_data.h
@@ -48,7 +48,7 @@
"Index not used as check for get info flag",0,0
},
{
- "validate the data using get api", VAL_PS_GET, PSA_PS_SUCCESS
+ "Validate the data using get api", VAL_PS_GET, PSA_PS_SUCCESS
},
{
"Index not used",0,0
@@ -66,22 +66,22 @@
"Index not used as check for get info flag",0,0
},
{
- "validate the data using get api after flag change", VAL_PS_GET, PSA_PS_SUCCESS
+ "Validate the data using get api after flag change", VAL_PS_GET, PSA_PS_SUCCESS
},
{
"Index not used",0,0
},
{
- " storage should not be removed after WRITE_ONCE flag", VAL_PS_REMOVE, PSA_PS_ERROR_WRITE_ONCE
+ "Storage should not be removed after WRITE_ONCE flag", VAL_PS_REMOVE, PSA_PS_ERROR_WRITE_ONCE
},
{
"Create a valid storage with different uid and flag value WRITE_ONCE ", VAL_PS_SET, PSA_PS_SUCCESS
},
{
- "storage should not be removed", VAL_PS_REMOVE, PSA_PS_ERROR_WRITE_ONCE
+ "Storage should not be removed", VAL_PS_REMOVE, PSA_PS_ERROR_WRITE_ONCE
},
{
- "validate the data using get api after flag change", VAL_PS_GET, PSA_PS_SUCCESS
+ "Validate the data using get api after flag change", VAL_PS_GET, PSA_PS_SUCCESS
},
{
"Index not used",0,0
@@ -96,7 +96,7 @@
"Index not used as check for get info flag",0,0
},
{
- "try to set different size for same uid and flag value ", VAL_PS_SET, PSA_PS_ERROR_WRITE_ONCE
+ "Try to set different size for same uid and flag value ", VAL_PS_SET, PSA_PS_ERROR_WRITE_ONCE
},
{
"storage should not be removed", VAL_PS_REMOVE, PSA_PS_ERROR_WRITE_ONCE
@@ -111,7 +111,7 @@
"Index not used as check for get info flag",0,0
},
{
- "validate the data using get api after flag change", VAL_PS_GET, PSA_PS_SUCCESS
+ "Validate the data using get api after flag change", VAL_PS_GET, PSA_PS_SUCCESS
},
{
"Index not used",0,0
@@ -120,6 +120,9 @@
"Setting flag to zero for uid should fail ", VAL_PS_SET, PSA_PS_ERROR_WRITE_ONCE
},
{
+ "Storage should not be removed", VAL_PS_REMOVE, PSA_PS_ERROR_WRITE_ONCE
+},
+{
"Check that the WRITE_ONCE flag is preserved", VAL_PS_GET_INFO, PSA_PS_SUCCESS
},
{
@@ -129,4 +132,4 @@
"Index not used as check for get info flag",0,0
},
};
-#endif /* _TEST_S001_PS_DATA_TESTS_H_ */
+#endif /* _TEST_S002_PS_DATA_TESTS_H_ */
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s003/test_s003.c b/api-tests/dev_apis/internal_trusted_storage/test_s003/test_s003.c
index 38a568f..2232a57 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s003/test_s003.c
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s003/test_s003.c
@@ -26,6 +26,7 @@
#define TEST_BUFF_SIZE 256
#define NUM_ITERATIONS 5
+#define TEST_BASE_UID_VALUE 20
client_test_t test_s003_sst_list[] = {
NULL,
@@ -46,21 +47,27 @@
for (i = 0 ; i < NUM_ITERATIONS; i++)
{
val->print(PRINT_TEST, "[Check %d] Overload storage space\n", i + 1 );
- for (uid = 1; status == PSA_SST_SUCCESS; uid++)
+ for (uid = TEST_BASE_UID_VALUE; status == PSA_SST_SUCCESS; uid++)
{
val->print(PRINT_INFO, "Setting 0x%x bytes for ", TEST_BUFF_SIZE);
- val->print(PRINT_INFO, "UID 0x%x\n", uid);
+ val->print(PRINT_INFO, "UID %d\n", uid);
status = SST_FUNCTION(s003_data[1].api, uid, TEST_BUFF_SIZE, write_buff, 0);
+ if (status != PSA_SST_SUCCESS)
+ {
+ val->print(PRINT_TEST, "UID %d set failed, Storage Space is exhausted\n", uid);
+ break;
+ }
}
TEST_ASSERT_EQUAL(status, s003_data[1].status, TEST_CHECKPOINT_NUM(1));
/* Store number of set()s it took to saturate the storage */
- count = uid;
- results[i] = uid - 1;
+ count = uid - TEST_BASE_UID_VALUE;
+ results[i] = uid - TEST_BASE_UID_VALUE;
val->print(PRINT_TEST, "Remove all registered UIDs\n", 0);
- for (uid = 1; uid < count; uid++)
+ for (uid = TEST_BASE_UID_VALUE; uid < count + TEST_BASE_UID_VALUE; uid++)
{
+ val->print(PRINT_INFO, "Removing UID %d\n", uid);
status = SST_FUNCTION(s003_data[2].api, uid);
if (status != PSA_SST_SUCCESS)
return VAL_STATUS_ERROR;
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s004/test_its_data.h b/api-tests/dev_apis/internal_trusted_storage/test_s004/test_its_data.h
index ab29232..6ec9467 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s004/test_its_data.h
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s004/test_its_data.h
@@ -36,7 +36,7 @@
"Create a valid storage entity ", VAL_ITS_SET, PSA_ITS_SUCCESS
},
{
- "validate the data using get api after set api failure", VAL_ITS_GET, PSA_ITS_SUCCESS
+ "Validate the data using get api after set api failure", VAL_ITS_GET, PSA_ITS_SUCCESS
},
{
"Index not used",0,0
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s005/test_its_data.h b/api-tests/dev_apis/internal_trusted_storage/test_s005/test_its_data.h
index 5c7693f..5e7cc9c 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s005/test_its_data.h
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s005/test_its_data.h
@@ -38,13 +38,13 @@
"Create a valid storage entity ", VAL_ITS_SET, PSA_ITS_SUCCESS
},
{
- "validate the data using get api", VAL_ITS_GET, PSA_ITS_SUCCESS
+ "Validate the data using get api", VAL_ITS_GET, PSA_ITS_SUCCESS
},
{
"Index not used",0,0
},
{
- "validate the data attributes get_info api", VAL_ITS_GET_INFO, PSA_ITS_SUCCESS
+ "Validate the data attributes get_info api", VAL_ITS_GET_INFO, PSA_ITS_SUCCESS
},
{
"Index not used",0,0
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s005/test_ps_data.h b/api-tests/dev_apis/internal_trusted_storage/test_s005/test_ps_data.h
index a928ed1..55770f5 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s005/test_ps_data.h
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s005/test_ps_data.h
@@ -38,13 +38,13 @@
"Create a valid storage entity ", VAL_PS_SET, PSA_PS_SUCCESS
},
{
- "validate the data using get api", VAL_PS_GET, PSA_PS_SUCCESS
+ "Validate the data using get api", VAL_PS_GET, PSA_PS_SUCCESS
},
{
"Index not used",0,0
},
{
- "validate the data attributes get_info api", VAL_PS_GET_INFO, PSA_PS_SUCCESS
+ "Validate the data attributes get_info api", VAL_PS_GET_INFO, PSA_PS_SUCCESS
},
{
"Index not used",0,0
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s005/test_s005.c b/api-tests/dev_apis/internal_trusted_storage/test_s005/test_s005.c
index 6e8b0b4..d372172 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s005/test_s005.c
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s005/test_s005.c
@@ -72,7 +72,7 @@
/* Calling SET function with BASE uid_value , data_len zero and valid data pointer */
val->print(PRINT_TEST, "[Check 1] Set UID with data length zero and call storage apis\n", 0);
- if (psa_sst_apis_check(UID_BASE_VALUE, data_len, write_buff, flag))
+ if (psa_sst_apis_check(UID_BASE_VALUE + 1, data_len, write_buff, flag))
{
val->print(PRINT_ERROR, "Data Len = %d\n", data_len);
val->print(PRINT_ERROR, "Create Flag value = %d\n", flag);
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s006/test_its_data.h b/api-tests/dev_apis/internal_trusted_storage/test_s006/test_its_data.h
index e6ddd35..4468340 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s006/test_its_data.h
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s006/test_its_data.h
@@ -39,7 +39,7 @@
"Create a valid storage entity with different flag values ", VAL_ITS_SET, PSA_ITS_SUCCESS
},
{
- "validate the flag value get_info api", VAL_ITS_GET_INFO, PSA_ITS_SUCCESS
+ "Validate the flag value get_info api", VAL_ITS_GET_INFO, PSA_ITS_SUCCESS
},
{
"Index not used",0,0
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s006/test_ps_data.h b/api-tests/dev_apis/internal_trusted_storage/test_s006/test_ps_data.h
index 400723b..6ec89ee 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s006/test_ps_data.h
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s006/test_ps_data.h
@@ -39,7 +39,7 @@
"Create a valid storage entity with different flag values ", VAL_PS_SET, PSA_PS_SUCCESS
},
{
- "validate the flag value get_info api", VAL_PS_GET_INFO, PSA_PS_SUCCESS
+ "Validate the flag value get_info api", VAL_PS_GET_INFO, PSA_PS_SUCCESS
},
{
"Index not used",0,0
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s007/test_entry.c b/api-tests/dev_apis/internal_trusted_storage/test_s007/test_entry.c
index 9dbc1df..5d25221 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s007/test_entry.c
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s007/test_entry.c
@@ -20,7 +20,7 @@
#include "test_s007.h"
#define TEST_NUM VAL_CREATE_TEST_ID(VAL_STORAGE_BASE, 7)
-#define TEST_DESC "Flag set after create error check\n"
+#define TEST_DESC "Incorrect Size error check\n"
TEST_PUBLISH(TEST_NUM, test_entry);
val_api_t *val = NULL;
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s007/test_its_data.h b/api-tests/dev_apis/internal_trusted_storage/test_s007/test_its_data.h
index 90c4931..c06d951 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s007/test_its_data.h
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s007/test_its_data.h
@@ -28,31 +28,36 @@
psa_its_status_t status;
} test_data;
-static psa_its_create_flags_t flag;
static test_data s007_data[] = {
{
"This is dummy for index0", 0, 0
},
{
- "Create a valid storage entity with non-zero flag value", VAL_ITS_SET, PSA_ITS_SUCCESS
+ "Create a valid storage entity", VAL_ITS_SET, PSA_ITS_SUCCESS
},
{
- "try to change the flag value with another non-zero value", VAL_ITS_SET, PSA_ITS_ERROR_FLAGS_SET_AFTER_CREATE
+ "Increase the length of storage", VAL_ITS_SET, PSA_ITS_SUCCESS
},
{
- "try to change the flag value with zero value", VAL_ITS_SET, PSA_ITS_ERROR_FLAGS_SET_AFTER_CREATE
+ "Try to access old length", VAL_ITS_GET, PSA_ITS_SUCCESS
},
{
- "Remove the storage entity ", VAL_ITS_REMOVE, PSA_ITS_SUCCESS
+ "Try to access valid length less than set length ", VAL_ITS_GET, PSA_ITS_SUCCESS
},
{
- "Create a valid storage entity with zero flag value", VAL_ITS_SET, PSA_ITS_SUCCESS
+ "This is dummy for index5", 0, 0
},
{
- "try to change the flag value with non-zero value", VAL_ITS_SET, PSA_ITS_SUCCESS
+ "Decrease the length of storage", VAL_ITS_SET, PSA_ITS_SUCCESS
},
{
- "try to change the flag again to zero value", VAL_ITS_SET, PSA_ITS_ERROR_FLAGS_SET_AFTER_CREATE
+ "Try to access old length", VAL_ITS_GET, PSA_ITS_ERROR_INCORRECT_SIZE
+},
+{
+ "Try to access old length", VAL_ITS_GET, PSA_ITS_ERROR_INCORRECT_SIZE
+},
+{
+ "Try to access data with correct length", VAL_ITS_GET, PSA_ITS_SUCCESS
},
{
"Remove the storage entity ", VAL_ITS_REMOVE, PSA_ITS_SUCCESS
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s007/test_ps_data.h b/api-tests/dev_apis/internal_trusted_storage/test_s007/test_ps_data.h
index 6757c9a..ff2601f 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s007/test_ps_data.h
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s007/test_ps_data.h
@@ -28,31 +28,36 @@
psa_ps_status_t status;
} test_data;
-static psa_ps_create_flags_t flag;
static test_data s007_data[] = {
{
"This is dummy for index0", 0, 0
},
{
- "Create a valid storage entity with non-zero flag value", VAL_PS_SET, PSA_PS_SUCCESS
+ "Create a valid storage entity", VAL_PS_SET, PSA_PS_SUCCESS
},
{
- "try to change the flag value with another non-zero value", VAL_PS_SET, PSA_PS_ERROR_FLAGS_SET_AFTER_CREATE
+ "Increase the length of storage", VAL_PS_SET, PSA_PS_SUCCESS
},
{
- "try to change the flag value with zero value", VAL_PS_SET, PSA_PS_ERROR_FLAGS_SET_AFTER_CREATE
+ "Try to access old length", VAL_PS_GET, PSA_PS_SUCCESS
},
{
- "Remove the storage entity ", VAL_PS_REMOVE, PSA_PS_SUCCESS
+ "Try to access valid length less than set length ", VAL_PS_GET, PSA_PS_SUCCESS
},
{
- "Create a valid storage entity with zero flag value", VAL_PS_SET, PSA_PS_SUCCESS
+ "This is dummy for index5", 0, 0
},
{
- "try to change the flag value with non-zero value", VAL_PS_SET, PSA_PS_SUCCESS
+ "Decrease the length of storage", VAL_PS_SET, PSA_PS_SUCCESS
},
{
- "try to change the flag again to zero value", VAL_PS_SET, PSA_PS_ERROR_FLAGS_SET_AFTER_CREATE
+ "Try to access old length", VAL_PS_GET, PSA_PS_ERROR_INCORRECT_SIZE
+},
+{
+ "Try to access old length", VAL_PS_GET, PSA_PS_ERROR_INCORRECT_SIZE
+},
+{
+ "Try to access data with correct length", VAL_PS_GET, PSA_PS_SUCCESS
},
{
"Remove the storage entity ", VAL_PS_REMOVE, PSA_PS_SUCCESS
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s007/test_s007.c b/api-tests/dev_apis/internal_trusted_storage/test_s007/test_s007.c
index a520837..4dabb0c 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s007/test_s007.c
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s007/test_s007.c
@@ -28,51 +28,56 @@
client_test_t test_s007_sst_list[] = {
NULL,
- psa_sst_api_flag_set_after_create,
+ psa_sst_get_incorrect_size,
NULL,
};
static uint8_t write_buff[TEST_BUFF_SIZE] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x23, 0xF6, 0x07, 0x08, 0x0D, 0x0A, 0x1B, 0x0C, 0x5D, 0x0E,\
0x70, 0xA1, 0xFF, 0xFF, 0x14, 0x73, 0x46, 0x97, 0xE8, 0xDD, 0xCA, 0x0B, 0x3C, 0x0D, 0x2E};
+static uint8_t read_buff[TEST_BUFF_SIZE];
-int32_t psa_sst_api_flag_set_after_create(security_t caller)
+int32_t psa_sst_get_incorrect_size(security_t caller)
{
psa_sst_uid_t uid = UID_BASE_VALUE + 10;
uint32_t status = VAL_STATUS_SUCCESS;
- flag = 0x0000100;
/* Set the uid with the data_len and data_buff */
- status = SST_FUNCTION(s007_data[1].api, uid, TEST_BUFF_SIZE/2, write_buff, flag);
+ status = SST_FUNCTION(s007_data[1].api, uid, TEST_BUFF_SIZE/2, write_buff, 0);
TEST_ASSERT_EQUAL(status, s007_data[1].status, TEST_CHECKPOINT_NUM(1));
- /* Call set for same uid and different non-zero flag value */
- status = SST_FUNCTION(s007_data[2].api, uid, TEST_BUFF_SIZE, write_buff, flag<<1);
+ /* Call set for same uid and increase the length */
+ status = SST_FUNCTION(s007_data[2].api, uid, TEST_BUFF_SIZE, write_buff, 0);
TEST_ASSERT_EQUAL(status, s007_data[2].status, TEST_CHECKPOINT_NUM(2));
- /* Call set for same uid and different nzero flag value */
- status = SST_FUNCTION(s007_data[3].api, uid, TEST_BUFF_SIZE, write_buff, 0);
+ /* Access data using get api and old length */
+ status = SST_FUNCTION(s007_data[3].api, uid, 0, TEST_BUFF_SIZE/2, read_buff);
TEST_ASSERT_EQUAL(status, s007_data[3].status, TEST_CHECKPOINT_NUM(3));
- /* Remove the uid */
- status = SST_FUNCTION(s007_data[4].api, uid);
+ /* Access data using get api and valid length */
+ status = SST_FUNCTION(s007_data[4].api, uid, 0, TEST_BUFF_SIZE/4, read_buff);
TEST_ASSERT_EQUAL(status, s007_data[4].status, TEST_CHECKPOINT_NUM(4));
+ TEST_ASSERT_MEMCMP(read_buff, write_buff, TEST_BUFF_SIZE/4, TEST_CHECKPOINT_NUM(5));
- /* Set the uid with the data_len and data_buff */
- status = SST_FUNCTION(s007_data[5].api, uid, TEST_BUFF_SIZE, write_buff, 0);
- TEST_ASSERT_EQUAL(status, s007_data[5].status, TEST_CHECKPOINT_NUM(5));
-
- /* Call set for same uid and different non-zero flag value */
- status = SST_FUNCTION(s007_data[6].api, uid, TEST_BUFF_SIZE, write_buff, flag);
+ /* Decrease the length again */
+ status = SST_FUNCTION(s007_data[6].api, uid, TEST_BUFF_SIZE/4, write_buff, 0);
TEST_ASSERT_EQUAL(status, s007_data[6].status, TEST_CHECKPOINT_NUM(6));
- /* Call set for same uid and different zero flag value */
- status = SST_FUNCTION(s007_data[7].api, uid, TEST_BUFF_SIZE, write_buff, flag);
+ /* Access data using get api and old length */
+ status = SST_FUNCTION(s007_data[7].api, uid, 0, TEST_BUFF_SIZE/2, read_buff);
TEST_ASSERT_EQUAL(status, s007_data[7].status, TEST_CHECKPOINT_NUM(7));
- /* Remove the uid */
- status = SST_FUNCTION(s007_data[8].api, uid);
+ /* Access data using get api and old length */
+ status = SST_FUNCTION(s007_data[8].api, uid, 0, TEST_BUFF_SIZE, read_buff);
TEST_ASSERT_EQUAL(status, s007_data[8].status, TEST_CHECKPOINT_NUM(8));
- return status;
+ /* Access data using correct length */
+ status = SST_FUNCTION(s007_data[9].api, uid, 0, TEST_BUFF_SIZE/4, read_buff);
+ TEST_ASSERT_EQUAL(status, s007_data[9].status, TEST_CHECKPOINT_NUM(9));
+
+ /* Remove the uid */
+ status = SST_FUNCTION(s007_data[10].api, uid);
+ TEST_ASSERT_EQUAL(status, s007_data[10].status, TEST_CHECKPOINT_NUM(10));
+
+ return status;
}
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s007/test_s007.h b/api-tests/dev_apis/internal_trusted_storage/test_s007/test_s007.h
index 37775b0..5a71e4b 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s007/test_s007.h
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s007/test_s007.h
@@ -31,6 +31,6 @@
extern psa_api_t *psa;
extern client_test_t test_s007_sst_list[];
-int32_t psa_sst_api_flag_set_after_create(security_t caller);
+int32_t psa_sst_get_incorrect_size(security_t caller);
#endif /* _TEST_S007_CLIENT_TESTS_H_ */
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s009/test_its_data.h b/api-tests/dev_apis/internal_trusted_storage/test_s009/test_its_data.h
index 0fb4dc0..5f3c8e0 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s009/test_its_data.h
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s009/test_its_data.h
@@ -43,7 +43,7 @@
"Create storage of zero size", VAL_ITS_SET, PSA_ITS_SUCCESS
},
{
- "try to set 0 buffer for previous created storage", VAL_ITS_SET, PSA_ITS_ERROR_BAD_POINTER
+ "Try to set 0 buffer for previous created storage", VAL_ITS_SET, PSA_ITS_ERROR_BAD_POINTER
},
{
"Call get_info api to check data size", VAL_ITS_GET_INFO, PSA_ITS_SUCCESS
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s009/test_ps_data.h b/api-tests/dev_apis/internal_trusted_storage/test_s009/test_ps_data.h
index 53f20e9..7fb2f5e 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s009/test_ps_data.h
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s009/test_ps_data.h
@@ -34,16 +34,16 @@
"This is dummy for index0", 0, 0
},
{
- "Call set api with 0 write buffer", VAL_PS_SET, PSA_PS_ERROR_BAD_POINTER
+ "Call set api with 0 write buffer", VAL_PS_SET, PSA_PS_ERROR_INVALID_ARGUMENT
},
{
- "Call to get_info api should fail", VAL_PS_GET_INFO, PSA_PS_ERROR_KEY_NOT_FOUND
+ "Call to get_info api should fail", VAL_PS_GET_INFO, PSA_PS_ERROR_UID_NOT_FOUND
},
{
"Create storage of zero size", VAL_PS_SET, PSA_PS_SUCCESS
},
{
- "try to set 0 buffer for previous created storage", VAL_PS_SET, PSA_PS_ERROR_BAD_POINTER
+ "Try to set 0 buffer for previous created storage", VAL_PS_SET, PSA_PS_ERROR_INVALID_ARGUMENT
},
{
"Call get_info api to check data size", VAL_PS_GET_INFO, PSA_PS_SUCCESS
@@ -52,10 +52,10 @@
"This is dummy for index6", 0, 0
},
{
- "Call get api with 0 read buffer", VAL_PS_GET, PSA_PS_ERROR_BAD_POINTER
+ "Call get api with 0 read buffer", VAL_PS_GET, PSA_PS_ERROR_INVALID_ARGUMENT
},
{
- "Call get_info api with 0 info buffer", VAL_PS_GET_INFO, PSA_PS_ERROR_BAD_POINTER
+ "Call get_info api with 0 info buffer", VAL_PS_GET_INFO, PSA_PS_ERROR_INVALID_ARGUMENT
},
{
"Remove the storage entity ", VAL_PS_REMOVE, PSA_PS_SUCCESS
diff --git a/api-tests/dev_apis/protected_storage/test_p010/source.mk b/api-tests/dev_apis/protected_storage/test_p010/source.mk
new file mode 100644
index 0000000..aa23cf6
--- /dev/null
+++ b/api-tests/dev_apis/protected_storage/test_p010/source.mk
@@ -0,0 +1,20 @@
+# * Copyright (c) 2019, 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.
+#**/
+
+CC_SOURCE = test_entry.c test_p010.c
+CC_OPTIONS = -DPS_TEST
+AS_SOURCE =
+AS_OPTIONS =
diff --git a/api-tests/dev_apis/protected_storage/test_p010/test_entry.c b/api-tests/dev_apis/protected_storage/test_p010/test_entry.c
new file mode 100644
index 0000000..8883c5e
--- /dev/null
+++ b/api-tests/dev_apis/protected_storage/test_p010/test_entry.c
@@ -0,0 +1,53 @@
+/** @file
+ * Copyright (c) 2019, 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 "val_interfaces.h"
+#include "val_target.h"
+#include "test_p010.h"
+
+#define TEST_NUM VAL_CREATE_TEST_ID(VAL_PROTECTED_STORAGE_BASE, 10)
+#define TEST_DESC "Invalid Key error check\n"
+
+TEST_PUBLISH(TEST_NUM, test_entry);
+val_api_t *val = NULL;
+psa_api_t *psa = NULL;
+
+void test_entry(val_api_t *val_api, psa_api_t *psa_api)
+{
+ int32_t status = VAL_STATUS_SUCCESS;
+
+ val = val_api;
+ psa = psa_api;
+
+ /* test init */
+ val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT));
+ if (!IS_TEST_START(val->get_status()))
+ {
+ goto test_exit;
+ }
+
+ /* Execute list of tests available in test[num]_protected_storage_list from Non-secure side*/
+ status = val->execute_non_secure_tests(TEST_NUM, test_p010_sst_list, FALSE);
+
+ if (VAL_ERROR(status))
+ {
+ goto test_exit;
+ }
+
+test_exit:
+ val->test_exit();
+}
diff --git a/api-tests/dev_apis/protected_storage/test_p010/test_p010.c b/api-tests/dev_apis/protected_storage/test_p010/test_p010.c
new file mode 100644
index 0000000..c54d222
--- /dev/null
+++ b/api-tests/dev_apis/protected_storage/test_p010/test_p010.c
@@ -0,0 +1,122 @@
+/** @file
+ * Copyright (c) 2019, 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 "val_interfaces.h"
+#include "val_target.h"
+#include "test_p010.h"
+#include "test_ps_data.h"
+
+#define TEST_BUFF_SIZE 16
+
+client_test_t test_p010_sst_list[] = {
+ NULL,
+ psa_sst_optional_api_key_not_found,
+ NULL,
+};
+
+static uint8_t write_buff[TEST_BUFF_SIZE] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
+static uint8_t read_buff[TEST_BUFF_SIZE] = {0};
+
+static int32_t psa_sst_invalid_key()
+{
+ uint32_t status,j;
+ psa_ps_uid_t p_uid = UID_BASE_VALUE + 10;
+ struct psa_ps_info_t orig_info;
+
+ /* Call the set_extended API with uid which is not created */
+ val->print(PRINT_TEST, "[Check 1] Set_extended api call for UID %d which is not set\n", p_uid);
+ status = SST_FUNCTION(p010_data[1].api, p_uid, 0, TEST_BUFF_SIZE, write_buff);
+ TEST_ASSERT_EQUAL(status, p010_data[1].status, TEST_CHECKPOINT_NUM(1));
+
+ /* Create a valid storage with set api */
+ status = SST_FUNCTION(p010_data[2].api, p_uid, TEST_BUFF_SIZE, write_buff, 0);
+ TEST_ASSERT_EQUAL(status, p010_data[2].status, TEST_CHECKPOINT_NUM(2));
+
+ /* Try to change data length for same uid using create api */
+ val->print(PRINT_TEST, "[Check 2] Call create api with different data length than used to"
+ " create the asset using set api\n", 0);
+ status = SST_FUNCTION(p010_data[3].api, p_uid, TEST_BUFF_SIZE/2, 0);
+ TEST_ASSERT_EQUAL(status, p010_data[3].status, TEST_CHECKPOINT_NUM(3));
+
+ /* Try to change flag value associated with the uid */
+ val->print(PRINT_TEST, "[Check 3] Call create api with different flag value than used to"
+ " create the asset using set api\n", 0);
+ status = SST_FUNCTION(p010_data[4].api, p_uid, TEST_BUFF_SIZE, PSA_PS_FLAG_WRITE_ONCE);
+ TEST_ASSERT_EQUAL(status, p010_data[4].status, TEST_CHECKPOINT_NUM(4));
+
+ /* Check the flag value should be same as original*/
+ status = SST_FUNCTION(p010_data[5].api, p_uid, &orig_info);
+ TEST_ASSERT_EQUAL(status, p010_data[5].status, TEST_CHECKPOINT_NUM(5));
+ TEST_ASSERT_EQUAL(orig_info.size, TEST_BUFF_SIZE, TEST_CHECKPOINT_NUM(6));
+ TEST_ASSERT_EQUAL(orig_info.flags, 0, TEST_CHECKPOINT_NUM(7));
+
+ /* Remove the uid */
+ status = SST_FUNCTION(p010_data[8].api, p_uid);
+ TEST_ASSERT_EQUAL(status, p010_data[8].status, TEST_CHECKPOINT_NUM(8));
+
+ /* Create a valid storage */
+ status = SST_FUNCTION(p010_data[9].api, p_uid, TEST_BUFF_SIZE/2, 0);
+ TEST_ASSERT_EQUAL(status, p010_data[9].status, TEST_CHECKPOINT_NUM(9));
+
+ /* Try to change length using create api */
+ val->print(PRINT_TEST, "[Check 4] Call create api with different parameters than used to"
+ " create the asset using create api\n", 0);
+ status = SST_FUNCTION(p010_data[10].api, p_uid, TEST_BUFF_SIZE, 0);
+ TEST_ASSERT_EQUAL(status, p010_data[10].status, TEST_CHECKPOINT_NUM(10));
+
+ /* Check the storage should be empty */
+ status = SST_FUNCTION(p010_data[11].api, p_uid, 0, TEST_BUFF_SIZE, read_buff);
+ TEST_ASSERT_EQUAL(status, p010_data[11].status, TEST_CHECKPOINT_NUM(11));
+ for (j = 0; j < TEST_BUFF_SIZE; j++)
+ {
+ TEST_ASSERT_EQUAL(read_buff[j], 0, TEST_CHECKPOINT_NUM(12));
+ }
+
+ /* Remove the uid */
+ status = SST_FUNCTION(p010_data[13].api, p_uid);
+ TEST_ASSERT_EQUAL(status, p010_data[13].api, TEST_CHECKPOINT_NUM(13));
+
+ /* Call the set_extended API with uid which is removed */
+ val->print(PRINT_TEST, "[Check 5] Set_extended api call for UID %d which is removed\n", p_uid);
+ status = SST_FUNCTION(p010_data[14].api, p_uid, 0, TEST_BUFF_SIZE, write_buff);
+ TEST_ASSERT_EQUAL(status, p010_data[14].status, TEST_CHECKPOINT_NUM(14));
+
+ return VAL_STATUS_SUCCESS;
+}
+
+int32_t psa_sst_optional_api_key_not_found(security_t caller)
+{
+ uint32_t status;
+
+ /* Call the get_support api and check if create and set_extended api are supported */
+ status = SST_FUNCTION(p010_data[0].api);
+
+ if (status == p010_data[0].status)
+ {
+ val->print(PRINT_INFO, "Optional PS APIs are supported.\n", 0);
+ psa_sst_invalid_key();
+ }
+ else
+ {
+ val->print(PRINT_TEST, "Test Case not needed as Optional PS APIs are not supported.\n", 0);
+ return RESULT_SKIP(VAL_STATUS_UNSUPPORTED);
+ }
+
+ return VAL_STATUS_SUCCESS;
+}
+
diff --git a/api-tests/dev_apis/protected_storage/test_p010/test_p010.h b/api-tests/dev_apis/protected_storage/test_p010/test_p010.h
new file mode 100644
index 0000000..8455142
--- /dev/null
+++ b/api-tests/dev_apis/protected_storage/test_p010/test_p010.h
@@ -0,0 +1,29 @@
+/** @file
+ * Copyright (c) 2019, 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.
+**/
+#ifndef _TEST_P010_CLIENT_TESTS_H_
+#define _TEST_P010_CLIENT_TESTS_H_
+
+#define test_entry CONCAT(test_entry_, p010)
+#define val CONCAT(val,test_entry)
+#define psa CONCAT(psa,test_entry)
+
+extern val_api_t *val;
+extern psa_api_t *psa;
+extern client_test_t test_p010_sst_list[];
+
+int32_t psa_sst_optional_api_key_not_found(security_t caller);
+#endif /* _TEST_P010_CLIENT_TESTS_H_ */
diff --git a/api-tests/dev_apis/protected_storage/test_p010/test_ps_data.h b/api-tests/dev_apis/protected_storage/test_p010/test_ps_data.h
new file mode 100644
index 0000000..f8d385b
--- /dev/null
+++ b/api-tests/dev_apis/protected_storage/test_p010/test_ps_data.h
@@ -0,0 +1,77 @@
+/** @file
+ * Copyright (c) 2019, Arm Limited or ps 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.
+**/
+#ifndef _TEST_P010_PS_DATA_TESTS_H_
+#define _TEST_P010_PS_DATA_TESTS_H_
+
+#include "val_protected_storage.h"
+
+#define SST_FUNCTION val->ps_function
+
+typedef struct {
+ char test_desc[100];
+ enum ps_function_code api;
+ psa_ps_status_t status;
+} test_data;
+
+static test_data p010_data[] = {
+{
+ "Check if optional PS api supported", VAL_PS_GET_SUPPORT, PSA_PS_SUPPORT_SET_EXTENDED
+},
+{
+ "Set_extended call for non-existing uid", VAL_PS_SET_EXTENDED, PSA_PS_ERROR_INVALID_KEY
+},
+{
+ "Create valid storage using set api", VAL_PS_SET, PSA_PS_SUCCESS
+},
+{
+ "Call create api for existing uid with different length", VAL_PS_CREATE, PSA_PS_ERROR_INVALID_KEY
+},
+{
+ "Call create api for to set WRITE_ONCE flag", VAL_PS_CREATE, PSA_PS_ERROR_INVALID_KEY
+},
+{
+ "Validate existing uid attributes maintained", VAL_PS_GET_INFO, PSA_PS_SUCCESS
+},
+{
+ "This is dummy for index6", 0, 0
+},
+{
+ "This is dummy for index7", 0, 0
+},
+{
+ "Remove the uid", VAL_PS_REMOVE, PSA_PS_SUCCESS
+},
+{
+ "Create valid storage using create api", VAL_PS_CREATE, PSA_PS_SUCCESS
+},
+{
+ "Again call create api with different length", VAL_PS_CREATE, PSA_PS_ERROR_INVALID_KEY
+},
+{
+ "Validate the storage is empty", VAL_PS_GET, PSA_PS_SUCCESS
+},
+{
+ "This is dummy for index12", 0, 0
+},
+{
+ "Remove the uid", VAL_PS_REMOVE, PSA_PS_SUCCESS
+},
+{
+ "Set_extended call for removed uid", VAL_PS_SET_EXTENDED, PSA_PS_ERROR_INVALID_KEY
+}
+};
+#endif /* _TEST_P010_PS_DATA_TESTS_H_ */
diff --git a/api-tests/dev_apis/protected_storage/test_p011/source.mk b/api-tests/dev_apis/protected_storage/test_p011/source.mk
new file mode 100644
index 0000000..16b6a86
--- /dev/null
+++ b/api-tests/dev_apis/protected_storage/test_p011/source.mk
@@ -0,0 +1,20 @@
+# * Copyright (c) 2019, 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.
+#**/
+
+CC_SOURCE = test_entry.c test_p011.c
+CC_OPTIONS =
+AS_SOURCE =
+AS_OPTIONS =
diff --git a/api-tests/dev_apis/protected_storage/test_p011/test_entry.c b/api-tests/dev_apis/protected_storage/test_p011/test_entry.c
new file mode 100644
index 0000000..c4c713f
--- /dev/null
+++ b/api-tests/dev_apis/protected_storage/test_p011/test_entry.c
@@ -0,0 +1,53 @@
+/** @file
+ * Copyright (c) 2019, 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 "val_interfaces.h"
+#include "val_target.h"
+#include "test_p011.h"
+
+#define TEST_NUM VAL_CREATE_TEST_ID(VAL_PROTECTED_STORAGE_BASE, 11)
+#define TEST_DESC "Set_Extended api : Bad pointer and offset invalid check\n"
+
+TEST_PUBLISH(TEST_NUM, test_entry);
+val_api_t *val = NULL;
+psa_api_t *psa = NULL;
+
+void test_entry(val_api_t *val_api, psa_api_t *psa_api)
+{
+ int32_t status = VAL_STATUS_SUCCESS;
+
+ val = val_api;
+ psa = psa_api;
+
+ /* test init */
+ val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT));
+ if (!IS_TEST_START(val->get_status()))
+ {
+ goto test_exit;
+ }
+
+ /* Execute list of tests available in test[num]_protected_storage_list from Non-secure side*/
+ status = val->execute_non_secure_tests(TEST_NUM, test_p011_sst_list, FALSE);
+
+ if (VAL_ERROR(status))
+ {
+ goto test_exit;
+ }
+
+test_exit:
+ val->test_exit();
+}
diff --git a/api-tests/dev_apis/protected_storage/test_p011/test_p011.c b/api-tests/dev_apis/protected_storage/test_p011/test_p011.c
new file mode 100644
index 0000000..4e36b9c
--- /dev/null
+++ b/api-tests/dev_apis/protected_storage/test_p011/test_p011.c
@@ -0,0 +1,133 @@
+/** @file
+ * Copyright (c) 2019, 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 "val_interfaces.h"
+#include "val_target.h"
+#include "test_p011.h"
+#include "test_ps_data.h"
+
+#define TEST_BUFF_SIZE 16
+
+client_test_t test_p011_sst_list[] = {
+ NULL,
+ psa_sst_optional_api_offset_invalid,
+ NULL,
+};
+
+static psa_ps_uid_t p_uid = UID_BASE_VALUE + 11;
+static uint8_t write_buff[TEST_BUFF_SIZE] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
+static uint8_t read_buff[TEST_BUFF_SIZE] = {0};
+static uint8_t write_buff_2[TEST_BUFF_SIZE] = {0xFF, 0xC1, 0xA2, 0xE3, 0x04, 0x05, 0x06, 0x07,
+ 0x03, 0x09, 0x0A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F};
+
+int32_t psa_sst_offset_invalid()
+{
+ uint32_t status;
+
+ /* Create valid storage using create api */
+ status = SST_FUNCTION(p011_data[1].api, p_uid, TEST_BUFF_SIZE, 0);
+ TEST_ASSERT_EQUAL(status, p011_data[1].status, TEST_CHECKPOINT_NUM(1));
+
+ /* Set some data in the storage created */
+ status = SST_FUNCTION(p011_data[2].api, p_uid, TEST_BUFF_SIZE/2, 5, write_buff);
+ TEST_ASSERT_EQUAL(status, p011_data[2].status, TEST_CHECKPOINT_NUM(2));
+
+ /* Try to set data at invalid location with incorrect data len + offset */
+ val->print(PRINT_TEST, "[Check 1] Set_extended api call with invalid offset + length\n", 0);
+ status = SST_FUNCTION(p011_data[3].api, p_uid, TEST_BUFF_SIZE, 2, write_buff);
+ TEST_ASSERT_EQUAL(status, p011_data[3].status, TEST_CHECKPOINT_NUM(3));
+
+ /* Try to set data at invalid location with incorrect offset */
+ val->print(PRINT_TEST, "[Check 2] Set_extended api call with invalid offset\n", 0);
+ status = SST_FUNCTION(p011_data[4].api, p_uid, TEST_BUFF_SIZE + 2, 0, write_buff);
+ TEST_ASSERT_EQUAL(status, p011_data[4].status, TEST_CHECKPOINT_NUM(4));
+
+ /* Try to set data at correct offset, but zero data len */
+ val->print(PRINT_TEST, "[Check 3] Set_extended api call with offset equals length\n", 0);
+ status = SST_FUNCTION(p011_data[5].api, p_uid, TEST_BUFF_SIZE, 0, write_buff);
+ TEST_ASSERT_EQUAL(status, p011_data[5].status, TEST_CHECKPOINT_NUM(5));
+
+ /* Try to set data at invalid location with incorrect data len + offset */
+ val->print(PRINT_TEST, "[Check 4] Set_extended api call with invalid offset + length\n", 0);
+ status = SST_FUNCTION(p011_data[6].api, p_uid, 1, TEST_BUFF_SIZE, write_buff);
+ TEST_ASSERT_EQUAL(status, p011_data[6].status, TEST_CHECKPOINT_NUM(6));
+
+ /* Try to set data at invalid location with incorrect data len */
+ val->print(PRINT_TEST, "[Check 5] Set_extended api call with invalid length\n", 0);
+ status = SST_FUNCTION(p011_data[7].api, p_uid, 0, TEST_BUFF_SIZE + 1, write_buff);
+ TEST_ASSERT_EQUAL(status, p011_data[7].status, TEST_CHECKPOINT_NUM(7));
+
+ /* Set data using set api */
+ val->print(PRINT_TEST, "[Check 6] Overwrite the whole data with set api\n", 0);
+ status = SST_FUNCTION(p011_data[8].api, p_uid, TEST_BUFF_SIZE, write_buff, 0);
+ TEST_ASSERT_EQUAL(status, p011_data[8].status, TEST_CHECKPOINT_NUM(8));
+
+ /* Call the GET function to check data is correctly overwritten */
+ status = SST_FUNCTION(p011_data[9].api, p_uid, 0, TEST_BUFF_SIZE, read_buff);
+ TEST_ASSERT_EQUAL(status, p011_data[9].status, TEST_CHECKPOINT_NUM(9));
+ TEST_ASSERT_MEMCMP(read_buff, write_buff, TEST_BUFF_SIZE, TEST_CHECKPOINT_NUM(10));
+
+ return VAL_STATUS_SUCCESS;
+}
+
+static int32_t psa_sst_bad_pointer()
+{
+ uint32_t status;
+
+ /* Call set extended with NULL write_buff */
+ val->print(PRINT_TEST, "[Check 7] Call set_extended with NULL write buffer\n", 0);
+ status = SST_FUNCTION(p011_data[11].api, p_uid, 0, TEST_BUFF_SIZE, NULL);
+ TEST_ASSERT_EQUAL(status, p011_data[11].status, TEST_CHECKPOINT_NUM(11));
+
+ /* Call set extended to overwrite data with new values */
+ status = SST_FUNCTION(p011_data[12].api, p_uid, 0, TEST_BUFF_SIZE, write_buff_2);
+ TEST_ASSERT_EQUAL(status, p011_data[12].status, TEST_CHECKPOINT_NUM(12));
+
+ /* Call the GET function to get the data buffer and match the buffer */
+ status = SST_FUNCTION(p011_data[13].api, p_uid, 0, TEST_BUFF_SIZE, read_buff);
+ TEST_ASSERT_EQUAL(status, p011_data[13].status, TEST_CHECKPOINT_NUM(13));
+ TEST_ASSERT_MEMCMP(read_buff, write_buff_2, TEST_BUFF_SIZE, TEST_CHECKPOINT_NUM(14));
+
+ /* Remove the storage */
+ status = SST_FUNCTION(p011_data[15].api, p_uid);
+ TEST_ASSERT_EQUAL(status, p011_data[15].status, TEST_CHECKPOINT_NUM(15));
+
+ return VAL_STATUS_SUCCESS;
+}
+
+int32_t psa_sst_optional_api_offset_invalid(security_t caller)
+{
+ uint32_t status;
+
+ /* Call the get_support api and check if create and set_extended api are supported */
+ status = SST_FUNCTION(p011_data[0].api);
+
+ if (status == p011_data[0].status)
+ {
+ val->print(PRINT_INFO, "Optional PS APIs are supported.\n", 0);
+ psa_sst_offset_invalid();
+ psa_sst_bad_pointer();
+ }
+ else
+ {
+ val->print(PRINT_TEST, "Test Case not needed as Optional PS APIs are not supported.\n", 0);
+ return RESULT_SKIP(VAL_STATUS_UNSUPPORTED);
+ }
+
+ return VAL_STATUS_SUCCESS;
+}
diff --git a/api-tests/dev_apis/protected_storage/test_p011/test_p011.h b/api-tests/dev_apis/protected_storage/test_p011/test_p011.h
new file mode 100644
index 0000000..8d09c07
--- /dev/null
+++ b/api-tests/dev_apis/protected_storage/test_p011/test_p011.h
@@ -0,0 +1,29 @@
+/** @file
+ * Copyright (c) 2019, 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.
+**/
+#ifndef _TEST_P011_CLIENT_TESTS_H_
+#define _TEST_P011_CLIENT_TESTS_H_
+
+#define test_entry CONCAT(test_entry_, p011)
+#define val CONCAT(val,test_entry)
+#define psa CONCAT(psa,test_entry)
+
+extern val_api_t *val;
+extern psa_api_t *psa;
+extern client_test_t test_p011_sst_list[];
+
+int32_t psa_sst_optional_api_offset_invalid(security_t caller);
+#endif /* _TEST_P011_CLIENT_TESTS_H_ */
diff --git a/api-tests/dev_apis/protected_storage/test_p011/test_ps_data.h b/api-tests/dev_apis/protected_storage/test_p011/test_ps_data.h
new file mode 100644
index 0000000..594b766
--- /dev/null
+++ b/api-tests/dev_apis/protected_storage/test_p011/test_ps_data.h
@@ -0,0 +1,80 @@
+/** @file
+ * Copyright (c) 2019, Arm Limited or ps 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.
+**/
+#ifndef _TEST_P011_PS_DATA_TESTS_H_
+#define _TEST_P011_PS_DATA_TESTS_H_
+
+#include "val_protected_storage.h"
+
+#define SST_FUNCTION val->ps_function
+
+typedef struct {
+ char test_desc[100];
+ enum ps_function_code api;
+ psa_ps_status_t status;
+} test_data;
+
+static test_data p011_data[] = {
+{
+ "Check if optional PS api supported", VAL_PS_GET_SUPPORT, PSA_PS_SUPPORT_SET_EXTENDED
+},
+{
+ "Create valid storage", VAL_PS_CREATE, PSA_PS_SUCCESS
+},
+{
+ "Set data using set_extended api", VAL_PS_SET_EXTENDED, PSA_PS_SUCCESS
+},
+{
+ "Set_extended call with invalid offset + length", VAL_PS_SET_EXTENDED, PSA_PS_ERROR_OFFSET_INVALID
+},
+{
+ "Set_extended call with invalid offset", VAL_PS_SET_EXTENDED, PSA_PS_ERROR_OFFSET_INVALID
+},
+{
+ "Set_extended call with valid offset and zero length", VAL_PS_SET_EXTENDED, PSA_PS_SUCCESS
+},
+{
+ "Set_extended call with invalid offset + length", VAL_PS_SET_EXTENDED, PSA_PS_ERROR_OFFSET_INVALID
+},
+{
+ "Set_extended call with invalid length", VAL_PS_SET_EXTENDED, PSA_PS_ERROR_OFFSET_INVALID
+},
+{
+ "Write data using set api", VAL_PS_SET, PSA_PS_SUCCESS
+},
+{
+ "Check data validity using get api", VAL_PS_GET, PSA_PS_SUCCESS
+},
+{
+ "This is dummy for index10", 0, 0
+},
+{
+ "Set_extended call with NULL write buffer", VAL_PS_SET_EXTENDED, PSA_PS_ERROR_BAD_POINTER
+},
+{
+ "Overwrite data using set_extended", VAL_PS_SET_EXTENDED, PSA_PS_SUCCESS
+},
+{
+ "Check data validity using get api", VAL_PS_GET, PSA_PS_SUCCESS
+},
+{
+ "This is dummy for index14", 0, 0
+},
+{
+ "Remove the uid", VAL_PS_REMOVE, PSA_PS_SUCCESS
+},
+};
+#endif /* _TEST_P011_PS_DATA_TESTS_H_ */
diff --git a/api-tests/dev_apis/protected_storage/test_p012/source.mk b/api-tests/dev_apis/protected_storage/test_p012/source.mk
new file mode 100644
index 0000000..2035409
--- /dev/null
+++ b/api-tests/dev_apis/protected_storage/test_p012/source.mk
@@ -0,0 +1,20 @@
+# * Copyright (c) 2019, 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.
+#**/
+
+CC_SOURCE = test_entry.c test_p012.c
+CC_OPTIONS =
+AS_SOURCE =
+AS_OPTIONS =
diff --git a/api-tests/dev_apis/protected_storage/test_p012/test_entry.c b/api-tests/dev_apis/protected_storage/test_p012/test_entry.c
new file mode 100644
index 0000000..e7bf507
--- /dev/null
+++ b/api-tests/dev_apis/protected_storage/test_p012/test_entry.c
@@ -0,0 +1,53 @@
+/** @file
+ * Copyright (c) 2019, 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 "val_interfaces.h"
+#include "val_target.h"
+#include "test_p012.h"
+
+#define TEST_NUM VAL_CREATE_TEST_ID(VAL_PROTECTED_STORAGE_BASE, 12)
+#define TEST_DESC "Set_Extended and Create api : Success\n"
+
+TEST_PUBLISH(TEST_NUM, test_entry);
+val_api_t *val = NULL;
+psa_api_t *psa = NULL;
+
+void test_entry(val_api_t *val_api, psa_api_t *psa_api)
+{
+ int32_t status = VAL_STATUS_SUCCESS;
+
+ val = val_api;
+ psa = psa_api;
+
+ /* test init */
+ val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT));
+ if (!IS_TEST_START(val->get_status()))
+ {
+ goto test_exit;
+ }
+
+ /* Execute list of tests available in test[num]_protected_storage_list from Non-secure side*/
+ status = val->execute_non_secure_tests(TEST_NUM, test_p012_sst_list, FALSE);
+
+ if (VAL_ERROR(status))
+ {
+ goto test_exit;
+ }
+
+test_exit:
+ val->test_exit();
+}
diff --git a/api-tests/dev_apis/protected_storage/test_p012/test_p012.c b/api-tests/dev_apis/protected_storage/test_p012/test_p012.c
new file mode 100644
index 0000000..48d7256
--- /dev/null
+++ b/api-tests/dev_apis/protected_storage/test_p012/test_p012.c
@@ -0,0 +1,139 @@
+/** @file
+ * Copyright (c) 2019, 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 "val_interfaces.h"
+#include "val_target.h"
+#include "test_p012.h"
+#include "test_ps_data.h"
+
+#define TEST_BUFF_SIZE 16
+
+client_test_t test_p012_sst_list[] = {
+ NULL,
+ psa_sst_optional_api_success_check,
+ NULL,
+};
+
+static psa_ps_uid_t p_uid = UID_BASE_VALUE + 11;
+static uint8_t write_buff[TEST_BUFF_SIZE/2] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
+static uint8_t write_buff_2[TEST_BUFF_SIZE/2] = {0xFF, 0x11, 0xA2, 0xE3, 0x04, 0xA5, 0xD6, 0x97};
+static uint8_t read_buff[TEST_BUFF_SIZE] = {0};
+static uint8_t write_buff_3[TEST_BUFF_SIZE] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
+
+static int32_t psa_sst_set_extended_create_success()
+{
+ uint32_t status;
+ struct psa_ps_info_t info;
+
+ /* Create storage of zero length using create api */
+ val->print(PRINT_TEST, "[Check 1] Create storage using create api for 0 length\n", 0);
+ status = SST_FUNCTION(p012_data[1].api, p_uid, 0, 0);
+ TEST_ASSERT_EQUAL(status, p012_data[1].status, TEST_CHECKPOINT_NUM(1));
+
+ /* Set some data in the storage created */
+ val->print(PRINT_TEST, "[Check 2] Call set_extended for zero storage length\n", 0);
+ status = SST_FUNCTION(p012_data[2].api, p_uid, 0, 0, write_buff);
+ TEST_ASSERT_EQUAL(status, p012_data[2].status, TEST_CHECKPOINT_NUM(2));
+
+ /* Call the GET_INFO function to match attributes */
+ status = SST_FUNCTION(p012_data[3].api, p_uid, &info);
+ TEST_ASSERT_EQUAL(status, p012_data[3].status, TEST_CHECKPOINT_NUM(3));
+ TEST_ASSERT_EQUAL(info.flags, 0, TEST_CHECKPOINT_NUM(4));
+ TEST_ASSERT_EQUAL(info.size, 0, TEST_CHECKPOINT_NUM(5));
+
+ /* Remove the storage */
+ val->print(PRINT_TEST, "[Check 3] Remove the storage\n", 0);
+ status = SST_FUNCTION(p012_data[6].api, p_uid);
+ TEST_ASSERT_EQUAL(status, p012_data[6].status, TEST_CHECKPOINT_NUM(6));
+
+ /* Create a valid storage */
+ status = SST_FUNCTION(p012_data[7].api, p_uid, TEST_BUFF_SIZE, 0);
+ TEST_ASSERT_EQUAL(status, p012_data[7].status, TEST_CHECKPOINT_NUM(7));
+
+ /* Try to set data in first half of buffer */
+ status = SST_FUNCTION(p012_data[8].api, p_uid, 0, TEST_BUFF_SIZE/2, write_buff);
+ TEST_ASSERT_EQUAL(status, p012_data[8].status, TEST_CHECKPOINT_NUM(8));
+
+ /* Try to set data in second half of buffer */
+ status = SST_FUNCTION(p012_data[9].api, p_uid, TEST_BUFF_SIZE/2, TEST_BUFF_SIZE/2,\
+ write_buff_2);
+ TEST_ASSERT_EQUAL(status, p012_data[9].status, TEST_CHECKPOINT_NUM(9));
+
+ /* Call the GET function to match the data */
+ val->print(PRINT_TEST, "[Check 4] Valid data written by multiple set_extended\n", 0);
+ status = SST_FUNCTION(p012_data[10].api, p_uid, 0, TEST_BUFF_SIZE, read_buff);
+ TEST_ASSERT_EQUAL(status, p012_data[10].status, TEST_CHECKPOINT_NUM(10));
+ TEST_ASSERT_MEMCMP(read_buff, write_buff, TEST_BUFF_SIZE/2, TEST_CHECKPOINT_NUM(11));
+ TEST_ASSERT_MEMCMP(read_buff + TEST_BUFF_SIZE/2, write_buff_2, TEST_BUFF_SIZE/2,\
+ TEST_CHECKPOINT_NUM(12));
+
+ /* Overwrite data using set api */
+ val->print(PRINT_TEST, "[Check 5] Overwrite whole data using set api\n", 0);
+ status = SST_FUNCTION(p012_data[13].api, p_uid, TEST_BUFF_SIZE, write_buff_3, 0);
+ TEST_ASSERT_EQUAL(status, p012_data[13].status, TEST_CHECKPOINT_NUM(13));
+
+ /* Call the GET function to match the data */
+ val->print(PRINT_TEST, "[Check 6] Validate the data using get api\n", 0);
+ status = SST_FUNCTION(p012_data[14].api, p_uid, 0, TEST_BUFF_SIZE, read_buff);
+ TEST_ASSERT_EQUAL(status, p012_data[14].status, TEST_CHECKPOINT_NUM(14));
+ TEST_ASSERT_MEMCMP(read_buff, write_buff_3, TEST_BUFF_SIZE, TEST_CHECKPOINT_NUM(15));
+
+ /* Call create api for existing uid with same parameters */
+ val->print(PRINT_TEST, "[Check 7] Call create api for existing uid with same parameters\n", 0);
+ status = SST_FUNCTION(p012_data[16].api, p_uid, TEST_BUFF_SIZE, 0);
+ TEST_ASSERT_EQUAL(status, p012_data[16].status, TEST_CHECKPOINT_NUM(16));
+
+ /* Call the GET function to match the data */
+ val->print(PRINT_TEST, "[Check 8] validity of data after create api call\n", 0);
+ status = SST_FUNCTION(p012_data[17].api, p_uid, 0, TEST_BUFF_SIZE, read_buff);
+ TEST_ASSERT_EQUAL(status, p012_data[17].status, TEST_CHECKPOINT_NUM(17));
+ TEST_ASSERT_MEMCMP(read_buff, write_buff_3, TEST_BUFF_SIZE, TEST_CHECKPOINT_NUM(18));
+
+ /* Remove the storage */
+ val->print(PRINT_TEST, "[Check 9] Remove the uid\n", 0);
+ status = SST_FUNCTION(p012_data[19].api, p_uid);
+ TEST_ASSERT_EQUAL(status, p012_data[19].status, TEST_CHECKPOINT_NUM(19));
+
+ /* Validate there should not be duplicate uid present */
+ val->print(PRINT_TEST, "[Check 10] No duplicate entry of uid present\n", 0);
+ status = SST_FUNCTION(p012_data[20].api, p_uid, 0, TEST_BUFF_SIZE, read_buff);
+ TEST_ASSERT_EQUAL(status, p012_data[20].status, TEST_CHECKPOINT_NUM(20));
+
+ return VAL_STATUS_SUCCESS;
+}
+
+int32_t psa_sst_optional_api_success_check(security_t caller)
+{
+ uint32_t status;
+
+ /* Call the get_support api and check if create and set_extended api are supported */
+ status = SST_FUNCTION(p012_data[0].api);
+
+ if (status == p012_data[0].status)
+ {
+ val->print(PRINT_INFO, "Optional PS APIs are supported.\n", 0);
+ psa_sst_set_extended_create_success();
+ }
+ else
+ {
+ val->print(PRINT_TEST, "Test Case not needed as Optional PS APIs are not supported.\n", 0);
+ return RESULT_SKIP(VAL_STATUS_UNSUPPORTED);
+ }
+
+ return VAL_STATUS_SUCCESS;
+}
diff --git a/api-tests/dev_apis/protected_storage/test_p012/test_p012.h b/api-tests/dev_apis/protected_storage/test_p012/test_p012.h
new file mode 100644
index 0000000..b2aeae7
--- /dev/null
+++ b/api-tests/dev_apis/protected_storage/test_p012/test_p012.h
@@ -0,0 +1,30 @@
+/** @file
+ * Copyright (c) 2019, 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.
+**/
+#ifndef _TEST_P012_CLIENT_TESTS_H_
+#define _TEST_P012_CLIENT_TESTS_H_
+
+#define test_entry CONCAT(test_entry_, p012)
+#define val CONCAT(val,test_entry)
+#define psa CONCAT(psa,test_entry)
+
+extern val_api_t *val;
+extern psa_api_t *psa;
+extern client_test_t test_p012_sst_list[];
+
+int32_t psa_sst_optional_api_success_check(security_t caller);
+
+#endif /* _TEST_P012_CLIENT_TESTS_H_ */
diff --git a/api-tests/dev_apis/protected_storage/test_p012/test_ps_data.h b/api-tests/dev_apis/protected_storage/test_p012/test_ps_data.h
new file mode 100644
index 0000000..a9c79a2
--- /dev/null
+++ b/api-tests/dev_apis/protected_storage/test_p012/test_ps_data.h
@@ -0,0 +1,95 @@
+/** @file
+ * Copyright (c) 2019, Arm Limited or ps 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.
+**/
+#ifndef _TEST_P012_PS_DATA_TESTS_H_
+#define _TEST_P012_PS_DATA_TESTS_H_
+
+#include "val_protected_storage.h"
+
+#define SST_FUNCTION val->ps_function
+
+typedef struct {
+ char test_desc[100];
+ enum ps_function_code api;
+ psa_ps_status_t status;
+} test_data;
+
+static test_data p012_data[] = {
+{
+ "Check if optional PS api supported", VAL_PS_GET_SUPPORT, PSA_PS_SUPPORT_SET_EXTENDED
+},
+{
+ "Create storage of zero length", VAL_PS_CREATE, PSA_PS_SUCCESS
+},
+{
+ "Call set_extened with zero length", VAL_PS_SET_EXTENDED, PSA_PS_SUCCESS
+},
+{
+ "Validate the storage attributes", VAL_PS_GET_INFO, PSA_PS_SUCCESS
+},
+{
+ "This is dummy for index4", 0, 0
+},
+{
+ "This is dummy for index5", 0, 0
+},
+{
+ "Remove the uid", VAL_PS_REMOVE, PSA_PS_SUCCESS
+},
+{
+ "Create storage of non-zero length", VAL_PS_CREATE, PSA_PS_SUCCESS
+},
+{
+ "Call set_extened to write data in first half of buffer", VAL_PS_SET_EXTENDED, PSA_PS_SUCCESS
+},
+{
+ "Call set_extened to write data in second half of buffer", VAL_PS_SET_EXTENDED, PSA_PS_SUCCESS
+},
+{
+ "Validate the data stored", VAL_PS_GET, PSA_PS_SUCCESS
+},
+{
+ "This is dummy for index11", 0, 0
+},
+{
+ "This is dummy for index12", 0, 0
+},
+{
+ "Overwrite data with set api", VAL_PS_SET, PSA_PS_SUCCESS
+},
+{
+ "Validate the data written", VAL_PS_GET, PSA_PS_SUCCESS
+},
+{
+ "This is dummy for index15", 0, 0
+},
+{
+ "Call Create api for existing uid with same parameters ", VAL_PS_CREATE, PSA_PS_SUCCESS
+},
+{
+ "Validate the data", VAL_PS_GET, PSA_PS_SUCCESS
+},
+{
+ "This is dummy for index18", 0, 0
+},
+{
+ "Remove the uid", VAL_PS_REMOVE, PSA_PS_SUCCESS
+},
+{
+ "Check no duplicate entry of uid present", VAL_PS_GET, PSA_PS_ERROR_UID_NOT_FOUND
+}
+};
+#endif /* _TEST_P012_PS_DATA_TESTS_H_ */
diff --git a/api-tests/dev_apis/protected_storage/testsuite.db b/api-tests/dev_apis/protected_storage/testsuite.db
index 186fb04..841cdf7 100644
--- a/api-tests/dev_apis/protected_storage/testsuite.db
+++ b/api-tests/dev_apis/protected_storage/testsuite.db
@@ -29,5 +29,8 @@
test_s007
test_s008
test_s009
+test_p010
+test_p011
+test_p012
(END)
diff --git a/api-tests/docs/psa_its_testlist.md b/api-tests/docs/psa_its_testlist.md
index a10c3a5..2b47d5c 100644
--- a/api-tests/docs/psa_its_testlist.md
+++ b/api-tests/docs/psa_its_testlist.md
@@ -1,18 +1,25 @@
# PSA Internal Trusted Storage Testcase checklist
+## Requirements for Storage Test Suite
+
+Following are the requirements of the Storage Test Suite. <br />
+
+1. Unless described in this document, any behaviour that is defined as IMPLEMENTATION_DEFINED in PSA Storage API document is not verified in this document. <br />
+2. Storage Test Cases use UID value starting from 10 onwards. These UID needs to be free for successfull test execution.<br />
+
| Test | Return Value | API Verified | Test Algorithm | UID Usage |
|-----------|--------------------------------------|------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| test_s001 | PSA_ITS_ERROR_KEY_NOT_FOUND | psa_its_get<br />psa_its_get_info <br />psa_its_remove<br /> | 1. Call get API with UID for which no UID/Data pair is created<br />2. Call get_info API for which no UID/Data pair is created<br />3. Call remove API for which no UID/Data pair is created<br />4. Set valid UID/Data pair with uid1<br />5. Set one more set of UID/Data pair, with different uid, than previous<br />6. Remove the uid of step 4.<br />7. Call get API for removed UID/data pair<br />8. Call get_info API for removed UID/Data pair<br />9. Call remove API for removed UID/Data pair<br />10. Set valid UID/Data pair<br />11. Call get API for different uid , then created<br />12. Call get_info API for different uid, then created<br />13. Call remove API for different uid, then created<br />14. Remove the created UID/Data pair.<br />15. remove the stray uid.<br /> | UID value used are 10,11 |
+| test_s001 | PSA_ITS_ERROR_KEY_NOT_FOUND | psa_its_get<br />psa_its_get_info <br />psa_its_remove<br /> | 1. Call get API with UID for which no UID/Data pair is created<br />2. Call get_info API for which no UID/Data pair is created<br />3. Call remove API for which no UID/Data pair is created<br />4. Set valid UID/Data pair with uid1<br />5. Set one more set of UID/Data pair, with different uid, than previous<br />6. Remove the uid of step 4.<br />7. Call get API for removed UID/data pair<br />8. Call get_info API for removed UID/Data pair<br />9. Call remove API for removed UID/Data pair<br />10. Set valid UID/Data pair<br />11. Call get API for different uid , then created<br />12. Call get_info API for different uid, then created<br />13. Call remove API for different uid, then created<br />14. Remove the created UID/Data pair.<br />15. Remove the stray uid.<br /> | UID value used are 10,11 |
| test_s002 | PSA_ITS_ERROR_WRITE_ONCE | psa_its_set<br />psa_its_remove<br /> | 1. Set valid UID/data value pair , with create flag value none.2. Call get and get_info API to validate the data, attributes associated with data<br />3. Call set API again with same uid and create flag PSA_PS_WRITE_ONCE_FLAG<br />4. Call get and get_info API to validate the data, attributes associated with data is not changed after second set operation<br />5. try to remove the UID/data pair.<br />6. Create new UID/data value pair, with create flag PSA_PS_WRITE_ONCE_FLAG<br />7. Try to remove the created UID.<br />8. Call get and get_info API to validate the data, attributes associated with data<br />9. Again call SET with same UID , create flag PSA_PS_WRITE_ONCE_FLAG but different data length<br />10. Try to remove the UID, PSA_ITS_ERROR_WRITE_ONCE error should be returned<br />11. Call get and get_info API to validate the data, attributes associated with data<br /> | UID value used are 14 and 15 |
-| test_s003 | PSA_ITS_ERROR_INSUFFICIENT_SPACE | psa_its_set<br /> | 1. Create UID/data pairs, with data_len 256 bytes. Do this with incrementing uid values till we have INSUFFICENT_SPACE.<br />2. Remove all the UID/data pairs created.<br />3. repeat the steps 5 times, to check same number of uid <br /> | UID value starts from 1 and keep on incrementing till all space is exhausted |
+| test_s003 | PSA_ITS_ERROR_INSUFFICIENT_SPACE | psa_its_set<br /> | 1. Create UID/data pairs, with data_len 256 bytes. Do this with incrementing uid values till we have INSUFFICENT_SPACE.<br />2. Remove all the UID/data pairs created.<br />3. Repeat the steps 5 times, to check same number of uid <br /> | UID value starts from 20 and keep on incrementing till all space is exhausted |
| test_s004 | PSA_ITS_SUCCESS | psa_its_set<br />psa_its_get<br />psa_its_get_info<br />psa_its_remove<br /> | 1. Set a valid uid/data pair<br />2. Validate the data using get api<br />3. Change the data length to half of previous.<br />4. Call GET api with original data length , error should be returned and also the return buffer should be empty<br />5. Call GET api with correct data_len and validate the data received.<br />6. Check old data cannot be accessed.<br />7. Call REMOVE api to delete the UID/data pair<br /> | UID value used is 11 |
-| test_s005 | PSA_ITS_SUCCESS | psa_its_set<br />psa_its_get<br />psa_its_get_info<br />psa_its_remove<br /> | 1. Set valid UID/data pair with varying uid and data_len <br />2. Call GET api and validate the set data<br />3. Call GET info api and validate the data attributes<br />4. Call REMOVE api to delete the UID/data pair<br /> | UID value used are 0 and 10 |
-| test_s006 | PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED | psa_its_set<br /> | 1. Call the SET_INFO with minimum flag value to max flag value <br />2. Call GET_INFO api and validae the flag value<br />3. remove the uid/data pair<br /> | UID value used is 10 |
-| test_s007 | PSA_ITS_ERROR_FLAGS_SET_AFTER_CREATE | psa_its_set<br /> | 1. Create valid uid/data pair with non-zero value. <br />2. Again call the set api for same uid to change flag to some different non-zero value.<br />3. Try to set flag to now CREATE_FLAG_VALUE_NONE.<br />4. remove the uid.<br />5. Create a new UID/data pair with zero create flag.<br />6. try to change the flag value to non-zero.<br />7. remove the uid<br /> | UID value used is 10 |
+| test_s005 | PSA_ITS_SUCCESS | psa_its_set<br />psa_its_get<br />psa_its_get_info<br />psa_its_remove<br /> | 1. Set valid UID/data pair with varying uid and data_len <br />2. Call GET api and validate the set data<br />3. Call GET info api and validate the data attributes<br />4. Call REMOVE api to delete the UID/data pair<br /> | UID value used are 1 and 10 |
+| test_s006 | PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED | psa_its_set<br /> | 1. Call the SET_INFO with minimum flag value to max flag value <br />2. Call GET_INFO api and validate the flag value<br />3. Remove the uid/data pair<br /> | UID value used is 10 |
+| test_s007 | PSA_ITS_ERROR_INCORRECT_SIZE | psa_its_set<br /> | 1. Create valid uid/data pair. <br />2. Increase the length of storage.<br />3. Try to access the old length using get api.<br />4. Try to access with valid length less than stored size.<br />5. Decrease the length of storage.<br />6. Try to access the old length.<br />7. Remove the uid<br /> | UID value used is 10 |
| test_s008 | PSA_ITS_ERROR_OFFSET_INVALID | psa_its_get<br /> | 1. Set valid UID/data pair<br />2. Call GET api with valid offset and offset + data_len equal to stored data size.<br />3. Call GET api with valid offset and offset + data_len less than stored data size.<br />4. Call get api with invalid offset.<br />5. Call get api with zero offset , but data len greater than data size.<br />6. Remove the uid.<br /> | UID value used is 11 |
-| test_s009 | PSA_ITS_ERROR_BAD_POINTER | psa_its_get<br />psa_its_set<br />psa_its_get_info<br /> | 1. Call the SET API with NULL pointer and data_len zero <br />2. Validate using get_info api storage should not be present.<br />3. Set storage entity with valid write_buffer , but length zero.<br />4. Again try to set for same uid with NULL write_buffer.<br />5. Call get and get_info api with NULL pointer and valid uid.<br />6. remove the uid<br /> | UID value used is 11 <br /> |
+| test_s009 | PSA_ITS_ERROR_BAD_POINTER | psa_its_get<br />psa_its_set<br />psa_its_get_info<br /> | 1. Call the SET API with NULL pointer and data_len zero <br />2. Validate using get_info api storage should not be present.<br />3. Set storage entity with valid write_buffer , but length zero.<br />4. Again try to set for same uid with NULL write_buffer.<br />5. Call get and get_info api with NULL pointer and valid uid.<br />6. Remove the uid<br /> | UID value used is 11 <br /> |
## License
diff --git a/api-tests/docs/psa_ps_testlist.md b/api-tests/docs/psa_ps_testlist.md
index 89f6981..d84d9a0 100644
--- a/api-tests/docs/psa_ps_testlist.md
+++ b/api-tests/docs/psa_ps_testlist.md
@@ -1,19 +1,27 @@
# PSA Protected Storage Testcase checklist
+## Requirements for Storage Test Suite
+
+Following are the requirements of the Storage Test Suite. <br />
+
+1. Unless described in this document, any behaviour that is defined as IMPLEMENTATION_DEFINED in PSA Storage API document is not verified in this document.<br />
+2. Storage Test Cases use UID value starting from 10 onwards. These UID needs to be free for successfull test execution.<br />
| Test | Return Value | API Verified | Test Algorithm | UID Usage |
|-----------|--------------------------------------|------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| test_s001 | PSA_PS_ERROR_KEY_NOT_FOUND | psa_ps_get<br />psa_ps_get_info <br />psa_ps_remove<br /> | 1. Call get API with UID for which no UID/Data pair is created<br />2. Call get_info API for which no UID/Data pair is created<br />3. Call remove API for which no UID/Data pair is created<br />4. Set valid UID/Data pair with uid1<br />5. Set one more set of UID/Data pair, with different uid, than previous<br />6. Remove the uid of step 4.<br />7. Call get API for removed UID/data pair<br />8. Call get_info API for removed UID/Data pair<br />9. Call remove API for removed UID/Data pair<br />10. Set valid UID/Data pair<br />11. Call get API for different uid , then created<br />12. Call get_info API for different uid, then created<br />13. Call remove API for different uid, then created<br />14. Remove the created UID/Data pair.<br />15. remove the stray uid.<br /> | UID value used are 10,11,9 |
-| test_s002 | PSA_PS_ERROR_WRITE_ONCE | psa_ps_set<br />psa_ps_remove<br /> | 1. Set valid UID/data value pair , with create flag value none.2. Call get and get_info API to validate the data, attributes associated with data<br />3. Call set API again with same uid and create flag PSA_PS_WRITE_ONCE_FLAG<br />4. Call get and get_info API to validate the data, attributes associated with data is not changed after second set operation<br />5. try to remove the UID/data pair.<br />6. Create new UID/data value pair, with create flag PSA_PS_WRITE_ONCE_FLAG<br />7. Try to remove the created UID.<br />8. Call get and get_info API to validate the data, attributes associated with data<br />9. Again call SET with same UID , create flag PSA_PS_WRITE_ONCE_FLAG but different data length<br />10. Try to remove the UID, PSA_PS_ERROR_WRITE_ONCE error should be returned<br />11. Call get and get_info API to validate the data, attributes associated with data<br /> | UID value used are 20 and 21 |
-| test_s003 | PSA_PS_ERROR_INSUFFICIENT_SPACE | psa_ps_set<br /> | 1. Create UID/data pairs, with data_len 256 bytes. Do this with incrementing uid values till we have INSUFFICENT_SPACE.<br />2. Remove all the UID/data pairs created.<br />3. repeat the steps 5 times, to check same number of uid <br /> | UID value starts from 1 and keep on incrementing till all space is exhausted |
+| test_s001 | PSA_PS_ERROR_UID_NOT_FOUND | psa_ps_get<br />psa_ps_get_info <br />psa_ps_remove<br /> | 1. Call get API with UID for which no UID/Data pair is created<br />2. Call get_info API for which no UID/Data pair is created<br />3. Call remove API for which no UID/Data pair is created<br />4. Set valid UID/Data pair with uid1<br />5. Set one more set of UID/Data pair, with different uid, than previous<br />6. Remove the uid of step 4.<br />7. Call get API for removed UID/data pair<br />8. Call get_info API for removed UID/Data pair<br />9. Call remove API for removed UID/Data pair<br />10. Set valid UID/Data pair<br />11. Call get API for different uid , then created<br />12. Call get_info API for different uid, then created<br />13. Call remove API for different uid, then created<br />14. Remove the created UID/Data pair.<br />15. Remove the stray uid.<br /> | UID value used are 10,11 |
+| test_s002 | PSA_PS_ERROR_WRITE_ONCE | psa_ps_set<br />psa_ps_remove<br /> | 1. Set valid UID/data value pair , with create flag value none.2. Call get and get_info API to validate the data, attributes associated with data<br />3. Call set API again with same uid and create flag PSA_PS_WRITE_ONCE_FLAG<br />4. Call get and get_info API to validate the data, attributes associated with data is not changed after second set operation<br />5. Try to remove the UID/data pair.<br />6. Create new UID/data value pair, with create flag PSA_PS_WRITE_ONCE_FLAG<br />7. Try to remove the created UID.<br />8. Call get and get_info API to validate the data, attributes associated with data<br />9. Again call SET with same UID , create flag PSA_PS_WRITE_ONCE_FLAG but different data length<br />10. Try to remove the UID, PSA_PS_ERROR_WRITE_ONCE error should be returned<br />11. Call get and get_info API to validate the data, attributes associated with data<br /> | UID value used are 20 and 21 |
+| test_s003 | PSA_PS_ERROR_INSUFFICIENT_SPACE | psa_ps_set<br /> | 1. Create UID/data pairs, with data_len 256 bytes. Do this with incrementing uid values till we have INSUFFICENT_SPACE.<br />2. Remove all the UID/data pairs created.<br />3. Repeat the steps 5 times, to check same number of uid <br /> | UID value starts from 20 and keep on incrementing till all space is exhausted |
| test_s004 | PSA_PS_SUCCESS | psa_ps_set<br />psa_ps_get<br />psa_ps_get_info<br />psa_ps_remove<br /> | 1. Set a valid uid/data pair<br />2. Validate the data using get api<br />3. Change the data length to half of previous.<br />4. Call GET api with original data length , error should be returned and also the return buffer should be empty<br />5. Call GET api with correct data_len and validate the data received.<br />6. Check old data cannot be accessed.<br />7. Call REMOVE api to delete the UID/data pair<br /> | UID value used is 11 |
-| test_s005 | PSA_PS_SUCCESS | psa_ps_set<br />psa_ps_get<br />psa_ps_get_info<br />psa_ps_remove<br /> | 1. Set valid UID/data pair with varying uid and data_len <br />2. Call GET api and validate the set data<br />3. Call GET info api and validate the data attributes<br />4. Call REMOVE api to delete the UID/data pair<br /> | UID value used are 0 and 10 |
-| test_s006 | PSA_PS_ERROR_FLAGS_NOT_SUPPORTED | psa_ps_set<br /> | 1. Call the SET_INFO with minimum flag value to max flag value <br />2. Call GET_INFO api and validae the flag value<br />3. remove the uid/data pair<br /> | UID value used is 10 |
-| test_s007 | PSA_PS_ERROR_FLAGS_SET_AFTER_CREATE | psa_ps_set<br /> | 1. Create valid uid/data pair with non-zero value. <br />2. Again call the set api for same uid to change flag to some different non-zero value.<br />3. Try to set flag to now CREATE_FLAG_VALUE_NONE.<br />4. remove the uid.<br />5. Create a new UID/data pair with zero create flag.<br />6. try to change the flag value to non-zero.<br />7. remove the uid<br /> | UID value used is 10 |
+| test_s005 | PSA_PS_SUCCESS | psa_ps_set<br />psa_ps_get<br />psa_ps_get_info<br />psa_ps_remove<br /> | 1. Set valid UID/data pair with varying uid and data_len <br />2. Call GET api and validate the set data<br />3. Call GET info api and validate the data attributes<br />4. Call REMOVE api to delete the UID/data pair<br /> | UID value used are 1 and 10 |
+| test_s006 | PSA_PS_ERROR_FLAGS_NOT_SUPPORTED | psa_ps_set<br /> | 1. Call the SET_INFO with minimum flag value to max flag value <br />2. Call GET_INFO api and validae the flag value<br />3. Remove the uid/data pair<br /> | UID value used is 10 |
+| test_s007 | PSA_PS_ERROR_INCORRECT_SIZE | psa_ps_set<br /> | 1. Create valid uid/data pair. <br />2. Increase the length of storage.<br />3. Try to access the old length using get api.<br />4. Try to access with valid length less than stored size.<br />5. Decrease the length of storage.<br />6. Try to access the old length.<br />7. Remove the uid<br /> | UID value used is 10 |
| test_s008 | PSA_PS_ERROR_OFFSET_INVALID | psa_ps_get<br /> | 1. Set valid UID/data pair<br />2. Call GET api with valid offset and offset + data_len equal to stored data size.<br />3. Call GET api with valid offset and offset + data_len less than stored data size.<br />4. Call get api with invalid offset.<br />5. Call get api with zero offset , but data len greater than data size.<br />6. Remove the uid.<br /> | UID value used is 11 |
-| test_s009 | PSA_PS_ERROR_BAD_POINTER | psa_ps_get<br />psa_ps_set<br />psa_ps_get_info<br /> | 1. Call the SET API with NULL pointer and data_len zero <br />2. Validate using get_info api storage should not be present.<br />3. Set storage entity with valid write_buffer , but length zero.<br />4. Again try to set for same uid with NULL write_buffer.<br />5. Call get and get_info api with NULL pointer and valid uid.<br />6. remove the uid<br /> | UID value used is 11 <br /> |
-
+| test_s009 | PSA_PS_ERROR_INVALID_ARGUMENT | psa_ps_get<br />psa_ps_set<br />psa_ps_get_info<br /> | 1. Call the SET API with NULL pointer and data_len zero <br />2. Validate using get_info api storage should not be present.<br />3. Set storage entity with valid write_buffer , but length zero.<br />4. Again try to set for same uid with NULL write_buffer.<br />5. Call get and get_info api with NULL pointer and valid uid.<br />6. Remove the uid<br /> | UID value used is 11 <br /> |
+| test_p010 | PSA_PS_ERROR_INVALID_KEY | psa_ps_create<br />psa_ps_set_extended<br /> | 1. Call the SET Extended API when no uid present <br />2. Create a valid storage using set. <br /> 3. Call create api with different length for existing uid.<br \> 4. Call create api to set WRITE_ONCE flag. <br \> 5. Validate data attributes are maintained.<br />6. Remove the uid. <br /> 7. Create valid storage using create api. <br /> 8. Try to change length using create api. <br \> 9. Validate storage is empty. <br /> 10. Again call create api with original parameters. <br />11. Remove the uid. <br \> 12. Check no duplicate entry present. <br /> | UID value used is 10 <br /> |
+| test_p011 | PSA_PS_ERROR_INVALID_ARGUMENT <br /> PSA_PS_ERROR_OFFSET_INVALID <br /> | psa_ps_create<br />psa_ps_set_extended<br /> | 1. Create a valid storage using set. <br /> 2. Set data on first half of buffer.<br /> 3. Try to set data at incorrect offset +length. <br /> 4. Try to set data at incorrect offset. <br />5. Try to set at correct offset but zero length buffer.<br />6. Try to set data at incorrect length and valid offset. <br /> 7. Overwrite the storage using set api. <br /> 8. Validate data is correctly written. <br \> 9. Call set_extended with NULL write buffer. <br /> 10. Overwrite storage using set_extended api. <br /> 11. Remove the uid. <br /> | UID value used is 11 <br />
+| test_s012 | PSA_PS_SUCCESS | psa_ps_set_extended<br /> | 1. Create Storage of zero length using create <br />2. Try to set some data in the storage created.<br />3. Validate the storage attributes<br /> 4. Remove the storage. <br /> 5. Create a valid storage with non-zero length. <br /> 6. Set data in the buffer. <br /> 7. Validate the data attributes. <br /> 8. Overwrite data using set api. <br /> 9. Validate the data. <br /> 10. Call create api for existing uid with same parameters. <br /> 11. Remove the uid. <br /> 12. Check with set_extended no duplicate uid exists. <br /> | UID value used is 11
## License
Arm PSA test suite is distributed under Apache v2.0 License.
diff --git a/api-tests/platform/targets/tgt_dev_apis_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.c b/api-tests/platform/targets/tgt_dev_apis_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.c
index 4f89efe..a424153 100644
--- a/api-tests/platform/targets/tgt_dev_apis_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.c
+++ b/api-tests/platform/targets/tgt_dev_apis_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.c
@@ -65,6 +65,8 @@
data_length = va_arg(valist, uint32_t);
p_write_data = va_arg(valist, const void*);
return psa_ps_set_extended(uid, offset, data_length, p_write_data);
+ case PAL_PS_GET_SUPPORT:
+ return psa_ps_get_support();
default:
return PAL_STATUS_UNSUPPORTED_FUNC;
}
diff --git a/api-tests/platform/targets/tgt_dev_apis_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.h b/api-tests/platform/targets/tgt_dev_apis_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.h
index 2f7e5fc..a338cdf 100644
--- a/api-tests/platform/targets/tgt_dev_apis_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.h
+++ b/api-tests/platform/targets/tgt_dev_apis_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.h
@@ -27,6 +27,7 @@
PAL_PS_REMOVE = 0x4,
PAL_PS_CREATE = 0x5,
PAL_PS_SET_EXTENDED = 0x6,
+ PAL_PS_GET_SUPPORT = 0x7,
};
uint32_t pal_ps_function(int type, va_list valist);
diff --git a/api-tests/platform/targets/tgt_dev_apis_tfm_musca_a/nspe/pal_protected_storage_intf.c b/api-tests/platform/targets/tgt_dev_apis_tfm_musca_a/nspe/pal_protected_storage_intf.c
index 4f89efe..a424153 100644
--- a/api-tests/platform/targets/tgt_dev_apis_tfm_musca_a/nspe/pal_protected_storage_intf.c
+++ b/api-tests/platform/targets/tgt_dev_apis_tfm_musca_a/nspe/pal_protected_storage_intf.c
@@ -65,6 +65,8 @@
data_length = va_arg(valist, uint32_t);
p_write_data = va_arg(valist, const void*);
return psa_ps_set_extended(uid, offset, data_length, p_write_data);
+ case PAL_PS_GET_SUPPORT:
+ return psa_ps_get_support();
default:
return PAL_STATUS_UNSUPPORTED_FUNC;
}
diff --git a/api-tests/platform/targets/tgt_dev_apis_tfm_musca_a/nspe/pal_protected_storage_intf.h b/api-tests/platform/targets/tgt_dev_apis_tfm_musca_a/nspe/pal_protected_storage_intf.h
index 2f7e5fc..a338cdf 100644
--- a/api-tests/platform/targets/tgt_dev_apis_tfm_musca_a/nspe/pal_protected_storage_intf.h
+++ b/api-tests/platform/targets/tgt_dev_apis_tfm_musca_a/nspe/pal_protected_storage_intf.h
@@ -27,6 +27,7 @@
PAL_PS_REMOVE = 0x4,
PAL_PS_CREATE = 0x5,
PAL_PS_SET_EXTENDED = 0x6,
+ PAL_PS_GET_SUPPORT = 0x7,
};
uint32_t pal_ps_function(int type, va_list valist);
diff --git a/api-tests/platform/targets/tgt_ff_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.c b/api-tests/platform/targets/tgt_ff_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.c
index 4f89efe..a424153 100644
--- a/api-tests/platform/targets/tgt_ff_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.c
+++ b/api-tests/platform/targets/tgt_ff_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.c
@@ -65,6 +65,8 @@
data_length = va_arg(valist, uint32_t);
p_write_data = va_arg(valist, const void*);
return psa_ps_set_extended(uid, offset, data_length, p_write_data);
+ case PAL_PS_GET_SUPPORT:
+ return psa_ps_get_support();
default:
return PAL_STATUS_UNSUPPORTED_FUNC;
}
diff --git a/api-tests/platform/targets/tgt_ff_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.h b/api-tests/platform/targets/tgt_ff_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.h
index 2f7e5fc..a338cdf 100644
--- a/api-tests/platform/targets/tgt_ff_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.h
+++ b/api-tests/platform/targets/tgt_ff_mbedos_fvp_mps2_m4/nspe/pal_protected_storage_intf.h
@@ -27,6 +27,7 @@
PAL_PS_REMOVE = 0x4,
PAL_PS_CREATE = 0x5,
PAL_PS_SET_EXTENDED = 0x6,
+ PAL_PS_GET_SUPPORT = 0x7,
};
uint32_t pal_ps_function(int type, va_list valist);
diff --git a/api-tests/val/common/val.h b/api-tests/val/common/val.h
index 3e9a9d7..b3dbcd5 100644
--- a/api-tests/val/common/val.h
+++ b/api-tests/val/common/val.h
@@ -223,6 +223,7 @@
VAL_STATUS_BOOT_EXPECTED_BUT_FAILED = 0x28,
VAL_STATUS_INIT_ALREADY_DONE = 0x29,
VAL_STATUS_HEAP_NOT_AVAILABLE = 0x2A,
+ VAL_STATUS_UNSUPPORTED = 0x2B,
VAL_STATUS_ERROR_MAX = INT_MAX,
} val_status_t;
diff --git a/api-tests/val/nspe/val_internal_trusted_storage.h b/api-tests/val/nspe/val_internal_trusted_storage.h
index e74a701..2f9384d 100644
--- a/api-tests/val/nspe/val_internal_trusted_storage.h
+++ b/api-tests/val/nspe/val_internal_trusted_storage.h
@@ -21,7 +21,6 @@
#include "val.h"
#define UID_BASE_VALUE 0
-#define UID_MAX_VALUE 15
#define BYTES_TO_BITS(byte) (byte * 8)
enum its_function_code {
diff --git a/api-tests/val/nspe/val_protected_storage.h b/api-tests/val/nspe/val_protected_storage.h
index 5d2df21..7f05cea 100644
--- a/api-tests/val/nspe/val_protected_storage.h
+++ b/api-tests/val/nspe/val_protected_storage.h
@@ -20,8 +20,7 @@
#include "val.h"
-#define UID_BASE_VALUE 0
-#define UID_MAX_VALUE 15
+#define UID_BASE_VALUE 0
#define BYTES_TO_BITS(byte) (byte * 8)
enum ps_function_code {
@@ -31,6 +30,7 @@
VAL_PS_REMOVE = 0x4,
VAL_PS_CREATE = 0x5,
VAL_PS_SET_EXTENDED = 0x6,
+ VAL_PS_GET_SUPPORT = 0x7,
};
uint32_t val_ps_function(int type, ...);