Как использовать технологию TEE в Android Studio?? Недоступность библиотеки optee_client_java_api
Я хочу реализовать TA и CA в проекте Android Studio. Для этого я выполнил следующие шаги.
Download the OP-TEE Client source code from the following link: https://github.com/OP-TEE/optee_client
Copy the required header files from the include folder to your Android project's source directory.
Open your Android.mk file (located in app/src/main/jni/Android.mk) and add the following lines:
makefile
LOCAL_C_INCLUDES += $(LOCAL_PATH)/optee_client/include
LOCAL_LDLIBS += -lutee -ltee_client_api
Open your Application.mk file (located in app/src/main/jni/Application.mk) and add the following line at the end of the file:
makefile
APP_CFLAGS += -DUTEE_LOG_LEVEL=UTEE_LOG_INFO
Для кода CA в java ниже приведен код
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
// Load the native library that contains the TEE Client API
static {
System.loadLibrary("optee_client");
}
// Define the UUID of the TA
private static final byte[] TA_UUID = new byte[] {
(byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
(byte) 0x87, (byte) 0x65, (byte) 0x43, (byte) 0x21,
(byte) 0x21, (byte) 0x43, (byte) 0x65, (byte) 0x87,
(byte) 0x09, (byte) 0x87, (byte) 0x65, (byte) 0x43
};
// Declare variables for the TEE Client API
private TEEC_Context context;
private TEEC_Session session;
private TEEC_Operation operation;
private TEEC_UUID uuid = new TEEC_UUID(TA_UUID);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Get references to the UI elements
final EditText firstNumber = findViewById(R.id.firstNumber);
final EditText secondNumber = findViewById(R.id.secondNumber);
Button addButton = findViewById(R.id.addButton);
final TextView resultView = findViewById(R.id.resultView);
// Initialize the TEE Client API
context = new TEEC_Context();
operation = new TEEC_Operation();
int result = TEEC_InitializeContext(null, context);
if (result != TEEC_SUCCESS) {
// Handle error
}
// Open a session with the TA
result = TEEC_OpenSession(context, session, uuid, TEEC_LOGIN_PUBLIC, null, null, null);
if (result != TEEC_SUCCESS) {
// Handle error
}
// Set up the TEEC_Operation structure to pass arguments to the TA
int[] paramTypes = new int[] {TEEC_VALUE_INPUT, TEEC_VALUE_INPUT, TEEC_VALUE_OUTPUT, TEEC_NONE};
operation.paramTypes = paramTypes;
operation.started = 1;
operation.params[0].value.a = Integer.parseInt(firstNumber.getText().toString());
operation.params[1].value.a = Integer.parseInt(secondNumber.getText().toString());
// Set up a button click listener to invoke the TA and display the result
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int result = TEEC_InvokeCommand(session, TA_ADDITION_CMD, operation, null);
if (result != TEEC_SUCCESS) {
// Handle error
}
resultView.setText("Result: " + operation.params[2].value.a);
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
// Clean up the TEE Client API resources
TEEC_CloseSession(session);
TEEC_FinalizeContext(context);
}
}
Чтобы использовать классы TEEC_Context, TEEC_Session и TEEC_Operation в проекте Android, необходимо включить следующие зависимости в файл app/build.gradle:
gradle
implementation 'com.github.OP-TEE.optee_client:optee_client_java_api:3.12.0'
Я также пробую эту реализацию, но не могу импортировать TEEC_Context, TEEC_Session и TEEC_Operation.
dependencies {
implementation 'com.github.linaro-swg:optee_client_java_api:v1.5.0'
implementation 'org.bouncycastle:bcpkix-jdk15on:1.68'
implementation 'org.bouncycastle:bcprov-jdk15on:1.68'
implementation 'org.op-tee:optee_client:3.12.0'
}
Удален ли optee_client_java_api с помощью Op-tee или есть какие-либо другие зависимости, которые мы должны добавить сюда, чтобы использовать TEEC_Context, TEEC_Session и TEEC_Operation?