資源簡介
該部分為在OP-TEE中添加的TA和CA部分的代碼,結合修改OP-TEE build目錄中的Makefile和其他編譯文件即可將該TA和CA添加到OP-TEE OS中使用qemu運行

代碼片段和文件信息
/*
?*?Copyright?(c)?2016?Linaro?Limited
?*?All?rights?reserved.
?*
?*?Redistribution?and?use?in?source?and?binary?forms?with?or?without
?*?modification?are?permitted?provided?that?the?following?conditions?are?met:
?*
?*?1.?Redistributions?of?source?code?must?retain?the?above?copyright?notice
?*?this?list?of?conditions?and?the?following?disclaimer.
?*
?*?2.?Redistributions?in?binary?form?must?reproduce?the?above?copyright?notice
?*?this?list?of?conditions?and?the?following?disclaimer?in?the?documentation
?*?and/or?other?materials?provided?with?the?distribution.
?*
?*?THIS?SOFTWARE?IS?PROVIDED?BY?THE?COPYRIGHT?HOLDERS?AND?CONTRIBUTORS?“AS?IS“
?*?AND?ANY?EXPRESS?OR?IMPLIED?WARRANTIES?INCLUDING?BUT?NOT?LIMITED?TO?THE
?*?IMPLIED?WARRANTIES?OF?MERCHANTABILITY?AND?FITNESS?FOR?A?PARTICULAR?PURPOSE
?*?ARE?DISCLAIMED.?IN?NO?EVENT?SHALL?THE?COPYRIGHT?HOLDER?OR?CONTRIBUTORS?BE
?*?LIABLE?FOR?ANY?DIRECT?INDIRECT?INCIDENTAL?SPECIAL?EXEMPLARY?OR
?*?CONSEQUENTIAL?DAMAGES?(INCLUDING?BUT?NOT?LIMITED?TO?PROCUREMENT?OF
?*?SUBSTITUTE?GOODS?OR?SERVICES;?LOSS?OF?USE?DATA?OR?PROFITS;?OR?BUSINESS
?*?INTERRUPTION)?HOWEVER?CAUSED?AND?ON?ANY?THEORY?OF?LIABILITY?WHETHER?IN
?*?CONTRACT?STRICT?LIABILITY?OR?TORT?(INCLUDING?NEGLIGENCE?OR?OTHERWISE)
?*?ARISING?IN?ANY?WAY?OUT?OF?THE?USE?OF?THIS?SOFTWARE?EVEN?IF?ADVISED?OF?THE
?*?POSSIBILITY?OF?SUCH?DAMAGE.
?*/
#include?
#include?
#include?
#include?
/*?OP-TEE?TEE?client?API?(built?by?optee_client)?*/
#include?
/*?To?the?the?UUID?(found?the?the?TA‘s?h-file(s))?*/
#include?“my_test_ca.h“
static?int?g_TaskInitFlag?=?-1;????/*?Flag?if?the?task?done?initialize?operation?*/
TEEC_UUID?svc_id?=?TA_MY_TEST_UUID;
TEEC_Context?g_TaskContext;
CHAR?g_RandomOut[512]?=?{0};
/*?Buffer?for?sha?operation?*/
CHAR?g_ShaTestBuf[]?={
?????‘Y‘?‘o‘?‘u‘?‘?‘?‘y‘?‘o‘?‘u‘?‘?‘?‘c‘?‘h‘?‘e‘?‘c‘?‘k‘?‘?‘?‘n‘?‘o‘
?????‘w‘?‘j‘?‘i‘?‘a‘?‘n‘?‘?‘?‘b‘?‘i‘?‘n‘?‘g‘?‘?‘?‘g‘?‘u‘?‘o‘?‘?‘?‘z‘
?????‘i‘?‘?‘?‘l‘?‘a‘?‘i‘?‘?‘?‘y‘?‘i‘?‘?‘?‘t‘?‘a‘?‘o‘?‘!‘?‘!‘?‘!‘?‘!‘};
CHAR?g_ShaOutput[80]?=?{0};
CHAR?g_Sha1Result[]?=?
{???
????0x21?0x9b?0x5b?0x8b?0x25?0x6f?0x0e?0x52?0xcb?0x2f?0xfe?0xfd?0x6c?0x47?0xd7?0xb4?
????0x44?0x00?0x57?0xc3
};
CHAR?g_Sha256Result[]?=?
{???
????0xda?0x52?0xe9?0xc2?0x53?0xae?0x03?0x30?0xbd?0x97?0x3f?0xa5?0xf3?0xea?0x51?0x1d?
????0x31?0x0a?0xdf?0x1f?0x0a?0xc0?0x0e?0x62?0x0f?0x2d?0x5e?0x99?0xf5?0xc8?0x6b?0x8f
};
void?g_CA_PrintfBuffer(CHAR*?buf?UINT32?len)
{
????UINT32?index?=?0U;
????for(index?=?0U;?index?????{
????????if(index?15U)
????????{
????????}
????????else?if(0U?==?index%16U)
????????{
????????????printf(“\n“);
????????????
????????}
????????else
????????{
????????}
????????
????????printf(“0x%02x?“?(buf[index]?&?0x000000FFU));
????????
????}
????printf(“\n“);
???
}
int?l_CryptoVerifyCa_TaskInit(void)
{
????TEEC_Result?result;
????int?l_RetVal?=?O
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????928??2017-05-10?12:25??OP-TEE_my_test\Android.mk
?????文件????????955??2017-05-10?12:25??OP-TEE_my_test\build_ta_mytest_qemu.sh
?????文件????????359??2017-05-10?12:25??OP-TEE_my_test\doc\close_session_and_finalize_context.msc
?????文件????????390??2017-05-10?12:25??OP-TEE_my_test\doc\invoke_command.msc
?????文件????????287??2017-05-10?12:25??OP-TEE_my_test\doc\Makefile
?????文件????????545??2017-05-10?12:25??OP-TEE_my_test\doc\open_session.msc
?????文件???????9782??2017-05-10?12:25??OP-TEE_my_test\host\main.c
?????文件????????517??2017-05-10?12:25??OP-TEE_my_test\host\Makefile
?????文件???????3695??2017-05-10?12:25??OP-TEE_my_test\host\my_test_ca.h
?????文件????????203??2017-05-10?12:25??OP-TEE_my_test\Makefile
?????文件???????1378??2017-05-10?12:25??OP-TEE_my_test\README.md
?????文件????????112??2017-05-10?12:25??OP-TEE_my_test\ta\Android.mk
?????文件???????3845??2017-05-10?12:25??OP-TEE_my_test\ta\include\my_test_handle.h
?????文件???????1957??2017-05-10?12:25??OP-TEE_my_test\ta\include\my_test_ta.h
?????文件????????213??2017-05-10?12:25??OP-TEE_my_test\ta\Makefile
?????文件???????4476??2017-05-10?12:25??OP-TEE_my_test\ta\my_test.c
?????文件???????6804??2017-05-10?12:25??OP-TEE_my_test\ta\my_test_handle.c
?????文件????????221??2017-05-10?12:25??OP-TEE_my_test\ta\sub.mk
?????文件???????1996??2017-05-10?12:25??OP-TEE_my_test\ta\user_ta_header_defines.h
?????目錄??????????0??2017-05-10?12:29??OP-TEE_my_test\ta\include
?????目錄??????????0??2017-05-10?12:29??OP-TEE_my_test\doc
?????目錄??????????0??2017-05-10?12:29??OP-TEE_my_test\host
?????目錄??????????0??2017-05-10?12:29??OP-TEE_my_test\ta
?????目錄??????????0??2017-05-10?12:29??OP-TEE_my_test
-----------?---------??----------?-----??----
????????????????38663????????????????????24
評論
共有 條評論