Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

raw secure storage accesses #5

Merged
merged 1 commit into from
Jul 10, 2018

Conversation

etienne-lms
Copy link
Contributor

secure_storage example provides basics for creating, reading and deleting
a object in a TA secure storage.

A TA command allows to create an object in the TA secure storage.
A TA command allows to read an object in the TA secure storage.
A TA command allows to delete an object from the TA secur storage.

This example does not cover all the possibilities of secure storage API
provided to TAs: seeking into a object data stream, manipulating
key material objects instead of raw data objects, etc.

$(OPTEE_CLIENT_EXPORT)/include \

LOCAL_SHARED_LIBRARIES := libteec
LOCAL_MODULE := tee_example_secure_storage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should prefix all optee_example files with somethings like ote_<module> (OP-TEE Example).

@@ -0,0 +1,15 @@
export V?=0
Copy link
Contributor

@jbech-linaro jbech-linaro Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/export V?=0/export V ?= 0/

#Add/link other required libraries here
LDADD += -lteec -L$(TEEC_EXPORT)/lib

BINARY = optee_secure_storage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here as for the module in the Android make files, ... ote_<module>. At least we should have the same name in both Android and Linux.

if (res != TEEC_SUCCESS)
errx(1, "Failed to create an object in the secure storage");

printf("- Read back the but in a too small buffer (should fail)\n");
Copy link
Contributor

@jbech-linaro jbech-linaro Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is a good idea to show this in an example like this. This smells a bit more of a test case than just showing how to do things. I would just skip this and go directly with the well sized buffer.

Copy link
Contributor

@jbech-linaro jbech-linaro Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, if you insist of keeping this part, then I think you should at least check/use the params[1].memref.size which contains the expected size when TEEC_ERROR_SHORT_BUFFER is returned (at least that is what you are doing in the TA).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove the test case.

if (res != TEEC_SUCCESS)
errx(1, "Failed to delete the object: 0x%x", res);

printf("- Try to access the object (should fail)\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, I would skip this "should fail" section.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


#define TA_CURRENT_TA_EXT_PROPERTIES \
{ "gp.ta.description", USER_TA_PROP_TYPE_STRING, \
"Exmaple of TA writing/reading data from its secure storage" }, \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Exmaple/Example/


#include <secure_storage_ta.h>

#define TA_UUID TA_SECURE_STORAGE_UUID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use the same idea here? OTE_<module>_UUID?

@etienne-lms
Copy link
Contributor Author

comments addressed.

res = read_secure_object(&ctx, obj1_id,
read_data, sizeof(read_data));
if (res != TEEC_SUCCESS)
errx(1, "Failed to create an object in the secure storage");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here Error message should be "Failed to read an object".

@etienne-lms
Copy link
Contributor Author

Rebased on top of #8 and #3.

@etienne-lms etienne-lms force-pushed the secure-storage-raw branch 3 times, most recently from f9b948c to 7a830ac Compare November 10, 2017 10:49
@etienne-lms
Copy link
Contributor Author

Rebased on master.

Copy link
Contributor

@jforissier jforissier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>

NM = $(CROSS_COMPILE)nm
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
READELF = $(CROSS_COMPILE)readelf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only CC is needed it seems

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept for consistency with other. Will clean all in a later change if better.

@etienne-lms etienne-lms force-pushed the secure-storage-raw branch 2 times, most recently from 46d63c8 to 3318005 Compare July 10, 2018 07:45
@etienne-lms
Copy link
Contributor Author

Rebased, tag applied.

.gitignore Outdated
@@ -17,3 +17,4 @@ hello_world/host/optee_example_hello_world
random/host/optee_example_random
aes/host/optee_example_aes
hotp/host/optee_example_hotp
secure_storage/host/optee_example_secure_storag
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is an e missing at the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. i don't know how I corrupted that!
Thanks.

@jenswi-linaro
Copy link
Contributor

Acked-by: Jens Wiklander <jens.wiklander@linaro.org>

This change provides basics for creating, reading and deleting an
object in a TA secure storage.

The TA implementation shows how to use the GPD TEE Internal Core API
for some basic data persistent object manipulations.

A TA command allows to create an object in the TA secure storage.
A TA command allows to read an object in the TA secure storage.
A TA command allows to delete an object from the TA secure storage.

This example does not cover all the possibilities of secure storage API
provided to TAs: seeking into a object data stream, manipulating
key material objects instead of raw data objects, etc.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
@etienne-lms
Copy link
Contributor Author

Squashed, commit description fixed, tags applied.
Thanks

@jenswi-linaro jenswi-linaro merged commit ae02c09 into linaro-swg:master Jul 10, 2018
@etienne-lms etienne-lms deleted the secure-storage-raw branch November 14, 2019 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants