Test: Update tests for no partial asset rw
- Change tests to use full rws if partial rws aren't part of the
test
- Change partial read test to check for failure if partial
rws are disabled
- Disable other tests that need a partial rw when partial rw is
disabled
Change-Id: I55c96e49a1c250a6a3ba59cf49cda46eab97d483
Signed-off-by: Ben Davis <ben.davis@arm.com>
diff --git a/secure_fw/services/secure_storage/assets/sst_asset_defs.c b/secure_fw/services/secure_storage/assets/sst_asset_defs.c
index 72f1b49..a2d143e 100644
--- a/secure_fw/services/secure_storage/assets/sst_asset_defs.c
+++ b/secure_fw/services/secure_storage/assets/sst_asset_defs.c
@@ -15,11 +15,6 @@
.perms_count = SST_ASSET_PERMS_COUNT_AES_KEY_128,
.perms_modes_start_idx = 0,
}, {
- .asset_uuid = SST_ASSET_ID_AES_KEY_192,
- .max_size = SST_ASSET_MAX_SIZE_AES_KEY_192,
- .perms_count = SST_ASSET_PERMS_COUNT_AES_KEY_192,
- .perms_modes_start_idx = 1,
-}, {
.asset_uuid = SST_ASSET_ID_AES_KEY_256,
.max_size = SST_ASSET_MAX_SIZE_AES_KEY_256,
.perms_count = SST_ASSET_PERMS_COUNT_AES_KEY_256,
@@ -45,12 +40,17 @@
.perms_count = SST_ASSET_PERMS_COUNT_X509_CERT_SMALL,
.perms_modes_start_idx = 6,
}, {
-/* The following assets are used by the SST testsuite */
.asset_uuid = SST_ASSET_ID_X509_CERT_LARGE,
.max_size = SST_ASSET_MAX_SIZE_X509_CERT_LARGE,
.perms_count = SST_ASSET_PERMS_COUNT_X509_CERT_LARGE,
.perms_modes_start_idx = 7,
}, {
+/* The following assets are used by the SST testsuite */
+ .asset_uuid = SST_ASSET_ID_AES_KEY_192,
+ .max_size = SST_ASSET_MAX_SIZE_AES_KEY_192,
+ .perms_count = SST_ASSET_PERMS_COUNT_AES_KEY_192,
+ .perms_modes_start_idx = 7,
+}, {
.asset_uuid = SST_ASSET_ID_SHA224_HASH,
.max_size = SST_ASSET_MAX_SIZE_SHA224_HASH,
.perms_count = SST_ASSET_PERMS_COUNT_SHA224_HASH,
diff --git a/secure_fw/services/secure_storage/assets/sst_asset_defs.h b/secure_fw/services/secure_storage/assets/sst_asset_defs.h
index 1e9268a..95a3515 100644
--- a/secure_fw/services/secure_storage/assets/sst_asset_defs.h
+++ b/secure_fw/services/secure_storage/assets/sst_asset_defs.h
@@ -38,7 +38,7 @@
#define SST_ASSET_MAX_SIZE_SHA384_HASH 48
#define SST_ASSET_PERMS_COUNT_AES_KEY_128 1
-#define SST_ASSET_PERMS_COUNT_AES_KEY_192 1
+#define SST_ASSET_PERMS_COUNT_AES_KEY_192 3
#define SST_ASSET_PERMS_COUNT_AES_KEY_256 1
#define SST_ASSET_PERMS_COUNT_RSA_KEY_1024 1
#define SST_ASSET_PERMS_COUNT_RSA_KEY_2048 1
diff --git a/test/suites/sst/CMakeLists.inc b/test/suites/sst/CMakeLists.inc
index 5ce5441..fdb3e65 100644
--- a/test/suites/sst/CMakeLists.inc
+++ b/test/suites/sst/CMakeLists.inc
@@ -43,6 +43,11 @@
list(APPEND ALL_SRC_C_NS "${SECURE_STORAGE_TEST_DIR}/non_secure/sst_ns_ref_access_testsuite.c")
endif()
+ if (SST_ENABLE_PARTIAL_ASSET_RW)
+ set_property(SOURCE ${ALL_SRC_C_S} APPEND PROPERTY COMPILE_DEFINITIONS SST_ENABLE_PARTIAL_ASSET_RW)
+ set_property(SOURCE ${ALL_SRC_C_NS} APPEND PROPERTY COMPILE_DEFINITIONS SST_ENABLE_PARTIAL_ASSET_RW)
+ endif()
+
#Setting include directories
embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE)
embedded_include_directories(PATH ${TFM_ROOT_DIR}/test/interface/include ABSOLUTE)
diff --git a/test/suites/sst/non_secure/ns_test_helpers.h b/test/suites/sst/non_secure/ns_test_helpers.h
index 0abdacd..3b70959 100644
--- a/test/suites/sst/non_secure/ns_test_helpers.h
+++ b/test/suites/sst/non_secure/ns_test_helpers.h
@@ -17,6 +17,27 @@
#define CONCAT_(x, y) x ## y
#define CONCAT(x, y) CONCAT_(x, y)
+
+/**
+ * Several tests use a buffer to read back data from an asset. This buffer is
+ * larger than the size of the asset data by PADDING_SIZE bytes. This allows
+ * us to ensure that the only the expected data is read back and that it is read
+ * back correctly.
+ *
+ * For example if the buffer and asset are as follows:
+ * Buffer - "XXXXXXXXXXXX", Asset data - "AAAA"
+ *
+ * Then a correct and successful read would give this result: "XXXXAAAAXXXX"
+ * (Assuming a PADDING_SIZE of 8)
+ */
+#define BUFFER_SIZE SST_ASSET_MAX_SIZE_AES_KEY_192
+#define PADDING_SIZE 8
+#define HALF_PADDING_SIZE 4
+
+#define BUFFER_PLUS_PADDING_SIZE (BUFFER_SIZE + PADDING_SIZE)
+#define BUFFER_PLUS_HALF_PADDING_SIZE (BUFFER_SIZE + HALF_PADDING_SIZE)
+
+
/**
* \brief Expands to the prototype of a test function.
*
diff --git a/test/suites/sst/non_secure/sst_ns_interface_testsuite.c b/test/suites/sst/non_secure/sst_ns_interface_testsuite.c
index 465ea1d..b56526a 100644
--- a/test/suites/sst/non_secure/sst_ns_interface_testsuite.c
+++ b/test/suites/sst/non_secure/sst_ns_interface_testsuite.c
@@ -19,7 +19,7 @@
#define INVALID_ASSET_ID 0xFFFF
#define INVALID_THREAD_NAME "Thread_INVALID"
-#define READ_BUF_SIZE 12UL
+#define READ_BUF_SIZE 14UL
#define WRITE_BUF_SIZE 5UL
/* Memory bounds to check */
@@ -34,13 +34,18 @@
#define WRITE_DATA_SHA224_2 "(ABCDEFGHIJKLMNOPQRSTUVWXYZ)"
#define BUF_SIZE_SHA224 (SST_ASSET_MAX_SIZE_SHA224_HASH + 1)
+/* Define used for bounds checking type tests */
+#define BUFFER_SIZE_PLUS_ONE (BUFFER_SIZE + 1)
+
/* Shared asset handles for multithreaded tests */
static uint32_t tfm_sst_test_1007_handle;
static uint32_t tfm_sst_test_1010_handle;
static uint32_t tfm_sst_test_1014_handle;
static uint32_t tfm_sst_test_1018_handle;
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
static uint32_t tfm_sst_test_1024_asset_1_handle;
static uint32_t tfm_sst_test_1024_asset_2_handle;
+#endif
/* Define test suite for asset manager tests */
/* List of tests */
@@ -65,14 +70,18 @@
static void tfm_sst_test_1019(struct test_result_t *ret);
static void tfm_sst_test_1020(struct test_result_t *ret);
static void tfm_sst_test_1021(struct test_result_t *ret);
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
static void tfm_sst_test_1022(struct test_result_t *ret);
static void tfm_sst_test_1023(struct test_result_t *ret);
static void tfm_sst_test_1024(struct test_result_t *ret);
+#endif
static void tfm_sst_test_1025(struct test_result_t *ret);
static void tfm_sst_test_1026(struct test_result_t *ret);
static void tfm_sst_test_1027(struct test_result_t *ret);
static void tfm_sst_test_1028(struct test_result_t *ret);
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
static void tfm_sst_test_1029(struct test_result_t *ret);
+#endif
static struct test_t asset_veeners_tests[] = {
{&tfm_sst_test_1001, "TFM_SST_TEST_1001",
@@ -117,12 +126,14 @@
"Write and partial reads", {0} },
{&tfm_sst_test_1021, "TFM_SST_TEST_1021",
"Write more data than asset max size", {0} },
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
{&tfm_sst_test_1022, "TFM_SST_TEST_1022",
"Append data to an asset", {0} },
{&tfm_sst_test_1023, "TFM_SST_TEST_1023",
"Append data to an asset until EOF", {0} },
{&tfm_sst_test_1024, "TFM_SST_TEST_1024",
"Write data to two assets alternately", {0} },
+#endif
{&tfm_sst_test_1025, "TFM_SST_TEST_1025",
"Access an illegal location: ROM", {0} },
{&tfm_sst_test_1026, "TFM_SST_TEST_1026",
@@ -131,8 +142,10 @@
"Access an illegal location: non-existant memory", {0} },
{&tfm_sst_test_1028, "TFM_SST_TEST_1028",
"Access an illegal location: secure memory", {0} },
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
{&tfm_sst_test_1029, "TFM_SST_TEST_1029",
"Write data to the middle of an existing asset", {0} },
+#endif
};
void register_testsuite_ns_sst_interface(struct test_suite_t *p_test_suite)
@@ -148,7 +161,7 @@
/**
* \note List of relations between thread name, app ID and permissions
*
- * Asset permissions: SST_ASSET_ID_X509_CERT_LARGE
+ * Asset permissions: SST_ASSET_ID_AES_KEY_192
*
* THREAD NAME | APP_ID | Permissions
* ------------|--------------------------------------
@@ -180,7 +193,7 @@
*/
TFM_SST_NS_TEST(1001, "Thread_C")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
uint32_t hdl;
@@ -226,7 +239,7 @@
*/
TFM_SST_NS_TEST(1002, INVALID_THREAD_NAME)
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
/* Calls create function with an invalid thread name */
@@ -247,7 +260,7 @@
*/
TFM_SST_NS_TEST(1003, "Thread_C")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
uint32_t hdl;
@@ -374,7 +387,7 @@
*/
TFM_SST_NS_TEST(1005, "Thread_C")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
uint32_t hdl;
@@ -416,7 +429,7 @@
*/
TFM_SST_NS_TEST(1006, "Thread_C")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
struct tfm_sst_attribs_t asset_attrs;
enum tfm_sst_err_t err;
uint32_t hdl;
@@ -450,7 +463,7 @@
return;
}
- if (asset_attrs.size_max != SST_ASSET_MAX_SIZE_X509_CERT_LARGE) {
+ if (asset_attrs.size_max != SST_ASSET_MAX_SIZE_AES_KEY_192) {
TEST_FAIL("Max size of the asset is incorrect");
return;
}
@@ -555,7 +568,7 @@
*/
TFM_SST_NS_TEST(1008, "Thread_C")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
uint32_t hdl;
@@ -598,7 +611,7 @@
*/
TFM_SST_NS_TEST(1009, "Thread_C")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
struct tfm_sst_attribs_t asset_attrs;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
@@ -668,7 +681,7 @@
*/
static void tfm_sst_test_1010_task_1(struct test_result_t *ret)
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
err = tfm_sst_create(asset_uuid);
@@ -747,7 +760,7 @@
*/
TFM_SST_NS_TEST(1011, "Thread_C")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
uint32_t hdl;
@@ -801,11 +814,11 @@
*/
TFM_SST_NS_TEST(1012, "Thread_C")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
uint32_t hdl;
- uint8_t wrt_data[WRITE_BUF_SIZE] = "DATA";
+ uint8_t wrt_data[SST_ASSET_MAX_SIZE_AES_KEY_192] = {0};
/* Creates asset to get a valid handle */
err = tfm_sst_create(asset_uuid);
@@ -823,8 +836,8 @@
/* Attempts to write beyond end of asset starting from a valid offset */
io_data.data = wrt_data;
- io_data.size = 2;
- io_data.offset = SST_ASSET_MAX_SIZE_X509_CERT_LARGE - 1;
+ io_data.size = BUFFER_PLUS_PADDING_SIZE;
+ io_data.offset = 0;
err = tfm_sst_write(hdl, &io_data);
if (err != TFM_SST_ERR_PARAM_ERROR) {
@@ -834,7 +847,7 @@
/* Attempts to write to an offset beyond the end of the asset */
io_data.size = 1;
- io_data.offset = SST_ASSET_MAX_SIZE_X509_CERT_LARGE;
+ io_data.offset = SST_ASSET_MAX_SIZE_AES_KEY_192;
err = tfm_sst_write(hdl, &io_data);
if (err != TFM_SST_ERR_PARAM_ERROR) {
@@ -859,12 +872,12 @@
*/
TFM_SST_NS_TEST(1013, "Thread_C")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
uint32_t hdl;
uint8_t wrt_data[WRITE_BUF_SIZE] = "DATA";
- uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXX";
+ uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXXXX";
/* Creates asset to get a valid handle */
err = tfm_sst_create(asset_uuid);
@@ -893,28 +906,29 @@
}
/* Sets data structure for read*/
- io_data.data = read_data+3;
+ io_data.data = read_data + HALF_PADDING_SIZE;
io_data.size = WRITE_BUF_SIZE;
io_data.offset = 0;
/* Read data from the asset */
err = tfm_sst_read(hdl, &io_data);
if (err != TFM_SST_ERR_SUCCESS) {
- TEST_FAIL("Read should works correctly");
+ TEST_FAIL("Read should work correctly");
return;
}
- if (memcmp(read_data, "XXX", 3) != 0) {
+ if (memcmp(read_data, "XXXX", HALF_PADDING_SIZE) != 0) {
TEST_FAIL("Read buffer contains illegal pre-data");
return;
}
- if (memcmp((read_data+3), wrt_data, WRITE_BUF_SIZE) != 0) {
+ if (memcmp((read_data+HALF_PADDING_SIZE), wrt_data, WRITE_BUF_SIZE) != 0) {
TEST_FAIL("Read buffer has read incorrect data");
return;
}
- if (memcmp((read_data+8), "XXX", 3) != 0) {
+ if (memcmp((read_data+(HALF_PADDING_SIZE+WRITE_BUF_SIZE)), "XXXX",
+ HALF_PADDING_SIZE) != 0) {
TEST_FAIL("Read buffer contains illegal post-data");
return;
}
@@ -942,7 +956,7 @@
*/
static void tfm_sst_test_1014_task_1(struct test_result_t *ret)
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
err = tfm_sst_create(asset_uuid);
@@ -967,7 +981,7 @@
{
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
- uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXX";
+ uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXXXX";
/* Sets data structure */
io_data.data = read_data;
@@ -1027,7 +1041,7 @@
*/
TFM_SST_NS_TEST(1015, "Thread_C")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
uint32_t hdl;
@@ -1080,13 +1094,13 @@
*/
TFM_SST_NS_TEST(1016, "Thread_C")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
struct tfm_sst_attribs_t asset_attrs;
uint32_t hdl;
uint8_t wrt_data[WRITE_BUF_SIZE] = "DATA";
- uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXX";
+ uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXXXX";
/* Creates asset to get a valid handle */
err = tfm_sst_create(asset_uuid);
@@ -1129,8 +1143,8 @@
/* Attempts to read beyond the current size starting from a valid offset */
io_data.data = read_data;
- io_data.size = 2;
- io_data.offset = asset_attrs.size_current - 1;
+ io_data.size = WRITE_BUF_SIZE + 1;
+ io_data.offset = 0;
err = tfm_sst_read(hdl, &io_data);
if (err != TFM_SST_ERR_PARAM_ERROR) {
@@ -1206,7 +1220,7 @@
*/
static void tfm_sst_test_1018_task_1(struct test_result_t *ret)
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
err = tfm_sst_create(asset_uuid);
@@ -1429,12 +1443,12 @@
*/
TFM_SST_NS_TEST(1020, "Thread_C")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
uint32_t hdl;
uint32_t i;
- uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXX";
+ uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXXXX";
uint8_t wrt_data[WRITE_BUF_SIZE] = "DATA";
/* Creates asset to get a valid handle */
@@ -1459,20 +1473,25 @@
/* Writes data in the asset */
err = tfm_sst_write(hdl, &io_data);
if (err != TFM_SST_ERR_SUCCESS) {
- TEST_FAIL("Write should works correctly");
+ TEST_FAIL("Write should work correctly");
return;
}
/* Sets data structure for read*/
- io_data.data = (read_data + 3);
+ io_data.data = (read_data + HALF_PADDING_SIZE);
io_data.size = 1;
io_data.offset = 0;
+
for (i = 0; i < WRITE_BUF_SIZE; i++) {
/* Read data from the asset */
err = tfm_sst_read(hdl, &io_data);
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
if (err != TFM_SST_ERR_SUCCESS) {
- TEST_FAIL("Read should works correctly");
+#else
+ if (io_data.offset != 0 && err != TFM_SST_ERR_PARAM_ERROR) {
+#endif
+ TEST_FAIL("Read did not behave correctly");
return;
}
@@ -1481,17 +1500,26 @@
io_data.offset++;
}
- if (memcmp(read_data, "XXX", 3) != 0) {
+
+ if (memcmp(read_data, "XXXX", HALF_PADDING_SIZE) != 0) {
TEST_FAIL("Read buffer contains illegal pre-data");
return;
}
- if (memcmp((read_data + 3), wrt_data, WRITE_BUF_SIZE) != 0) {
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
+ if (memcmp((read_data + HALF_PADDING_SIZE), wrt_data,
+ WRITE_BUF_SIZE) != 0) {
+#else
+ /* Read should fail if no partial asset rw except when offset 0 */
+ if (memcmp((read_data + HALF_PADDING_SIZE), "DXXXX",
+ WRITE_BUF_SIZE) != 0) {
+#endif
TEST_FAIL("Read buffer has read incorrect data");
return;
}
- if (memcmp((read_data + 8), "XXX", 3) != 0) {
+ if (memcmp((read_data + (HALF_PADDING_SIZE + WRITE_BUF_SIZE)), "XXXX",
+ HALF_PADDING_SIZE) != 0) {
TEST_FAIL("Read buffer contains illegal post-data");
return;
}
@@ -1508,7 +1536,7 @@
/**
* \brief Tests write function against a write call where data size is
- * bigger than the maximum assert size.
+ * bigger than the maximum asset size.
*/
TFM_SST_NS_TEST(1021, "Thread_B")
{
@@ -1554,6 +1582,7 @@
ret->val = TEST_PASSED;
}
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
/**
* \brief Tests write function against multiple writes.
*/
@@ -1563,7 +1592,7 @@
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
uint32_t hdl;
- uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXX";
+ uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXXXX";
uint8_t wrt_data[WRITE_BUF_SIZE+1] = "Hello";
uint8_t wrt_data2[WRITE_BUF_SIZE+1] = "World";
@@ -1617,7 +1646,7 @@
return;
}
- if (memcmp(read_data, "HelloWorldX", READ_BUF_SIZE) != 0) {
+ if (memcmp(read_data, "HelloWorldXXX", READ_BUF_SIZE) != 0) {
TEST_FAIL("Read buffer has read incorrect data");
return;
}
@@ -1728,7 +1757,7 @@
*/
static void tfm_sst_test_1024_task_1(struct test_result_t *ret)
{
- const uint16_t asset_uuid_1 = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid_1 = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
/* Creates asset 1 to get a valid handle */
@@ -1858,7 +1887,7 @@
{
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
- uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXX";
+ uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXXXX";
/* Sets data structure */
io_data.data = read_data;
@@ -1873,7 +1902,7 @@
return;
}
- if (memcmp(read_data, "HelloWorldX", READ_BUF_SIZE) != 0) {
+ if (memcmp(read_data, "HelloWorldXXX", READ_BUF_SIZE) != 0) {
TEST_FAIL("Read buffer has incorrect data");
return;
}
@@ -1885,7 +1914,7 @@
{
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
- uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXX";
+ uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXXXX";
/* Sets data structure */
io_data.data = read_data;
@@ -1899,7 +1928,7 @@
return;
}
- if (memcmp(read_data, "Hi12345XXXX", READ_BUF_SIZE) != 0) {
+ if (memcmp(read_data, "Hi12345XXXXXX", READ_BUF_SIZE) != 0) {
TEST_FAIL("Read buffer has incorrect data");
return;
}
@@ -1972,6 +2001,7 @@
tfm_sst_run_test("Thread_C", ret, tfm_sst_test_1024_task_9);
}
+#endif /* SST_ENABLE_PARTIAL_ASSET_RW */
/**
* \brief Tests read from and write to an illegal location: ROM.
@@ -2221,17 +2251,18 @@
ret->val = TEST_PASSED;
}
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
/**
* \brief Tests write data to the middle of an existing asset
*/
TFM_SST_NS_TEST(1029, "Thread_C")
{
struct tfm_sst_attribs_t asset_attrs;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
uint32_t hdl;
- uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXX";
+ uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXXXX";
uint8_t wrt_data_1[WRITE_BUF_SIZE] = "AAAA";
uint8_t wrt_data_2[2] = "B";
@@ -2297,7 +2328,7 @@
return;
}
- io_data.data = (read_data + 3);
+ io_data.data = (read_data + HALF_PADDING_SIZE);
io_data.size = (WRITE_BUF_SIZE - 1);
io_data.offset = 0;
@@ -2311,7 +2342,7 @@
/* Checks that the asset contains write_data_1 with the second character
* overwritten with write_data_2.
*/
- if (memcmp(read_data, "XXXABAAXXXX", READ_BUF_SIZE) != 0) {
+ if (memcmp(read_data, "XXXXABAAXXXXX", READ_BUF_SIZE) != 0) {
TEST_FAIL("Read buffer is incorrect");
return;
}
@@ -2330,3 +2361,4 @@
ret->val = TEST_PASSED;
}
+#endif /* SST_ENABLE_PARTIAL_ASSET_RW */
diff --git a/test/suites/sst/non_secure/sst_policy_testsuite.c b/test/suites/sst/non_secure/sst_policy_testsuite.c
index 617355b..936c0c7 100644
--- a/test/suites/sst/non_secure/sst_policy_testsuite.c
+++ b/test/suites/sst/non_secure/sst_policy_testsuite.c
@@ -29,7 +29,7 @@
/**
* \note List of relations between thread name, app ID and permissions.
*
- * Asset permissions: SST_ASSET_ID_X509_CERT_LARGE
+ * Asset permissions: SST_ASSET_ID_AES_KEY_192
*
* THREAD NAME | APP_ID | Permissions
* ------------|--------------------------------------
@@ -63,10 +63,10 @@
#define WRITE_DATA_C "CCCC"
/* Original contents of the read buffer */
-#define READ_DATA "XXXXXXXXXXX"
+#define READ_DATA "XXXXXXXXXXXXX"
/* Contents of the read buffer after reading back write_data */
-#define RESULT_DATA(write_data) ("XXX" write_data "\0XXX")
+#define RESULT_DATA(write_data) ("XXXX" write_data "\0XXXX")
/* Sizes of the read and write buffers */
#define WRITE_BUF_SIZE (sizeof(WRITE_DATA_A))
@@ -92,13 +92,13 @@
static struct test_t policy_tests[] = {
{ &tfm_sst_test_4001, "TFM_SST_TEST_4001",
- "Check policy for X509_CERT_LARGE from Thread_C", {0} },
+ "Check policy for AES_KEY_192 from Thread_C", {0} },
{ &tfm_sst_test_4002, "TFM_SST_TEST_4002",
- "Check policy for X509_CERT_LARGE from Thread_A", {0} },
+ "Check policy for AES_KEY_192 from Thread_A", {0} },
{ &tfm_sst_test_4003, "TFM_SST_TEST_4003",
- "Check policy for X509_CERT_LARGE from Thread_B", {0} },
+ "Check policy for AES_KEY_192 from Thread_B", {0} },
{ &tfm_sst_test_4004, "TFM_SST_TEST_4004",
- "Delete X509_CERT_LARGE from Thread_C", {0} },
+ "Delete AES_KEY_192 from Thread_C", {0} },
{ &tfm_sst_test_4005, "TFM_SST_TEST_4005",
"Check policy for SHA224_HASH from Thread_B", {0} },
{ &tfm_sst_test_4006, "TFM_SST_TEST_4006",
@@ -122,7 +122,7 @@
}
/**
- * \brief Tests policy for SST_ASSET_ID_X509_CERT_LARGE with the following
+ * \brief Tests policy for SST_ASSET_ID_AES_KEY_192 with the following
* permissions:
* THREAD NAME | APP_ID | Permissions
* ------------|--------------|-----------------------
@@ -130,7 +130,7 @@
*/
TFM_SST_NS_TEST(4001, "Thread_C")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
struct tfm_sst_attribs_t attribs;
struct tfm_sst_buf_t buf;
enum tfm_sst_err_t err;
@@ -165,7 +165,7 @@
}
/* Sets the tfm_sst_buf_t structure */
- buf.data = read_data + 3;
+ buf.data = read_data + HALF_PADDING_SIZE;
buf.size = WRITE_BUF_SIZE;
buf.offset = 0;
@@ -195,7 +195,7 @@
return;
}
- if (attribs.size_max != SST_ASSET_MAX_SIZE_X509_CERT_LARGE) {
+ if (attribs.size_max != SST_ASSET_MAX_SIZE_AES_KEY_192) {
TEST_FAIL("Max size of the asset is incorrect");
return;
}
@@ -204,7 +204,7 @@
}
/**
- * \brief Tests policy for SST_ASSET_ID_X509_CERT_LARGE with the following
+ * \brief Tests policy for SST_ASSET_ID_AES_KEY_192 with the following
* permissions:
* THREAD NAME | APP_ID | Permissions
* ------------|--------------|------------
@@ -212,7 +212,7 @@
*/
TFM_SST_NS_TEST(4002, "Thread_A")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
struct tfm_sst_attribs_t attribs;
struct tfm_sst_buf_t buf;
enum tfm_sst_err_t err;
@@ -278,7 +278,7 @@
return;
}
- if (attribs.size_max != SST_ASSET_MAX_SIZE_X509_CERT_LARGE) {
+ if (attribs.size_max != SST_ASSET_MAX_SIZE_AES_KEY_192) {
TEST_FAIL("Max size of the asset is incorrect");
return;
}
@@ -294,7 +294,7 @@
}
/**
- * \brief Tests policy for SST_ASSET_ID_X509_CERT_LARGE with the following
+ * \brief Tests policy for SST_ASSET_ID_AES_KEY_192 with the following
* permissions:
* THREAD NAME | APP_ID | Permissions
* ------------|--------------|----------------
@@ -302,7 +302,7 @@
*/
TFM_SST_NS_TEST(4003, "Thread_B")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
struct tfm_sst_attribs_t attribs;
struct tfm_sst_buf_t buf;
enum tfm_sst_err_t err;
@@ -338,7 +338,7 @@
}
/* Sets the tfm_sst_buf_t structure */
- buf.data = read_data + 3;
+ buf.data = read_data + HALF_PADDING_SIZE;
buf.size = WRITE_BUF_SIZE;
buf.offset = 0;
@@ -370,7 +370,7 @@
return;
}
- if (attribs.size_max != SST_ASSET_MAX_SIZE_X509_CERT_LARGE) {
+ if (attribs.size_max != SST_ASSET_MAX_SIZE_AES_KEY_192) {
TEST_FAIL("Max size of the asset is incorrect");
return;
}
@@ -386,7 +386,7 @@
}
/**
- * \brief Tests delete policy for SST_ASSET_ID_X509_CERT_LARGE with the
+ * \brief Tests delete policy for SST_ASSET_ID_AES_KEY_192 with the
* following permissions:
* THREAD NAME | APP_ID | Permissions
* ------------|--------------|-----------------------
@@ -397,7 +397,7 @@
*/
TFM_SST_NS_TEST(4004, "Thread_C")
{
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
uint32_t hdl;
@@ -463,7 +463,7 @@
}
/* Sets the tfm_sst_buf_t structure */
- buf.data = read_data + 3;
+ buf.data = read_data + HALF_PADDING_SIZE;
buf.size = WRITE_BUF_SIZE;
buf.offset = 0;
@@ -670,7 +670,7 @@
}
/* Sets the tfm_sst_buf_t structure */
- buf.data = read_data + 3;
+ buf.data = read_data + HALF_PADDING_SIZE;
buf.size = WRITE_BUF_SIZE;
buf.offset = 0;
@@ -763,7 +763,7 @@
}
/* Sets the tfm_sst_buf_t structure */
- buf.data = read_data + 3;
+ buf.data = read_data + HALF_PADDING_SIZE;
buf.size = WRITE_BUF_SIZE;
buf.offset = 0;
diff --git a/test/suites/sst/secure/s_test_helpers.h b/test/suites/sst/secure/s_test_helpers.h
index 4ae531b..9c9932f 100755
--- a/test/suites/sst/secure/s_test_helpers.h
+++ b/test/suites/sst/secure/s_test_helpers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -15,6 +15,25 @@
#include "test/framework/test_framework.h"
/**
+ * Several tests use a buffer to read back data from an asset. This buffer is
+ * larger than the size of the asset data by PADDING_SIZE bytes. This allows
+ * us to ensure that the only the expected data is read back and that it is read
+ * back correctly.
+ *
+ * For example if the buffer and asset are as follows:
+ * Buffer - "XXXXXXXXXXXX", Asset data - "AAAA"
+ *
+ * Then a correct and successful read would give this result: "XXXXAAAAXXXX"
+ * (Assuming a PADDING_SIZE of 8)
+ */
+#define BUFFER_SIZE SST_ASSET_MAX_SIZE_AES_KEY_192
+#define PADDING_SIZE 8
+#define HALF_PADDING_SIZE 4
+
+#define BUFFER_PLUS_PADDING_SIZE (BUFFER_SIZE + PADDING_SIZE)
+#define BUFFER_PLUS_HALF_PADDING_SIZE (BUFFER_SIZE + HALF_PADDING_SIZE)
+
+/**
* \brief Prepares secure storage area for the new tests. It executes wipes and
* prepare.
*
diff --git a/test/suites/sst/secure/sst_reliability_testsuite.c b/test/suites/sst/secure/sst_reliability_testsuite.c
index f0ec676..836d5ea 100644
--- a/test/suites/sst/secure/sst_reliability_testsuite.c
+++ b/test/suites/sst/secure/sst_reliability_testsuite.c
@@ -58,15 +58,16 @@
* -------------------------------------
* S_APP_ID | REFERENCE, READ, WRITE
*/
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
static void tfm_sst_test_3001(struct test_result_t *ret)
{
uint32_t hdl;
uint32_t app_id = S_APP_ID;
- uint32_t asset_offset = 0;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
- struct tfm_sst_buf_t data;
+ struct tfm_sst_buf_t io_data;
enum tfm_sst_err_t err;
uint32_t itr;
+ uint32_t asset_offset = 0;
+ const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
uint8_t wrt_data[WRITE_BUF_SIZE] = WRITE_DATA;
uint8_t read_data[READ_BUF_SIZE] = READ_DATA;
@@ -89,28 +90,28 @@
}
/* Sets write and read sizes */
- data.size = WRITE_BUF_SIZE-1;
+ io_data.size = WRITE_BUF_SIZE-1;
for (itr = 0; itr < LOOP_ITERATIONS_001; itr++) {
TEST_LOG(" > Iteration %d of %d\r", itr + 1, LOOP_ITERATIONS_001);
do {
/* Sets data structure */
- data.data = wrt_data;
- data.offset = asset_offset;
+ io_data.data = wrt_data;
+ io_data.offset = asset_offset;
/* Checks write permissions in the write function */
- err = tfm_sst_veneer_write(app_id, hdl, &data);
+ err = tfm_sst_veneer_write(app_id, hdl, &io_data);
if (err != TFM_SST_ERR_SUCCESS) {
TEST_FAIL("Write should not fail for application S_APP_ID");
return;
}
/* Updates data structure to point to the read buffer */
- data.data = &read_data[3];
+ io_data.data = &read_data[3];
/* Checks write permissions in the read function */
- err = tfm_sst_veneer_read(app_id, hdl, &data);
+ err = tfm_sst_veneer_read(app_id, hdl, &io_data);
if (err != TFM_SST_ERR_SUCCESS) {
TEST_FAIL("Application S_APP_ID must get file handle");
return;
@@ -123,10 +124,10 @@
}
/* Reset read buffer data */
- memset(data.data, 'X', data.size);
+ memset(io_data.data, 'X', io_data.size);
/* Moves asset offsets to next position */
- asset_offset += data.size;
+ asset_offset += io_data.size;
} while (asset_offset < SST_ASSET_MAX_SIZE_X509_CERT_LARGE);
@@ -145,6 +146,96 @@
ret->val = TEST_PASSED;
}
+#else
+static void tfm_sst_test_3001(struct test_result_t *ret)
+{
+ uint32_t hdl;
+ uint32_t app_id = S_APP_ID;
+ struct tfm_sst_buf_t io_data;
+ enum tfm_sst_err_t err;
+ uint32_t itr;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
+ uint8_t data[BUFFER_PLUS_PADDING_SIZE] = {0};
+ uint32_t i;
+
+ /* Prepares test context */
+ if (prepare_test_ctx(ret) != 0) {
+ return;
+ }
+
+ /* Checks write permissions in create function */
+ err = tfm_sst_veneer_create(app_id, asset_uuid);
+ if (err != TFM_SST_ERR_SUCCESS) {
+ TEST_FAIL("Create should not fail for application S_APP_ID");
+ return;
+ }
+
+ err = tfm_sst_veneer_get_handle(app_id, asset_uuid, &hdl);
+ if (err != TFM_SST_ERR_SUCCESS) {
+ TEST_FAIL("Get handle should not fail");
+ return;
+ }
+
+ /* Sets write and read sizes */
+ io_data.size = SST_ASSET_MAX_SIZE_AES_KEY_192;
+
+ for (itr = 0; itr < LOOP_ITERATIONS_001; itr++) {
+ TEST_LOG(" > Iteration %d of %d\r", itr + 1, LOOP_ITERATIONS_001);
+
+ memset(data, 0, BUFFER_PLUS_PADDING_SIZE);
+ /* Sets data structure */
+ io_data.data = data;
+ io_data.offset = 0;
+
+ /* Checks write permissions in the write function */
+ err = tfm_sst_veneer_write(app_id, hdl, &io_data);
+ if (err != TFM_SST_ERR_SUCCESS) {
+ TEST_FAIL("Write should not fail for application S_APP_ID");
+ return;
+ }
+
+ memset(data, 'X', BUFFER_PLUS_PADDING_SIZE);
+ io_data.data = data + HALF_PADDING_SIZE;
+
+ /* Checks write permissions in the read function */
+ err = tfm_sst_veneer_read(app_id, hdl, &io_data);
+ if (err != TFM_SST_ERR_SUCCESS) {
+ TEST_FAIL("Application S_APP_ID must get file handle");
+ return;
+ }
+
+ /* Checks read data buffer content */
+ if (memcmp(data, "XXXX", HALF_PADDING_SIZE) != 0) {
+ TEST_FAIL("Read buffer contains illegal pre-data");
+ return;
+ }
+
+ for (i=HALF_PADDING_SIZE; i<(BUFFER_PLUS_HALF_PADDING_SIZE); i++) {
+ if (data[i] != 0) {
+ TEST_FAIL("Read buffer has read incorrect data");
+ return;
+ }
+ }
+
+ if (memcmp((data+BUFFER_PLUS_HALF_PADDING_SIZE), "XXXX",
+ HALF_PADDING_SIZE) != 0) {
+ TEST_FAIL("Read buffer contains illegal post-data");
+ return;
+ }
+ }
+
+ TEST_LOG("\n");
+
+ /* Checks write permissions in delete function */
+ err = tfm_sst_veneer_delete(app_id, hdl);
+ if (err != TFM_SST_ERR_SUCCESS) {
+ TEST_FAIL("Delete should not fail for application S_APP_ID");
+ return;
+ }
+
+ ret->val = TEST_PASSED;
+}
+#endif /* SST_ENABLE_PARTIAL_ASSET_RW */
/**
* \brief Tests repetitive creates, reads, writes and deletes, with the follow
@@ -153,15 +244,16 @@
* -------------------------------------
* S_APP_ID | REFERENCE, READ, WRITE
*/
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
static void tfm_sst_test_3002(struct test_result_t *ret)
{
uint32_t hdl;
uint32_t app_id = S_APP_ID;
- uint32_t asset_offset = 0;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
- struct tfm_sst_buf_t data;
+ struct tfm_sst_buf_t io_data;
enum tfm_sst_err_t err;
uint32_t itr;
+ uint32_t asset_offset = 0;
+ const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
uint8_t wrt_data[WRITE_BUF_SIZE] = WRITE_DATA;
uint8_t read_data[READ_BUF_SIZE] = READ_DATA;
@@ -171,7 +263,7 @@
}
/* Sets write and read sizes */
- data.size = WRITE_BUF_SIZE-1;
+ io_data.size = WRITE_BUF_SIZE-1;
for (itr = 0; itr < LOOP_ITERATIONS_002; itr++) {
TEST_LOG(" > Iteration %d of %d\r", itr + 1, LOOP_ITERATIONS_002);
@@ -191,21 +283,21 @@
do {
/* Sets data structure */
- data.data = wrt_data;
- data.offset = asset_offset;
+ io_data.data = wrt_data;
+ io_data.offset = asset_offset;
/* Checks write permissions in the write function */
- err = tfm_sst_veneer_write(app_id, hdl, &data);
+ err = tfm_sst_veneer_write(app_id, hdl, &io_data);
if (err != TFM_SST_ERR_SUCCESS) {
TEST_FAIL("Write should not fail for application S_APP_ID");
return;
}
/* Updates data structure to point to the read buffer */
- data.data = &read_data[3];
+ io_data.data = &read_data[3];
/* Checks write permissions in the read function */
- err = tfm_sst_veneer_read(app_id, hdl, &data);
+ err = tfm_sst_veneer_read(app_id, hdl, &io_data);
if (err != TFM_SST_ERR_SUCCESS) {
TEST_FAIL("Application S_APP_ID must get file handle");
return;
@@ -219,25 +311,116 @@
}
/* Reset read buffer data */
- memset(data.data, 'X', data.size);
+ memset(io_data.data, 'X', io_data.size);
/* Moves asset offsets to next position */
- asset_offset += data.size;
+ asset_offset += io_data.size;
} while (asset_offset < SST_ASSET_MAX_SIZE_X509_CERT_LARGE);
+ /* Resets asset_offset */
+ asset_offset = 0;
+
/* Checks write permissions in delete function */
err = tfm_sst_veneer_delete(app_id, hdl);
if (err != TFM_SST_ERR_SUCCESS) {
TEST_FAIL("Delete should not fail for application S_APP_ID");
return;
}
-
- /* Resets asset_offset */
- asset_offset = 0;
}
TEST_LOG("\n");
ret->val = TEST_PASSED;
}
+
+#else
+static void tfm_sst_test_3002(struct test_result_t *ret)
+{
+ uint32_t hdl;
+ uint32_t app_id = S_APP_ID;
+ struct tfm_sst_buf_t io_data;
+ enum tfm_sst_err_t err;
+ uint32_t itr;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
+ uint8_t data[BUFFER_PLUS_PADDING_SIZE] = {0};
+ uint32_t i;
+
+ /* Prepares test context */
+ if (prepare_test_ctx(ret) != 0) {
+ return;
+ }
+
+ /* Sets write and read sizes */
+ io_data.size = SST_ASSET_MAX_SIZE_AES_KEY_192;
+
+ for (itr = 0; itr < LOOP_ITERATIONS_002; itr++) {
+ TEST_LOG(" > Iteration %d of %d\r", itr + 1, LOOP_ITERATIONS_002);
+
+ /* Checks write permissions in create function */
+ err = tfm_sst_veneer_create(app_id, asset_uuid);
+ if (err != TFM_SST_ERR_SUCCESS) {
+ TEST_FAIL("Create should not fail for application S_APP_ID");
+ return;
+ }
+
+ err = tfm_sst_veneer_get_handle(app_id, asset_uuid, &hdl);
+ if (err != TFM_SST_ERR_SUCCESS) {
+ TEST_FAIL("Get handle should not fail");
+ return;
+ }
+
+ memset(data, 0, BUFFER_PLUS_PADDING_SIZE);
+ /* Sets data structure */
+ io_data.data = data;
+ io_data.offset = 0;
+
+ /* Checks write permissions in the write function */
+ err = tfm_sst_veneer_write(app_id, hdl, &io_data);
+ if (err != TFM_SST_ERR_SUCCESS) {
+ TEST_FAIL("Write should not fail for application S_APP_ID");
+ return;
+ }
+
+ memset(data, 'X', BUFFER_PLUS_PADDING_SIZE);
+ io_data.data = data + HALF_PADDING_SIZE;
+
+ /* Checks write permissions in the read function */
+ err = tfm_sst_veneer_read(app_id, hdl, &io_data);
+ if (err != TFM_SST_ERR_SUCCESS) {
+ TEST_FAIL("Application S_APP_ID must get file handle");
+ return;
+ }
+
+ /* Checks read data buffer content */
+ if (memcmp(data, "XXXX", HALF_PADDING_SIZE) != 0) {
+ TEST_FAIL("Read buffer contains illegal pre-data");
+ return;
+ }
+
+ for (i=HALF_PADDING_SIZE; i<(BUFFER_PLUS_HALF_PADDING_SIZE); i++) {
+ if (data[i] != 0) {
+ TEST_FAIL("Read buffer has read incorrect data");
+ return;
+ }
+ }
+
+ if (memcmp((data+BUFFER_PLUS_HALF_PADDING_SIZE), "XXXX",
+ HALF_PADDING_SIZE) != 0) {
+ TEST_FAIL("Read buffer contains illegal post-data");
+ return;
+ }
+
+ /* Checks write permissions in delete function */
+ err = tfm_sst_veneer_delete(app_id, hdl);
+ if (err != TFM_SST_ERR_SUCCESS) {
+ TEST_FAIL("Delete should not fail for application S_APP_ID");
+ return;
+ }
+ }
+
+ TEST_LOG("\n");
+
+ ret->val = TEST_PASSED;
+}
+#endif /* SST_ENABLE_PARTIAL_ASSET_RW */
diff --git a/test/suites/sst/secure/sst_sec_interface_testsuite.c b/test/suites/sst/secure/sst_sec_interface_testsuite.c
index 393e0e7..02902e1 100644
--- a/test/suites/sst/secure/sst_sec_interface_testsuite.c
+++ b/test/suites/sst/secure/sst_sec_interface_testsuite.c
@@ -19,7 +19,7 @@
/* Test suite defines */
#define INVALID_APP_ID 0xFFFFFFFF
#define INVALID_ASSET_ID 0xFFFF
-#define READ_BUF_SIZE 12UL
+#define READ_BUF_SIZE 14UL
#define WRITE_BUF_SIZE 5UL
/* Memory bounds to check */
@@ -33,6 +33,9 @@
#define WRITE_DATA_SHA224_2 "(ABCDEFGHIJKLMNOPQRSTUVWXYZ)"
#define BUF_SIZE_SHA224 (SST_ASSET_MAX_SIZE_SHA224_HASH + 1)
+/* Define used for bounds checking type tests */
+#define BUFFER_SIZE_PLUS_ONE (BUFFER_SIZE + 1)
+
/* Define test suite for asset manager tests */
/* List of tests */
static void tfm_sst_test_2001(struct test_result_t *ret);
@@ -50,13 +53,17 @@
static void tfm_sst_test_2013(struct test_result_t *ret);
static void tfm_sst_test_2014(struct test_result_t *ret);
static void tfm_sst_test_2015(struct test_result_t *ret);
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
static void tfm_sst_test_2016(struct test_result_t *ret);
static void tfm_sst_test_2017(struct test_result_t *ret);
static void tfm_sst_test_2018(struct test_result_t *ret);
+#endif
static void tfm_sst_test_2019(struct test_result_t *ret);
static void tfm_sst_test_2020(struct test_result_t *ret);
static void tfm_sst_test_2021(struct test_result_t *ret);
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
static void tfm_sst_test_2022(struct test_result_t *ret);
+#endif
static struct test_t write_tests[] = {
{&tfm_sst_test_2001, "TFM_SST_TEST_2001",
@@ -89,20 +96,24 @@
"Write partial data in an asset and reload secure storage area", {0} },
{&tfm_sst_test_2015, "TFM_SST_TEST_2015",
"Write more data than asset max size", {0} },
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
{&tfm_sst_test_2016, "TFM_SST_TEST_2016",
"Append data to an asset", {0} },
{&tfm_sst_test_2017, "TFM_SST_TEST_2017",
"Append data to an asset until EOF", {0} },
{&tfm_sst_test_2018, "TFM_SST_TEST_2018",
"Write data to two assets alternately", {0} },
+#endif
{&tfm_sst_test_2019, "TFM_SST_TEST_2019",
"Access an illegal location: ROM", {0} },
{&tfm_sst_test_2020, "TFM_SST_TEST_2020",
"Access an illegal location: device memory", {0} },
{&tfm_sst_test_2021, "TFM_SST_TEST_2021",
"Access an illegal location: non-existant memory", {0} },
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
{&tfm_sst_test_2022, "TFM_SST_TEST_2022",
"Write data to the middle of an existing asset", {0} },
+#endif
};
void register_testsuite_s_sst_sec_interface(struct test_suite_t *p_test_suite)
@@ -122,7 +133,7 @@
static void tfm_sst_test_2001(struct test_result_t *ret)
{
const uint32_t app_id = S_APP_ID;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
/* Prepares test context */
@@ -172,7 +183,7 @@
static void tfm_sst_test_2002(struct test_result_t *ret)
{
const uint32_t app_id = S_APP_ID;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
uint32_t hdl;
@@ -229,7 +240,7 @@
static void tfm_sst_test_2003(struct test_result_t *ret)
{
const uint32_t app_id = S_APP_ID;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
/* Prepares test context */
@@ -241,7 +252,7 @@
/* Calls get handle with invalid handle pointer */
err = tfm_sst_veneer_get_handle(app_id, asset_uuid, NULL);
if (err == TFM_SST_ERR_SUCCESS) {
- TEST_FAIL("Get handle should fail as asset hanlder pointer is invalid");
+ TEST_FAIL("Get handle should fail as asset handler pointer is invalid");
return;
}
@@ -257,7 +268,7 @@
static void tfm_sst_test_2004(struct test_result_t *ret)
{
const uint32_t app_id = S_APP_ID;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
struct tfm_sst_attribs_t asset_attrs;
enum tfm_sst_err_t err;
uint32_t hdl;
@@ -298,7 +309,7 @@
return;
}
- if (asset_attrs.size_max != SST_ASSET_MAX_SIZE_X509_CERT_LARGE) {
+ if (asset_attrs.size_max != SST_ASSET_MAX_SIZE_AES_KEY_192) {
TEST_FAIL("Max size of the asset is incorrect");
return;
}
@@ -329,7 +340,7 @@
static void tfm_sst_test_2005(struct test_result_t *ret)
{
const uint32_t app_id = S_APP_ID;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
uint32_t hdl;
@@ -373,7 +384,7 @@
static void tfm_sst_test_2006(struct test_result_t *ret)
{
const uint32_t app_id = S_APP_ID;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
struct tfm_sst_attribs_t asset_attrs;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
@@ -408,7 +419,7 @@
/* Writes data in the asset */
err = tfm_sst_veneer_write(app_id, hdl, &io_data);
if (err != TFM_SST_ERR_SUCCESS) {
- TEST_FAIL("Write should works correctly");
+ TEST_FAIL("Write should work correctly");
return;
}
@@ -453,7 +464,7 @@
static void tfm_sst_test_2007(struct test_result_t *ret)
{
const uint32_t app_id = S_APP_ID;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
uint32_t hdl;
@@ -507,11 +518,11 @@
static void tfm_sst_test_2008(struct test_result_t *ret)
{
const uint32_t app_id = S_APP_ID;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
uint32_t hdl;
- uint8_t wrt_data[WRITE_BUF_SIZE] = "DATA";
+ uint8_t wrt_data[BUFFER_PLUS_PADDING_SIZE] = {0};
/* Prepares test context */
if (prepare_test_ctx(ret) != 0) {
@@ -535,8 +546,8 @@
/* Attempts to write beyond end of asset starting from a valid offset */
io_data.data = wrt_data;
- io_data.size = 2;
- io_data.offset = SST_ASSET_MAX_SIZE_X509_CERT_LARGE - 1;
+ io_data.size = BUFFER_SIZE_PLUS_ONE;
+ io_data.offset = 0;
err = tfm_sst_veneer_write(app_id, hdl, &io_data);
if (err == TFM_SST_ERR_SUCCESS) {
@@ -546,7 +557,7 @@
/* Attempts to write to an offset beyond the end of the asset */
io_data.size = 1;
- io_data.offset = SST_ASSET_MAX_SIZE_X509_CERT_LARGE;
+ io_data.offset = SST_ASSET_MAX_SIZE_AES_KEY_192;
err = tfm_sst_veneer_write(app_id, hdl, &io_data);
if (err == TFM_SST_ERR_SUCCESS) {
@@ -566,12 +577,12 @@
static void tfm_sst_test_2009(struct test_result_t *ret)
{
const uint32_t app_id = S_APP_ID;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
uint32_t hdl;
uint8_t wrt_data[WRITE_BUF_SIZE] = "DATA";
- uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXX";
+ uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXXXX";
/* Prepares test context */
if (prepare_test_ctx(ret) != 0) {
@@ -601,33 +612,34 @@
/* Writes data in the asset */
err = tfm_sst_veneer_write(app_id, hdl, &io_data);
if (err != TFM_SST_ERR_SUCCESS) {
- TEST_FAIL("Write should works correctly");
+ TEST_FAIL("Write should work correctly");
return;
}
/* Sets data structure for read*/
- io_data.data = read_data+3;
+ io_data.data = read_data + HALF_PADDING_SIZE;
io_data.size = WRITE_BUF_SIZE;
io_data.offset = 0;
/* Read data from the asset */
err = tfm_sst_veneer_read(app_id, hdl, &io_data);
if (err != TFM_SST_ERR_SUCCESS) {
- TEST_FAIL("Read should works correctly");
+ TEST_FAIL("Read should work correctly");
return;
}
- if (memcmp(read_data, "XXX", 3) != 0) {
+ if (memcmp(read_data, "XXXX", HALF_PADDING_SIZE) != 0) {
TEST_FAIL("Read buffer contains illegal pre-data");
return;
}
- if (memcmp((read_data+3), wrt_data, WRITE_BUF_SIZE) != 0) {
+ if (memcmp((read_data+HALF_PADDING_SIZE), wrt_data, WRITE_BUF_SIZE) != 0) {
TEST_FAIL("Read buffer has read incorrect data");
return;
}
- if (memcmp((read_data+8), "XXX", 3) != 0) {
+ if (memcmp((read_data+HALF_PADDING_SIZE+WRITE_BUF_SIZE), "XXXX",
+ HALF_PADDING_SIZE) != 0) {
TEST_FAIL("Read buffer contains illegal post-data");
return;
}
@@ -659,7 +671,7 @@
static void tfm_sst_test_2010(struct test_result_t *ret)
{
const uint32_t app_id = S_APP_ID;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
uint32_t hdl;
@@ -712,13 +724,12 @@
static void tfm_sst_test_2011(struct test_result_t *ret)
{
const uint32_t app_id = S_APP_ID;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
struct tfm_sst_attribs_t asset_attrs;
uint32_t hdl;
- uint8_t wrt_data[WRITE_BUF_SIZE] = "DATA";
- uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXX";
+ uint8_t data[BUFFER_SIZE_PLUS_ONE] = {0};
/* Prepares test context */
if (prepare_test_ctx(ret) != 0) {
@@ -741,14 +752,14 @@
}
/* Sets data structure */
- io_data.data = wrt_data;
- io_data.size = WRITE_BUF_SIZE;
+ io_data.data = data;
+ io_data.size = SST_ASSET_MAX_SIZE_AES_KEY_192;
io_data.offset = 0;
/* Writes data in the asset */
err = tfm_sst_veneer_write(app_id, hdl, &io_data);
if (err != TFM_SST_ERR_SUCCESS) {
- TEST_FAIL("Write should works correctly");
+ TEST_FAIL("Write should work correctly");
return;
}
@@ -767,9 +778,9 @@
}
/* Attempts to read beyond the current size starting from a valid offset */
- io_data.data = read_data;
- io_data.size = 2;
- io_data.offset = asset_attrs.size_current - 1;
+ io_data.data = data;
+ io_data.size = BUFFER_SIZE_PLUS_ONE;
+ io_data.offset = 0;
err = tfm_sst_veneer_read(app_id, hdl, &io_data);
if (err == TFM_SST_ERR_SUCCESS) {
@@ -949,12 +960,12 @@
static void tfm_sst_test_2013(struct test_result_t *ret)
{
const uint32_t app_id = S_APP_ID;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
uint32_t hdl;
uint32_t i;
- uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXX";
+ uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXXXX";
uint8_t wrt_data[WRITE_BUF_SIZE] = "DATA";
/* Prepares test context */
@@ -985,20 +996,24 @@
/* Writes data in the asset */
err = tfm_sst_veneer_write(app_id, hdl, &io_data);
if (err != TFM_SST_ERR_SUCCESS) {
- TEST_FAIL("Write should works correctly");
+ TEST_FAIL("Write should work correctly");
return;
}
- /* Sets data structure for read*/
- io_data.data = (read_data + 3);
+ /* Sets data structure for read */
+ io_data.data = read_data + HALF_PADDING_SIZE;
io_data.size = 1;
io_data.offset = 0;
- for (i = 0; i < WRITE_BUF_SIZE; i++) {
+ for (i = 0; i < WRITE_BUF_SIZE ; i++) {
/* Read data from the asset */
err = tfm_sst_veneer_read(app_id, hdl, &io_data);
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
if (err != TFM_SST_ERR_SUCCESS) {
- TEST_FAIL("Read should works correctly");
+#else
+ if (io_data.offset != 0 && err != TFM_SST_ERR_PARAM_ERROR) {
+#endif
+ TEST_FAIL("Read did not behave correctly");
return;
}
@@ -1007,17 +1022,23 @@
io_data.offset++;
}
- if (memcmp(read_data, "XXX", 3) != 0) {
+ if (memcmp(read_data, "XXXX", HALF_PADDING_SIZE) != 0) {
TEST_FAIL("Read buffer contains illegal pre-data");
return;
}
- if (memcmp((read_data + 3), wrt_data, WRITE_BUF_SIZE) != 0) {
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
+ if (memcmp((read_data+HALF_PADDING_SIZE), wrt_data, WRITE_BUF_SIZE) != 0) {
+#else
+ /* Only the first read ("D") is from a valid offset (0) */
+ if (memcmp((read_data+HALF_PADDING_SIZE), "DXXXX", WRITE_BUF_SIZE) != 0) {
+#endif
TEST_FAIL("Read buffer has read incorrect data");
return;
}
- if (memcmp((read_data + 8), "XXX", 3) != 0) {
+ if (memcmp((read_data+HALF_PADDING_SIZE+WRITE_BUF_SIZE), "XXXX",
+ HALF_PADDING_SIZE) != 0) {
TEST_FAIL("Read buffer contains illegal post-data");
return;
}
@@ -1034,11 +1055,11 @@
static void tfm_sst_test_2014(struct test_result_t *ret)
{
const uint32_t app_id = S_APP_ID;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
uint32_t hdl;
- uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXX";
+ uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXXXX";
uint8_t wrt_data[WRITE_BUF_SIZE] = "DATA";
/* Prepares test context */
@@ -1069,7 +1090,7 @@
/* Writes data in the asset */
err = tfm_sst_veneer_write(app_id, hdl, &io_data);
if (err != TFM_SST_ERR_SUCCESS) {
- TEST_FAIL("Write should works correctly");
+ TEST_FAIL("Write should work correctly");
return;
}
@@ -1081,7 +1102,7 @@
}
/* Sets data structure */
- io_data.data = (read_data + 3);
+ io_data.data = read_data + HALF_PADDING_SIZE;
io_data.size = WRITE_BUF_SIZE;
io_data.offset = 0;
@@ -1092,17 +1113,18 @@
return;
}
- if (memcmp(read_data, "XXX", 3) != 0) {
+ if (memcmp(read_data, "XXXX", HALF_PADDING_SIZE)) {
TEST_FAIL("Read buffer contains illegal pre-data");
return;
}
- if (memcmp((read_data + 3), wrt_data, WRITE_BUF_SIZE) != 0) {
+ if (memcmp((read_data+HALF_PADDING_SIZE), wrt_data, WRITE_BUF_SIZE) != 0) {
TEST_FAIL("Read buffer has read incorrect data");
return;
}
- if (memcmp((read_data + 8), "XXX", 3) != 0) {
+ if (memcmp((read_data+HALF_PADDING_SIZE+WRITE_BUF_SIZE), "XXXX",
+ HALF_PADDING_SIZE) != 0) {
TEST_FAIL("Read buffer contains illegal post-data");
return;
}
@@ -1158,6 +1180,7 @@
ret->val = TEST_PASSED;
}
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
/**
* \brief Tests write function against multiple writes.
*/
@@ -1168,7 +1191,7 @@
enum tfm_sst_err_t err;
struct tfm_sst_buf_t io_data;
uint32_t hdl;
- uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXX";
+ uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXXXX";
uint8_t wrt_data[WRITE_BUF_SIZE+1] = "Hello";
uint8_t wrt_data2[WRITE_BUF_SIZE+1] = "World";
@@ -1231,7 +1254,7 @@
/* The X is used to check that the number of bytes read was exactly the
* number requested
*/
- if (memcmp(read_data, "HelloWorldX", READ_BUF_SIZE) != 0) {
+ if (memcmp(read_data, "HelloWorldXXX", READ_BUF_SIZE) != 0) {
TEST_FAIL("Read buffer has read incorrect data");
return;
}
@@ -1294,7 +1317,7 @@
err = tfm_sst_veneer_write(app_id, hdl, &io_data);
if (err == TFM_SST_ERR_SUCCESS) {
TEST_FAIL("Write data 2 should have failed as this write tries to "
- "write more bytes that the max size");
+ "write more bytes than the max size");
return;
}
@@ -1338,13 +1361,13 @@
const uint32_t app_id_1 = S_APP_ID;
const uint32_t app_id_2 = S_APP_ID;
- const uint16_t asset_uuid_1 = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid_1 = SST_ASSET_ID_AES_KEY_192;
const uint16_t asset_uuid_2 = SST_ASSET_ID_SHA224_HASH;
enum tfm_sst_err_t err;
uint32_t hdl_1;
uint32_t hdl_2;
struct tfm_sst_buf_t io_data;
- uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXX";
+ uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXXXX";
uint8_t wrt_data[WRITE_BUF_SIZE+1] = "Hello";
uint8_t wrt_data2[3] = "Hi";
uint8_t wrt_data3[WRITE_BUF_SIZE+1] = "World";
@@ -1444,7 +1467,7 @@
return;
}
- if (memcmp(read_data, "HelloWorldX", READ_BUF_SIZE) != 0) {
+ if (memcmp(read_data, "HelloWorldXXX", READ_BUF_SIZE) != 0) {
TEST_FAIL("Read buffer has incorrect data");
return;
}
@@ -1464,13 +1487,14 @@
return;
}
- if (memcmp(read_data, "Hi12345XXXX", READ_BUF_SIZE) != 0) {
+ if (memcmp(read_data, "Hi12345XXXXXX", READ_BUF_SIZE) != 0) {
TEST_FAIL("Read buffer has incorrect data");
return;
}
ret->val = TEST_PASSED;
}
+#endif /* SST_ENABLE_PARTIAL_ASSET_RW */
/**
* \brief Tests read from and write to an illegal location: ROM.
@@ -1661,18 +1685,19 @@
ret->val = TEST_PASSED;
}
+#ifdef SST_ENABLE_PARTIAL_ASSET_RW
/**
* \brief Writes data to the middle of an existing asset.
*/
static void tfm_sst_test_2022(struct test_result_t *ret)
{
const uint32_t app_id = S_APP_ID;
- const uint16_t asset_uuid = SST_ASSET_ID_X509_CERT_LARGE;
+ const uint16_t asset_uuid = SST_ASSET_ID_AES_KEY_192;
struct tfm_sst_attribs_t attribs;
struct tfm_sst_buf_t buf;
enum tfm_sst_err_t err;
uint32_t hdl;
- uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXX";
+ uint8_t read_data[READ_BUF_SIZE] = "XXXXXXXXXXXXX";
uint8_t write_data_1[WRITE_BUF_SIZE] = "AAAA";
uint8_t write_data_2[2] = "B";
@@ -1741,7 +1766,7 @@
return;
}
- buf.data = (read_data + 3);
+ buf.data = (read_data + HALF_PADDING_SIZE);
buf.size = (WRITE_BUF_SIZE - 1);
buf.offset = 0;
@@ -1754,7 +1779,7 @@
/* Checks that the asset contains write_data_1 with the second character
* overwritten with write_data_2.
*/
- if (memcmp(read_data, "XXXABAAXXXX", READ_BUF_SIZE) != 0) {
+ if (memcmp(read_data, "XXXXABAAXXXXX", READ_BUF_SIZE) != 0) {
TEST_FAIL("Read buffer is incorrect");
return;
}
@@ -1773,3 +1798,4 @@
ret->val = TEST_PASSED;
}
+#endif /* SST_ENABLE_PARTIAL_ASSET_RW */