Merge pull request #135 from kotegowder/master
Fix: PSA Storage test_s006.c
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s006/test_entry_s006.c b/api-tests/dev_apis/internal_trusted_storage/test_s006/test_entry_s006.c
index dda491b..f3f2af3 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s006/test_entry_s006.c
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s006/test_entry_s006.c
@@ -20,7 +20,7 @@
#include "test_s006.h"
#define TEST_NUM VAL_CREATE_TEST_ID(VAL_STORAGE_BASE, 6)
-#define TEST_DESC "Flags not supported check\n"
+#define TEST_DESC "Check for storage create flags\n"
TEST_PUBLISH(TEST_NUM, test_entry);
val_api_t *val = NULL;
diff --git a/api-tests/dev_apis/internal_trusted_storage/test_s006/test_s006.c b/api-tests/dev_apis/internal_trusted_storage/test_s006/test_s006.c
index a45351a..2adc5d5 100755
--- a/api-tests/dev_apis/internal_trusted_storage/test_s006/test_s006.c
+++ b/api-tests/dev_apis/internal_trusted_storage/test_s006/test_s006.c
@@ -43,48 +43,81 @@
/* Call the get_info function and match the attributes */
status = SST_FUNCTION(s006_data[2].api, uid, &info);
- TEST_ASSERT_EQUAL(status, s006_data[2].status, TEST_CHECKPOINT_NUM(2));
- TEST_ASSERT_EQUAL(info.flags, create_flag, TEST_CHECKPOINT_NUM(3));
+ TEST_ASSERT_EQUAL(status, s006_data[2].status, TEST_CHECKPOINT_NUM(1));
+ if ((create_flag != PSA_STORAGE_FLAG_NO_CONFIDENTIALITY) ||
+ (create_flag != PSA_STORAGE_FLAG_NO_REPLAY_PROTECTION))
+ {
+ TEST_ASSERT_EQUAL(info.flags, create_flag, TEST_CHECKPOINT_NUM(2));
+ }
/* Remove the UID */
status = SST_FUNCTION(s006_data[4].api, uid);
- TEST_ASSERT_EQUAL(status, s006_data[4].status, TEST_CHECKPOINT_NUM(4));
+ TEST_ASSERT_EQUAL(status, s006_data[4].status, TEST_CHECKPOINT_NUM(3));
+
+ return VAL_STATUS_SUCCESS;
+}
+
+static int32_t psa_sst_create_storage_api(psa_storage_uid_t uid, uint32_t data_len,
+ uint8_t *data_buff, psa_storage_create_flags_t create_flag)
+{
+ uint32_t status;
+ int32_t test_status;
+
+ status = SST_FUNCTION(s006_data[1].api, uid, data_len, data_buff, create_flag);
+ if (status == s006_data[1].status)
+ {
+ test_status = psa_sst_remove_api(uid, data_len, data_buff, create_flag);
+ if (test_status != VAL_STATUS_SUCCESS)
+ {
+ return test_status;
+ }
+ } else if (status == s006_data[0].status)
+ {
+ /* Remove UID should fail */
+ status = SST_FUNCTION(s006_data[5].api, uid);
+ TEST_ASSERT_EQUAL(status, s006_data[5].status, TEST_CHECKPOINT_NUM(4));
+ }
return VAL_STATUS_SUCCESS;
}
int32_t psa_sst_flags_not_supported(caller_security_t caller)
{
- psa_storage_create_flags_t flag = 0x80000000;
- uint32_t status = VAL_STATUS_SUCCESS;
- psa_storage_uid_t uid = UID_BASE_VALUE + 5;
- int32_t test_status;
+ psa_storage_create_flags_t flag;
+ uint32_t status = VAL_STATUS_SUCCESS;
+ psa_storage_uid_t uid = UID_BASE_VALUE + 5;
+ int32_t test_status;
- /* Calling set function with different create flag value */
+ /* Calling set function with different create flag value */
- val->print(PRINT_TEST, "[Check 1] Call set API with valid flag values\n", 0);
- while (flag)
- {
- /* Create storage with flag value */
- status = SST_FUNCTION(s006_data[1].api, uid, TEST_BUFF_SIZE, write_buff,
- (flag & (~PSA_STORAGE_FLAG_WRITE_ONCE)));
+ val->print(PRINT_TEST, "[Check 1] Call set API with flag - PSA_STORAGE_FLAG_NONE\n", 0);
+ /* Create storage with flag value */
+ flag = PSA_STORAGE_FLAG_NONE;
+ test_status = psa_sst_create_storage_api(uid, TEST_BUFF_SIZE, write_buff, flag);
+ if (test_status != VAL_STATUS_SUCCESS)
+ {
+ return test_status;
+ }
- if (status == s006_data[1].status)
- {
- test_status = psa_sst_remove_api(uid, TEST_BUFF_SIZE, write_buff,
- (flag & (~PSA_STORAGE_FLAG_WRITE_ONCE)));
- if (test_status != VAL_STATUS_SUCCESS)
- return test_status;
- }
- else if (status == s006_data[0].status)
- {
- /* Remove UID should fail */
- status = SST_FUNCTION(s006_data[5].api, uid);
- TEST_ASSERT_EQUAL(status, s006_data[5].status, TEST_CHECKPOINT_NUM(5));
- }
+ val->print(PRINT_TEST, "[Check 2] Call set API with flag - "
+ "PSA_STORAGE_FLAG_NO_CONFIDENTIALITY\n", 0);
+ /* Create storage with flag value */
+ flag = PSA_STORAGE_FLAG_NO_CONFIDENTIALITY;
+ test_status = psa_sst_create_storage_api(uid, TEST_BUFF_SIZE, write_buff, flag);
+ if (test_status != VAL_STATUS_SUCCESS)
+ {
+ return test_status;
+ }
- flag = flag >> 1;
- };
+ val->print(PRINT_TEST, "[Check 3] Call set API with flag - "
+ "PSA_STORAGE_FLAG_NO_REPLAY_PROTECTION\n", 0);
+ /* Create storage with flag value */
+ flag = PSA_STORAGE_FLAG_NO_REPLAY_PROTECTION;
+ test_status = psa_sst_create_storage_api(uid, TEST_BUFF_SIZE, write_buff, flag);
+ if (test_status != VAL_STATUS_SUCCESS)
+ {
+ return test_status;
+ }
- return status;
+ return status;
}
diff --git a/api-tests/docs/psa_its_testlist.md b/api-tests/docs/psa_its_testlist.md
index 3443249..28aaead 100644
--- a/api-tests/docs/psa_its_testlist.md
+++ b/api-tests/docs/psa_its_testlist.md
@@ -15,7 +15,7 @@
| test_s003 | Exhaust storage space | psa_its_set<br /> | PSA_ERROR_INSUFFICIENT_STORAGE | 1. Create UID/data pairs, with data_len 1024 bytes. Do this with incrementing<br /> uid values till we have INSUFFICENT_SPACE.<br />2. Remove all the UID/data pairs created.<br />3. Repeat the steps once more, to check all previous uid are removed successfully<br /> | UID value starts from 5 and keep on incrementing till all space is exhausted |
| test_s004 | Overwriting data for asset created without WRITE_ONCE flag | psa_its_set<br />psa_its_get<br />psa_its_get_info<br />psa_its_remove<br /> | PSA_SUCCESS | 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<br /> 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 5 |
| test_s005 | Get, get_info and remove API call for valid assest | psa_its_set<br />psa_its_get<br />psa_its_get_info<br />psa_its_remove<br /> | PSA_SUCCESS | 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 4 |
-| test_s006 | Storage asset creation with unsupported <br /> create_flag value | psa_its_set<br /> | PSA_ERROR_NOT_SUPPORTED | 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 5 |
+| test_s006 | Storage asset creation with supported create flag values | psa_its_set<br /> | PSA_ERROR_NOT_SUPPORTED | 1. Call the SET API with available create flag values <br />2. Call GET_INFO api and validate the flag value<br />3. Remove the uid/data pair<br /> | UID value used is 5 |
| test_s007 | Get API call with length different than asset <br /> data length | psa_its_set<br /> | PSA_ERROR_INVALID_ARGUMENT | 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 5 |
| test_s008 | Get API call with invalid offset | psa_its_get<br /> | PSA_ERROR_INVALID_ARGUMENT | 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 5 |
| test_s009 | API call with NULL pointer and zero length | psa_its_get<br />psa_its_set<br />psa_its_get_info<br /> | PSA_ERROR_DOES_NOT_EXIST | 1. Call the SET API with NULL pointer and data_len zero <br />2. Validate using get_info api storage should be present.<br />3. Call get API with NULL pointer.<br />4. Remove the UID.<br />5. Call get_info API to validate storage is removed.<br />6. Set storage entity with valid write_buffer , but length zero.<br />7. Call get_info API to validate storage attributes.<br />8. Call get_info api with NULL pointer and valid uid.<br />9. Remove the uid<br /> | UID value used is 5 <br /> |
diff --git a/api-tests/docs/psa_ps_testlist.md b/api-tests/docs/psa_ps_testlist.md
index f93cfbd..e12989b 100644
--- a/api-tests/docs/psa_ps_testlist.md
+++ b/api-tests/docs/psa_ps_testlist.md
@@ -15,7 +15,7 @@
| test_s003 | Exhaust storage space | psa_its_set<br /> | PSA_ERROR_INSUFFICIENT_STORAGE | 1. Create UID/data pairs, with data_len 1024 bytes. Do this with incrementing<br /> uid values till we have INSUFFICENT_SPACE.<br />2. Remove all the UID/data pairs created.<br />3. Repeat the steps once more, to check all previous uid are removed successfully<br /> | UID value starts from 5 and keep on incrementing till all space is exhausted |
| test_s004 | Overwriting data for asset created without WRITE_ONCE flag | psa_its_set<br />psa_its_get<br />psa_its_get_info<br />psa_its_remove<br /> | PSA_SUCCESS | 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<br /> 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 5 |
| test_s005 | Get, get_info and remove API call for valid assest | psa_its_set<br />psa_its_get<br />psa_its_get_info<br />psa_its_remove<br /> | PSA_SUCCESS | 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 4 |
-| test_s006 | Storage asset creation with unsupported <br /> create_flag value | psa_its_set<br /> | PSA_ERROR_NOT_SUPPORTED | 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 5 |
+| test_s006 | Storage asset creation with supported create flag values | psa_its_set<br /> | PSA_ERROR_NOT_SUPPORTED | 1. Call the SET API with available create flag values <br />2. Call GET_INFO api and validate the flag value<br />3. Remove the uid/data pair<br /> | UID value used is 5 |
| test_s007 | Get API call with length different than asset <br /> data length | psa_its_set<br /> | PSA_ERROR_INVALID_ARGUMENT | 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 5 |
| test_s008 | Get API call with invalid offset | psa_its_get<br /> | PSA_ERROR_INVALID_ARGUMENT | 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 5 |
| test_s009 | API call with NULL pointer and zero length | psa_its_get<br />psa_its_set<br />psa_its_get_info<br /> | PSA_ERROR_DOES_NOT_EXIST | 1. Call the SET API with NULL pointer and data_len zero <br />2. Validate using get_info api storage should be present.<br />3. Call get API with NULL pointer.<br />4. Remove the UID.<br />5. Call get_info API to validate storage is removed.<br />6. Set storage entity with valid write_buffer , but length zero.<br />7. Call get_info API to validate storage attributes.<br />8. Call get_info api with NULL pointer and valid uid.<br />9. Remove the uid<br /> | UID value used is 5 <br /> |