luckfox-pico-sdk/sysdrv/source/uboot/u-boot/include/optee_include/OpteeClientInterface.h
luckfox-eng29 8f34c2760d project:build.sh: Added fastboot support; custom modifications to U-Boot and kernel implemented using patches.
project:cfg:BoardConfig_IPC: Added fastboot BoardConfig file and firmware post-scripts, distinguishing between
the BoardConfigs for Luckfox Pico Pro and Luckfox Pico Max. project:app: Added fastboot_client and rk_smart_door
for quick boot applications; updated rkipc app to adapt to the latest media library. media:samples: Added more
usage examples. media:rockit: Fixed bugs; removed support for retrieving data frames from VPSS. media:isp:
Updated rkaiq library and related tools to support connection to RKISP_Tuner. sysdrv:Makefile: Added support for
compiling drv_ko on Luckfox Pico Ultra W using Ubuntu; added support for custom root filesystem.
sysdrv:tools:board: Updated Buildroot optional mirror sources, updated some software versions, and stored device
tree files and configuration files that undergo multiple modifications for U-Boot and kernel separately.
sysdrv:source:mcu: Used RISC-V MCU SDK with RT-Thread system, mainly for initializing camera AE during quick
boot. sysdrv:source:uboot: Added support for fastboot; added high baud rate DDR bin for serial firmware upgrades.
sysdrv:source:kernel: Upgraded to version 5.10.160; increased NPU frequency for RV1106G3; added support for
fastboot.

Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
2024-10-14 09:47:04 +08:00

126 lines
4.3 KiB
C

/*
* Copyright 2017, Rockchip Electronics Co., Ltd
* hisping lin, <hisping.lin@rock-chips.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#ifndef _OPTEECLIENTTEST_H_
#define _OPTEECLIENTTEST_H_
#include <optee_include/tee_client_api.h>
enum RK_OEM_OTP_KEYID {
RK_OEM_OTP_KEY0 = 0,
RK_OEM_OTP_KEY1 = 1,
RK_OEM_OTP_KEY2 = 2,
RK_OEM_OTP_KEY3 = 3,
RK_OEM_OTP_KEY_FW = 10, //keyid of fw_encryption_key
RK_OEM_OTP_KEYMAX
};
enum RK_HDCP_KEYID {
RK_HDCP_KEY0 = 0,
RK_HDCP_KEY1 = 1,
RK_HDCP_KEYMAX
};
/* Crypto mode */
enum RK_CIPIHER_MODE {
RK_CIPHER_MODE_ECB = 0,
RK_CIPHER_MODE_CBC = 1,
RK_CIPHER_MODE_CTS = 2,
RK_CIPHER_MODE_CTR = 3,
RK_CIPHER_MODE_CFB = 4,
RK_CIPHER_MODE_OFB = 5,
RK_CIPHER_MODE_XTS = 6,
RK_CIPHER_MODE_CCM = 7,
RK_CIPHER_MODE_GCM = 8,
RK_CIPHER_MODE_CMAC = 9,
RK_CIPHER_MODE_CBC_MAC = 10,
RK_CIPHER_MODE_MAX
};
/* Crypto algorithm */
enum RK_CRYPTO_ALGO {
RK_ALGO_AES = 1,
RK_ALGO_DES,
RK_ALGO_TDES,
RK_ALGO_SM4,
RK_ALGO_ALGO_MAX
};
typedef struct {
uint32_t algo;
uint32_t mode;
uint32_t operation;
uint8_t key[64];
uint32_t key_len;
uint8_t iv[16];
void *reserved;
} rk_cipher_config;
/* Crypto operation */
#define RK_MODE_ENCRYPT 1
#define RK_MODE_DECRYPT 0
#define AES_BLOCK_SIZE 16
#define SM4_BLOCK_SIZE 16
#define RK_CRYPTO_MAX_DATA_LEN (1 * 1024 * 1024)
#define ATAP_HEX_UUID_LEN 32
#define ATTEST_DH_SIZE 8
#define ATTEST_UUID_SIZE (ATAP_HEX_UUID_LEN+1)
#define ATTEST_CA_OUT_SIZE 256
void optee_client_init(void);
uint32_t trusty_read_rollback_index(uint32_t slot, uint64_t *value);
uint32_t trusty_write_rollback_index(uint32_t slot, uint64_t value);
uint32_t trusty_read_permanent_attributes(uint8_t *attributes, uint32_t size);
uint32_t trusty_write_permanent_attributes(uint8_t *attributes, uint32_t size);
uint32_t trusty_read_permanent_attributes_cer(uint8_t *attributes,
uint32_t size);
uint32_t trusty_write_permanent_attributes_cer(uint8_t *attributes,
uint32_t size);
uint32_t trusty_read_lock_state(uint8_t *lock_state);
uint32_t trusty_write_lock_state(uint8_t lock_state);
uint32_t trusty_read_flash_lock_state(uint8_t *flash_lock_state);
uint32_t trusty_write_flash_lock_state(uint8_t flash_lock_state);
uint32_t trusty_read_attribute_hash(uint32_t *buf, uint32_t length);
uint32_t trusty_write_attribute_hash(uint32_t *buf, uint32_t length);
uint32_t trusty_notify_optee_uboot_end(void);
uint32_t trusty_read_vbootkey_hash(uint32_t *buf, uint32_t length);
uint32_t trusty_write_vbootkey_hash(uint32_t *buf, uint32_t length);
uint32_t trusty_read_vbootkey_enable_flag(uint8_t *flag);
uint32_t trusty_write_ta_encryption_key(uint32_t *buf, uint32_t length);
uint32_t trusty_ta_encryption_key_is_written(uint8_t *value);
uint32_t trusty_write_oem_encrypt_data(uint32_t *buf, uint32_t length);
uint32_t trusty_oem_encrypt_data_is_written(uint8_t *value);
uint32_t trusty_check_security_level_flag(uint8_t flag);
uint32_t trusty_write_oem_huk(uint32_t *buf, uint32_t length);
uint32_t trusty_read_permanent_attributes_flag(uint8_t *attributes);
uint32_t trusty_write_permanent_attributes_flag(uint8_t attributes);
uint32_t trusty_write_oem_ns_otp(uint32_t byte_off, uint8_t *byte_buf, uint32_t byte_len);
uint32_t trusty_read_oem_ns_otp(uint32_t byte_off, uint8_t *byte_buf, uint32_t byte_len);
uint32_t trusty_write_oem_otp_key(enum RK_OEM_OTP_KEYID key_id,
uint8_t *byte_buf, uint32_t byte_len);
uint32_t trusty_oem_otp_key_is_written(enum RK_OEM_OTP_KEYID key_id, uint8_t *value);
uint32_t trusty_set_oem_hr_otp_read_lock(enum RK_OEM_OTP_KEYID key_id);
uint32_t trusty_oem_otp_key_cipher(enum RK_OEM_OTP_KEYID key_id, rk_cipher_config *config,
uint32_t src_phys_addr, uint32_t dst_phys_addr,
uint32_t len);
uint32_t trusty_oem_user_ta_transfer(void);
uint32_t trusty_oem_user_ta_storage(void);
uint32_t trusty_write_oem_hdcp_key(enum RK_HDCP_KEYID key_id,
uint8_t *byte_buf, uint32_t byte_len);
uint32_t trusty_oem_hdcp_key_is_written(enum RK_HDCP_KEYID key_id, uint8_t *value);
uint32_t trusty_set_oem_hdcp_key_mask(enum RK_HDCP_KEYID key_id);
uint32_t trusty_attest_dh(uint8_t *dh, uint32_t *dh_size);
uint32_t trusty_attest_uuid(uint8_t *uuid, uint32_t *uuid_size);
uint32_t trusty_attest_get_ca
(uint8_t *operation_start, uint32_t *operation_size,
uint8_t *out, uint32_t *out_len);
uint32_t trusty_attest_set_ca(uint8_t *ca_response, uint32_t *ca_response_size);
#endif