blob: 7bb8a866c120cbccc6c539adfe931d0011b4e292 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#ifndef H_TE200_CIPHER_OPTEE_H
2#define H_TE200_CIPHER_OPTEE_H
3
4#define OPTEE_AES_ACCESS_UUID \
5 { \
6 0xba1b496f, 0xf07d, 0x466e, \
7 { 0x99, 0x09, 0xeb, 0xe3, 0x55, 0x43, 0xa0, 0x1c } \
8 }
9
10/*
11 * AES ECB encrypt/decrypt data with HWKEY(RKEK)
12 *
13 * [in] params[0].memref.buffer plain/cipher text to encrypt/decrypt
14 * [in] params[0].memref.size length of plain/cipher text
15 * [out] pParams[1].memref.buffer cipher/plain text after encrypt/decrypt
16 * [in] pParams[2].value.a keysize
17 * [in] pParams[2].value.b op_mode: 1--encrypt, 0--decrypt
18 */
19#define CMD_AES_HWKEY_ECB 0x1
20
21/*
22 * AES CBC encrypt/decrypt data with HWKEY(RKEK)
23 *
24 * [in] params[0].memref.buffer plain/cipher text to encrypt/decrypt
25 * [in] params[0].memref.size length of plain/cipher text
26 * [out] pParams[1].memref.buffer cipher/plain text after encrypt/decrypt
27 * [in] pParams[2].value.a keysize
28 * [in] pParams[2].value.b op_mode: 1--encrypt, 0--decrypt
29 * [in] pParams[3].memref.buffer initial vector
30 */
31#define CMD_AES_HWKEY_CBC 0x2
32
33
34/*
35 * Check AES RKEK status
36 * 0: RKEK(hwkey) is not burned
37 * 1: RKEK(hwkey) is burned and software access is disabled
38 * 2: RKEK(hwkey) is burned but software access is not disabled)
39 *
40 * [out] pParams[0].value.a status
41 */
42#define CMD_AES_HWKEY_STATUS 0x3
43
44/*
45 * AES ECB encrypt/decrypt data with input key
46 *
47 * [in] params[0].memref.buffer plain/cipher text to encrypt/decrypt
48 * [in] params[0].memref.size length of plain/cipher text
49 * [out] pParams[1].memref.buffer cipher/plain text after encrypt/decrypt
50 * [in] pParams[2].value.a op_mode: 1--encrypt, 0--decrypt
51 * [in] pParams[3].memref.buffer input key
52 * [in] pParams[3].memref.size keysize
53 */
54#define CMD_AES_ECB 0x4
55
56/*
57 * AES CBC encrypt/decrypt data with input key
58 *
59 * [in] params[0].memref.buffer plain/cipher text to encrypt/decrypt
60 * [in] params[0].memref.size length of plain/cipher text
61 * [out] pParams[1].memref.buffer cipher/plain text after encrypt/decrypt
62 * [in] pParams[2].value.a op_mode: 1--encrypt, 0--decrypt
63 * [in] pParams[2].value.b keysize
64 * [in] pParams[3].memref.buffer input key + initial vector
65 * [in] pParams[3].memref.size keysize + ivsize
66 */
67#define CMD_AES_CBC 0x5
68
69int aes_ecb_encrypt_optee(uint8_t *key, uint32_t key_len, bool use_rkek,
70 void *in, void *out, uint32_t size);
71int aes_ecb_decrypt_optee(uint8_t *key, uint32_t key_len, bool use_rkek,
72 void *in, void *out, uint32_t size);
73int aes_cbc_encrypt_optee(uint8_t *iv, uint8_t *key, uint32_t key_len,
74 bool use_rkek, void *in, void *out, uint32_t size);
75int aes_cbc_decrypt_optee(uint8_t *iv, uint8_t *key, uint32_t key_len,
76 bool use_rkek, void *in, void *out, uint32_t size);
77
78#endif