* Copyright (c) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"),
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* @addtogroup TeeTrusted
* @{
*
* @brief TEE(Trusted Excution Environment) API.
* Provides security capability APIs such as trusted storage, encryption and decryption,
* and trusted time for trusted application development.
*
* @since 20
*/
* @file tee_crypto_api.h
*
* @brief Provides APIs for cryptographic operations.
*
* You can use these APIs to implement encryption and decryption.
*
* @library NA
* @kit TEEKit
* @syscap SystemCapability.Tee.TeeClient
* @since 20
*/
#ifndef TEE_CRYPTO_API_H
#define TEE_CRYPTO_API_H
#include <pthread.h>
#include "tee_defines.h"
#include "tee_mem_mgmt_api.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef NULL
* @brief Definition of <b>NULL</b>.
*
* @since 20
*/
#define NULL ((void *)0)
#endif
* @brief Defines the maximum key length, in bits.
*
* @since 20
*/
#define TEE_MAX_KEY_SIZE_IN_BITS (1024 * 8)
* @brief Defines the length of the SW_RSA key, in bytes.
*
* @since 20
*/
#define SW_RSA_KEYLEN 1024
* @brief Defines the maximum length of other Diffie-Hellman (DH) information, in bytes.
*
* @since 20
*/
#define TEE_DH_MAX_SIZE_OF_OTHER_INFO 64
* @brief Defines the maximum parameter count.
*
* @since 20
*/
#define TEE_PARAM_COUNT_MAX 9
* @brief Enumerates the cryptographic operation handles.
*
* @since 20
*/
enum __TEE_Operation_Constants {
TEE_OPERATION_CIPHER = 0x1,
TEE_OPERATION_MAC = 3,
TEE_OPERATION_AE = 4,
TEE_OPERATION_DIGEST = 5,
TEE_OPERATION_ASYMMETRIC_CIPHER = 6,
TEE_OPERATION_ASYMMETRIC_SIGNATURE = 7,
TEE_OPERATION_KEY_DERIVATION = 8,
TEE_OPERATION_KDF_KEY_DERIVATION = 9,
};
* @brief Enumerates the cryptographic algorithms.
*
* @since 20
*/
enum __tee_crypto_algorithm_id {
TEE_ALG_INVALID = 0x0,
TEE_ALG_AES_ECB_NOPAD = 0x10000010,
TEE_ALG_AES_CBC_NOPAD = 0x10000110,
TEE_ALG_AES_CTR = 0x10000210,
TEE_ALG_AES_CTS = 0x10000310,
TEE_ALG_AES_XTS = 0x10000410,
TEE_ALG_AES_CBC_MAC_NOPAD = 0x30000110,
TEE_ALG_AES_CBC_MAC_PKCS5 = 0x30000510,
TEE_ALG_AES_CMAC = 0x30000610,
TEE_ALG_AES_GMAC = 0x30000810,
TEE_ALG_AES_CCM = 0x40000710,
TEE_ALG_AES_GCM = 0x40000810,
TEE_ALG_DES_ECB_NOPAD = 0x10000011,
TEE_ALG_DES_CBC_NOPAD = 0x10000111,
TEE_ALG_DES_CBC_MAC_NOPAD = 0x30000111,
TEE_ALG_DES_CBC_MAC_PKCS5 = 0x30000511,
TEE_ALG_DES3_ECB_NOPAD = 0x10000013,
TEE_ALG_DES3_CBC_NOPAD = 0x10000113,
TEE_ALG_DES3_CBC_MAC_NOPAD = 0x30000113,
TEE_ALG_DES3_CBC_MAC_PKCS5 = 0x30000513,
TEE_ALG_RSASSA_PKCS1_V1_5_MD5 = 0x70001830,
TEE_ALG_RSASSA_PKCS1_V1_5_SHA1 = 0x70002830,
TEE_ALG_RSASSA_PKCS1_V1_5_SHA224 = 0x70003830,
TEE_ALG_RSASSA_PKCS1_V1_5_SHA256 = 0x70004830,
TEE_ALG_RSASSA_PKCS1_V1_5_SHA384 = 0x70005830,
TEE_ALG_RSASSA_PKCS1_V1_5_SHA512 = 0x70006830,
TEE_ALG_RSASSA_PKCS1_V1_5_SM3 = 0xF0007830,
TEE_ALG_RSASSA_PKCS1_V1_5_MD5_SHA1 = 0xF0008830,
TEE_ALG_RSASSA_PKCS1_PSS_MGF1_MD5 = 0x70111930,
TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA1 = 0x70212930,
TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA224 = 0x70313930,
TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256 = 0x70414930,
TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA384 = 0x70515930,
TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA512 = 0x70616930,
TEE_ALG_RSAES_PKCS1_V1_5 = 0x60000130,
TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA1 = 0x60210230,
TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA224 = 0x60211230,
TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256 = 0x60212230,
TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA384 = 0x60213230,
TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512 = 0x60214230,
TEE_ALG_RSA_NOPAD = 0x60000030,
TEE_ALG_DSA_SHA1 = 0x70002131,
TEE_ALG_DSA_SHA224 = 0x70003131,
TEE_ALG_DSA_SHA256 = 0x70004131,
TEE_ALG_DH_DERIVE_SHARED_SECRET = 0x80000032,
TEE_ALG_MD5 = 0x50000001,
TEE_ALG_SHA1 = 0x50000002,
TEE_ALG_SHA224 = 0x50000003,
TEE_ALG_SHA256 = 0x50000004,
TEE_ALG_SHA384 = 0x50000005,
TEE_ALG_SHA512 = 0x50000006,
TEE_ALG_HMAC_MD5 = 0x30000001,
TEE_ALG_HMAC_SHA1 = 0x30000002,
TEE_ALG_HMAC_SHA224 = 0x30000003,
TEE_ALG_HMAC_SHA256 = 0x30000004,
TEE_ALG_HMAC_SHA384 = 0x30000005,
TEE_ALG_HMAC_SHA512 = 0x30000006,
TEE_ALG_HMAC_SM3 = 0x30000007,
TEE_ALG_AES_ECB_PKCS5 = 0x10000020,
TEE_ALG_AES_CBC_PKCS5 = 0x10000220,
TEE_ALG_AES_CBC_ISO_PADDING = 0x10000330,
TEE_ALG_ECDSA_SHA1 = 0x70001042,
TEE_ALG_ECDSA_SHA224 = 0x70002042,
TEE_ALG_ECDSA_SHA256 = 0x70003042,
TEE_ALG_ECDSA_SHA384 = 0x70004042,
TEE_ALG_ECDSA_SHA512 = 0x70005042,
TEE_ALG_ED25519 = 0x70005043,
TEE_ALG_ECDH_DERIVE_SHARED_SECRET = 0x80000042,
TEE_ALG_X25519 = 0x80000044,
TEE_ALG_ECC = 0x80000001,
TEE_ALG_ECDSA_P192 = 0x70001042,
TEE_ALG_ECDSA_P224 = 0x70002042,
TEE_ALG_ECDSA_P256 = 0x70003042,
TEE_ALG_ECDSA_P384 = 0x70004042,
TEE_ALG_ECDSA_P521 = 0x70005042,
TEE_ALG_ECDH_P192 = 0x80001042,
TEE_ALG_ECDH_P224 = 0x80002042,
TEE_ALG_ECDH_P256 = 0x80003042,
TEE_ALG_ECDH_P384 = 0x80004042,
TEE_ALG_ECDH_P521 = 0x80005042,
TEE_ALG_SIP_HASH = 0xF0000002,
TEE_ALG_SM2_DSA_SM3 = 0x70006045,
TEE_ALG_SM2_PKE = 0x80000045,
TEE_ALG_SM3 = 0x50000007,
TEE_ALG_SM4_ECB_NOPAD = 0x10000014,
TEE_ALG_SM4_ECB_PKCS7 = 0x10000024,
TEE_ALG_SM4_CBC_NOPAD = 0x10000114,
TEE_ALG_SM4_CBC_PKCS7 = 0xF0000003,
TEE_ALG_SM4_CTR = 0x10000214,
TEE_ALG_SM4_CFB128 = 0xF0000000,
TEE_ALG_SM4_XTS = 0x10000414,
TEE_ALG_SM4_OFB = 0x10000514,
TEE_ALG_AES_OFB = 0x10000510,
TEE_ALG_AES_CFB128 = 0xF0000610,
TEE_ALG_SM4_GCM = 0xF0000005,
TEE_ALG_PBKDF2_HMAC_SHA1_DERIVE_KEY = 0x800020C2,
TEE_ALG_PBKDF2_HMAC_SHA256_DERIVE_KEY = 0x800040C2,
TEE_ALG_PBKDF2_HMAC_SHA384_DERIVE_KEY = 0x800050C2,
TEE_ALG_PBKDF2_HMAC_SHA512_DERIVE_KEY = 0x800060C2,
TEE_ALG_HKDF = 0x80000047,
TEE_ALG_PRF = 0xF0000006,
};
* @brief Defines the <b>__tee_crypto_algorithm_id</b> struct.
*
* @see __tee_crypto_algorithm_id
*
* @since 20
*/
typedef enum __tee_crypto_algorithm_id tee_crypto_algorithm_id;
* @brief No element is available.
*
* @since 20
*/
#define TEE_OPTIONAL_ELEMENT_NONE 0x00000000
* @brief Enumerates the Elliptic-Curve Cryptography (ECC) curves supported.
*
* @since 20
*/
typedef enum {
TEE_ECC_CURVE_NIST_P192 = 0x00000001,
TEE_ECC_CURVE_NIST_P224 = 0x00000002,
TEE_ECC_CURVE_NIST_P256 = 0x00000003,
TEE_ECC_CURVE_NIST_P384 = 0x00000004,
TEE_ECC_CURVE_NIST_P521 = 0x00000005,
TEE_ECC_CURVE_SM2 = 0x00000300,
TEE_ECC_CURVE_25519 = 0x00000200,
} TEE_ECC_CURVE;
* @brief Enumerates the Mask Generation Function (MGF1) modes.
*
* @since 20
*/
typedef enum {
TEE_DH_HASH_SHA1_mode = 0,
TEE_DH_HASH_SHA224_mode = 1,
TEE_DH_HASH_SHA256_mode = 2,
TEE_DH_HASH_SHA384_mode = 3,
TEE_DH_HASH_SHA512_mode = 4,
TEE_DH_HASH_NumOfModes,
} TEE_DH_HASH_Mode;
* @brief Enumerates the Diffie-Hellman operation modes.
*
* @since 20
*/
typedef enum {
TEE_DH_PKCS3_mode = 0,
TEE_DH_ANSI_X942_mode = 1,
TEE_DH_NumOfModes,
} TEE_DH_OpMode_t;
* @brief Defines an enum for TEE_DH_DerivFuncMode.
*
* @since 20
*/
typedef enum {
TEE_DH_ASN1_DerivMode = 0,
TEE_DH_ConcatDerivMode = 1,
TEE_DH_X963_DerivMode = TEE_DH_ConcatDerivMode,
TEE_DH_OMADRM_DerivMode = 2,
TEE_DH_ISO18033_KDF1_DerivMode = 3,
TEE_DH_ISO18033_KDF2_DerivMode = 4,
TEE_DH_DerivFunc_NumOfModes,
} TEE_DH_DerivFuncMode;
* @brief Enumerates the object attributes for cryptographic operations.
*
* @since 20
*/
enum __TEE_DK_ObjectAttribute {
TEE_DK_SECRECT = 0,
TEE_DK_OTHER,
TEE_DK_HASH_MODE,
TEE_DK_DERIVATION_MODE
};
* @brief Defines a struct for __TEE_DK_ObjectAttribute.
*
* @see __TEE_DK_ObjectAttribute
*
* @since 20
*/
typedef enum __TEE_DK_ObjectAttribute tee_dk_objectattribute;
* @brief Enumerates the cryptographic operation modes.
*
* @since 20
*/
enum __TEE_OperationMode {
TEE_MODE_ENCRYPT = 0x0,
TEE_MODE_DECRYPT,
TEE_MODE_SIGN,
TEE_MODE_VERIFY,
TEE_MODE_MAC,
TEE_MODE_DIGEST,
TEE_MODE_DERIVE
};
* @brief Enumerates the cryptographic operation states.
*
* @since 20
*/
enum tee_operation_state {
TEE_OPERATION_STATE_INITIAL = 0x00000000,
TEE_OPERATION_STATE_ACTIVE = 0x00000001,
};
* @brief Defines the mode for cryptographic operations.
*
* @since 20
*/
typedef uint32_t TEE_OperationMode;
* @brief Defines a struct for TEE_DH_OtherInfo.
*
* @since 20
*/
typedef struct {
uint8_t algorithm_id[TEE_DH_MAX_SIZE_OF_OTHER_INFO];
uint32_t size_of_algorithm_id;
uint8_t party_u_info[TEE_DH_MAX_SIZE_OF_OTHER_INFO];
uint32_t size_of_party_u_info;
uint8_t party_v_info[TEE_DH_MAX_SIZE_OF_OTHER_INFO];
uint32_t size_of_party_v_info;
uint8_t supp_priv_info[TEE_DH_MAX_SIZE_OF_OTHER_INFO];
uint32_t size_of_supp_priv_info;
uint8_t supp_pub_info[TEE_DH_MAX_SIZE_OF_OTHER_INFO];
uint32_t size_of_supp_pub_info;
} TEE_DH_OtherInfo;
* @brief Defines the operation information.
*
* @since 20
*/
struct __TEE_OperationInfo {
uint32_t algorithm;
uint32_t operationClass;
uint32_t mode;
uint32_t digestLength;
uint32_t maxKeySize;
uint32_t keySize;
uint32_t requiredKeyUsage;
uint32_t handleState;
void *keyValue;
};
* @brief Defines a struct for __TEE_OperationInfo.
*
* @see __TEE_OperationInfo
*
* @since 20
*/
typedef struct __TEE_OperationInfo TEE_OperationInfo;
* @brief Defines the key information stored in the <b>OperationInfo</b>.
*
* @since 20
*/
typedef struct {
uint32_t keySize;
uint32_t requiredKeyUsage;
} TEE_OperationInfoKey;
* @brief Defines information about an operation.
*
* @since 20
*/
typedef struct {
uint32_t algorithm;
uint32_t operationClass;
uint32_t mode;
uint32_t digestLength;
uint32_t maxKeySize;
uint32_t handleState;
uint32_t operationState;
uint32_t numberOfKeys;
TEE_OperationInfoKey keyInformation[];
} TEE_OperationInfoMultiple;
* @brief Defines the cryptographic operation handle.
*
* @since 20
*/
struct __TEE_OperationHandle {
uint32_t algorithm;
uint32_t operationClass;
uint32_t mode;
uint32_t digestLength;
uint32_t maxKeySize;
uint32_t keySize;
uint32_t keySize2;
uint32_t requiredKeyUsage;
uint32_t handleState;
void *keyValue;
void *keyValue2;
void *crypto_ctxt;
void *hmac_rest_ctext;
void *IV;
void *publicKey;
uint32_t publicKeyLen;
void *privateKey;
uint32_t privateKeyLen;
uint32_t IVLen;
TEE_DH_OtherInfo *dh_otherinfo;
uint32_t dh_hash_mode;
uint32_t dh_derive_func;
uint32_t dh_op_mode;
void *dh_prime;
uint32_t dh_prime_size;
pthread_mutex_t operation_lock;
void *hal_info;
};
* @brief Defines the data used for conversion of integers.
*
* @since 20
*/
typedef struct {
uint32_t src;
uint32_t dest;
} crypto_uint2uint;
* @brief Defines the maximum length of an RSA public key.
*
* @since 20
*/
#define RSA_PUBKEY_MAXSIZE sizeof(CRYS_RSAUserPubKey_t)
* @brief Defines the maximum length of an RES private key.
*
* @since 20
*/
#define RSA_PRIVKEY_MAXSIZE sizeof(CRYS_RSAUserPrivKey_t)
* @brief Defines a structure to hold the input and output data.
*
* @since 20
*/
typedef struct {
void *src_data;
size_t src_len;
void *dest_data;
size_t *dest_len;
} operation_src_dest;
* @brief Defines the AE initialization data.
*
* @since 20
*/
typedef struct {
void *nonce;
size_t nonce_len;
uint32_t tag_len;
size_t aad_len;
size_t payload_len;
} operation_ae_init;
* @brief Defines the <b>__TEE_OperationHandle</b> struct.
*
* @see __TEE_OperationHandle
*
* @since 20
*/
typedef struct __TEE_OperationHandle TEE_OperationHandleVar;
* @brief Defines the <b>__TEE_ObjectHandle</b> struct.
*
* @since 20
*/
typedef struct __TEE_ObjectHandle TEE_ObjectHandleVar;
* @brief Allocates an operation handle.
*
* @param operation Indicates the pointer to the operation handle.
* @param algorithm Indicates the cipher algorithm.
* @param mode Indicates the operation mode.
* @param maxKeySize Indicates the maximum length of the key.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation handle is allocated.
* Returns <b>TEE_ERROR_OUT_OF_MEMORY</b> if there is no enough memory for this operation.
* Returns <b>TEE_ERROR_NOT_SUPPORTED</b> if the specified algorithm is not supported.
* Returns <b>TEE_ERROR_GENERIC</b> if the operation fails due to other errors.
*
* @since 20
*/
TEE_Result TEE_AllocateOperation(TEE_OperationHandle *operation, uint32_t algorithm, uint32_t mode,
uint32_t maxKeySize);
* @brief Releases an operation handle.
*
* @param operation Indicates the operation handle to release.
*
* @since 20
*/
void TEE_FreeOperation(TEE_OperationHandle operation);
* @brief Obtains operation information.
*
* @param operation Indicates the operation handle.
* @param operationInfo Indicates the pointer to the operation information.
*
* @since 20
*/
void TEE_GetOperationInfo(const TEE_OperationHandle operation, TEE_OperationInfo *operationInfo);
* @brief Resets an operation handle.
*
* @param operation Indicates the operation handle to reset.
*
* @since 20
*/
void TEE_ResetOperation(TEE_OperationHandle operation);
* @brief Sets the key for an operation.
*
* @param operation Indicates the operation handle.
* @param key Indicates the key.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_BAD_PARAMETERS</b> if the operation fails due to invalid parameters.
* Returns <b>TEE_ERROR_OUT_OF_MEMORY</b> if there is no enough memory for this operation.
*
* @since 20
*/
TEE_Result TEE_SetOperationKey(TEE_OperationHandle operation, const TEE_ObjectHandle key);
* @brief Sets two keys for an operation.
*
* @param operation Indicates the operation handle.
* @param key1 Indicates key 1.
* @param key2 Indicates key 2.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_BAD_PARAMETERS</b> if the operation fails due to invalid parameters.
*
* @since 20
*/
TEE_Result TEE_SetOperationKey2(TEE_OperationHandle operation, const TEE_ObjectHandle key1,
const TEE_ObjectHandle key2);
* @brief Copies an operation handle.
*
* @param dstOperation Indicates the destination operation handle.
* @param srcOperation Indicates the source operation handle.
*
* @since 20
*/
void TEE_CopyOperation(TEE_OperationHandle dstOperation, const TEE_OperationHandle srcOperation);
* @brief Initializes the context to start a cipher operation.
*
* @param operation Indicates the operation handle.
* @param IV Indicates the pointer to the buffer storing the operation IV. If this parameter is not used,
* set it to <b>NULL</b>.
* @param IVLen Indicates the length of the IV buffer.
*
* @since 20
*/
void TEE_CipherInit(TEE_OperationHandle operation, const void *IV, size_t IVLen);
* @brief Updates the data for a cipher operation.
*
* @param operation Indicates the operation handle.
* @param srcData Indicates the pointer to the source data.
* @param srcLen Indicates the length of the source data.
* @param destData Indicates the pointer to the destination data.
* @param destLen Indicates the pointer to the destination data length.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_BAD_PARAMETERS</b> if the operation fails due to invalid parameters.
* Returns <b>TEE_ERROR_GENERIC</b> if the operation fails due to other errors.
*
* @since 20
*/
TEE_Result TEE_CipherUpdate(TEE_OperationHandle operation, const void *srcData, size_t srcLen, void *destData,
size_t *destLen);
* @brief Finalizes a cipher operation.
*
* @param operation Indicates the operation handle.
* @param srcData Indicates the pointer to the source data.
* @param srcLen Indicates the length of the source data.
* @param destData Indicates the pointer to the destination data.
* @param destLen Indicates the pointer to the destination data length.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_BAD_PARAMETERS</b> if the operation fails due to invalid parameters.
* Returns <b>TEE_ERROR_GENERIC</b> if the operation fails due to other errors.
*
* @since 20
*/
TEE_Result TEE_CipherDoFinal(TEE_OperationHandle operation, const void *srcData, size_t srcLen, void *destData,
size_t *destLen);
* @brief Updates the digest.
*
* @param operation Indicates the operation handle.
* @param chunk Indicates the pointer to the chunk of data to be hashed.
* @param chunkSize Indicates the length of the chunk.
*
* @since 20
*/
void TEE_DigestUpdate(TEE_OperationHandle operation, const void *chunk, size_t chunkSize);
* @brief Finalizes the message digest operation.
*
* @param operation Indicates the operation handle.
* @param chunk Indicates the pointer to the chunk of data to be hashed.
* @param chunkLen Indicates the length of the chunk.
* @param hash Indicates the pointer to the buffer storing the message hash.
* @param hashLen
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_SHORT_BUFFER</b> if the operationInfo buffer is not large enough to
* hold the information obtained.
*
* @since 20
*/
TEE_Result TEE_DigestDoFinal(TEE_OperationHandle operation, const void *chunk, size_t chunkLen, void *hash,
size_t *hashLen);
* @brief Initializes a MAC operation.
*
* @param operation Indicates the operation handle.
* @param IV Indicates the pointer to the buffer storing the operation IV. If this parameter is not used,
* set it to <b>NULL</b>.
* @param IVLen Indicates the length of the IV buffer.
*
* @since 20
*/
void TEE_MACInit(TEE_OperationHandle operation, void *IV, size_t IVLen);
* @brief Updates the MAC.
*
* @param operation Indicates the operation handle.
* @param chunk Indicates the pointer to the chunk of MAC data.
* @param chunkSize Indicates the size of the chunk.
*
* @since 20
*/
void TEE_MACUpdate(TEE_OperationHandle operation, const void *chunk, size_t chunkSize);
* @brief MAC Finalizes the MAC operation with a last chunk of message and computes the MAC.
*
* @param operation Indicates the operation handle.
* @param message Indicates the pointer to the buffer containing the last message chunk to MAC.
* @param messageLen Indicates the length of the message buffer.
* @param mac Indicates the pointer to the buffer storing the computed MAC.
* @param macLen Indicates the pointer to the MAC buffer length.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_GENERIC</b> if the operation fails due to other errors.
*
* @since 20
*/
TEE_Result TEE_MACComputeFinal(TEE_OperationHandle operation, const void *message, size_t messageLen, void *mac,
size_t *macLen);
* @brief Finalizes the MAC operation and compares the MAC with the one passed in.
*
* @param operation Indicates the operation handle.
* @param message Indicates the pointer to the buffer containing the last message chunk to MAC.
* @param messageLen Indicates the length of the buffer.
* @param mac Indicates the pointer to the buffer storing the computed MAC.
* @param macLen Indicates the MAC buffer length.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_GENERIC</b> if the operation fails due to other errors.
* Returns <b>TEE_ERROR_MAC_INVALID</b> if the computed MAC is not the same as that passed in.
*
* @since 20
*/
TEE_Result TEE_MACCompareFinal(TEE_OperationHandle operation, const void *message, size_t messageLen, const void *mac,
const size_t macLen);
* @brief Derives a key.
*
* @param operation Indicates the operation handle.
* @param params Indicates the pointer to the parameters for this operation.
* @param paramCount Indicates the number of parameters.
* @param derivedKey Indicates the derived key.
*
* @since 20
*/
void TEE_DeriveKey(TEE_OperationHandle operation, const TEE_Attribute *params, uint32_t paramCount,
TEE_ObjectHandle derivedKey);
* @brief Generates random data.
*
* @param randomBuffer Indicates the pointer to the buffer storing the random data generated.
* @param randomBufferLen Indicates the length of the buffer storing the random data.
*
* @since 20
*/
void TEE_GenerateRandom(void *randomBuffer, size_t randomBufferLen);
* @brief Initializes an AE operation.
*
* @param operation Indicates the operation handle.
* @param nonce Indicates the pointer to the buffer for storing the nonce.
* @param nonceLen Indicates the length of the nonce.
* @param tagLen Indicates the length of the tag.
* @param AADLen Indicates the length of the AAD.
* @param payloadLen Indicates the length of the payload.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_GENERIC</b> if the operation fails due to other errors.
*
* @since 20
*/
TEE_Result TEE_AEInit(TEE_OperationHandle operation, void *nonce, size_t nonceLen, uint32_t tagLen, size_t AADLen,
size_t payloadLen);
* @brief Updates the AAD in an AE operation.
*
* @param operation Indicates the operation handle.
* @param AADdata Indicates the pointer to the new AAD.
* @param AADdataLen Indicates the length of the new AAD.
*
* @since 20
*/
void TEE_AEUpdateAAD(TEE_OperationHandle operation, const void *AADdata, size_t AADdataLen);
* @brief Updates data for an AE operation.
*
* @param operation Indicates the operation handle.
* @param srcData Indicates the pointer to the source data.
* @param srcLen Indicates the length of the source data.
* @param destData Indicates the pointer to the destination data.
* @param destLen Indicates the pointer to the destination data length.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_GENERIC</b> if the operation fails due to other errors.
*
* @since 20
*/
TEE_Result TEE_AEUpdate(TEE_OperationHandle operation, void *srcData, size_t srcLen, void *destData, size_t *destLen);
* @brief Finalizes the AE encryption operation.
*
* @param operation Indicates the operation handle.
* @param srcData Indicates the pointer to the source data.
* @param srcLen Indicates the length of the source data.
* @param destData Indicates the pointer to the destination data.
* @param destLen Indicates the pointer to the destination data length.
* @param tag Indicates the pointer to the buffer storing the computed tag.
* @param tagLen Indicates the pointer to the tag buffer length.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_GENERIC</b> if the operation fails due to other errors.
*
* @since 20
*/
TEE_Result TEE_AEEncryptFinal(TEE_OperationHandle operation, void *srcData, size_t srcLen, void *destData,
size_t *destLen, void *tag, size_t *tagLen);
* @brief Finalizes an AE decryption operation.
*
* @param operation Indicates the operation handle.
* @param srcData Indicates the pointer to the source data.
* @param srcLen Indicates the length of the source data.
* @param destData Indicates the pointer to the destination data.
* @param destLen Indicates the pointer to the destination data length.
* @param tag Indicates the pointer to the buffer storing the computed tag.
* @param tagLen Indicates the tag buffer length.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_MAC_INVALID</b> if the computed tag does not match the provided tag.
*
* @since 20
*/
TEE_Result TEE_AEDecryptFinal(TEE_OperationHandle operation, void *srcData, size_t srcLen, void *destData,
size_t *destLen, void *tag, size_t tagLen);
* @brief Performs asymmetric encryption.
*
* @param operation Indicates the operation handle.
* @param params Indicates the pointer to the parameters for this operation.
* @param paramCount Indicates the number of parameters.
* @param srcData Indicates the pointer to the source data.
* @param srcLen Indicates the length of the source data.
* @param destData Indicates the pointer to the destination data.
* @param destLen Indicates the pointer to the destination data length.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_BAD_PARAMETERS</b> if the operation fails due to invalid parameters.
* Returns <b>TEE_ERROR_GENERIC</b> if the operation fails due to other errors.
*
* @since 20
*/
TEE_Result TEE_AsymmetricEncrypt(TEE_OperationHandle operation, const TEE_Attribute *params, uint32_t paramCount,
void *srcData, size_t srcLen, void *destData, size_t *destLen);
* @brief Performs asymmetric decryption.
*
* @param operation Indicates the operation handle.
* @param params Indicates the pointer to the parameters for this operation.
* @param paramCount Indicates the number of parameters.
* @param srcData Indicates the pointer to the source data.
* @param srcLen Indicates the length of the source data.
* @param destData Indicates the pointer to the destination data.
* @param destLen Indicates the pointer to the destination data length.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_BAD_PARAMETERS</b> if the operation fails due to invalid parameters.
* Returns <b>TEE_ERROR_GENERIC</b> if the operation fails due to other errors.
*
* @since 20
*/
TEE_Result TEE_AsymmetricDecrypt(TEE_OperationHandle operation, const TEE_Attribute *params, uint32_t paramCount,
void *srcData, size_t srcLen, void *destData, size_t *destLen);
* @brief Signs a message digest in an asymmetric operation.
*
* @param operation Indicates the operation handle.
* @param params Indicates the pointer to the parameters for this operation.
* @param paramCount Indicates the number of parameters.
* @param digest Indicates the pointer to the message digest.
* @param digestLen Indicates the digest length.
* @param signature Indicates the pointer to the signature.
* @param signatureLen Indicates the pointer to the signature length.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_BAD_PARAMETERS</b> if the operation fails due to invalid parameters.
* Returns <b>TEE_ERROR_GENERIC</b> if the operation fails due to other errors.
*
* @since 20
*/
TEE_Result TEE_AsymmetricSignDigest(TEE_OperationHandle operation, const TEE_Attribute *params, uint32_t paramCount,
void *digest, size_t digestLen, void *signature, size_t *signatureLen);
* @brief Verifies a message digest signature in an asymmetric operation.
*
* @param operation Indicates the operation handle.
* @param params Indicates the pointer to the parameters for this operation.
* @param paramCount Indicates the number of parameters.
* @param digest Indicates the pointer to the message digest.
* @param digestLen Indicates the digest length.
* @param signature Indicates the pointer to the signature.
* @param signatureLen Indicates the signature length.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_BAD_PARAMETERS</b> if the operation fails due to invalid parameters.
* Returns <b>TEE_ERROR_GENERIC</b> if the operation fails due to other errors.
*
* @since 20
*/
TEE_Result TEE_AsymmetricVerifyDigest(TEE_OperationHandle operation, const TEE_Attribute *params, uint32_t paramCount,
void *digest, size_t digestLen, void *signature, size_t signatureLen);
* @brief Obtains information about the operation involving multiple keys.
*
* @param operation Indicates the operation handle.
* @param operationInfoMultiple Indicates the pointer to the operation information obtained.
* @param operationSize [IN/OUT] Indicates the pointer to the operation information size.
*
* @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
* Returns <b>TEE_ERROR_BAD_PARAMETERS</b> if the operation fails due to invalid parameters.
* Returns <b>TEE_ERROR_SHORT_BUFFER</b> if the operationInfo buffer is not large enough to
* hold the information obtained.
*
* @since 20
*/
TEE_Result TEE_GetOperationInfoMultiple(TEE_OperationHandle operation, TEE_OperationInfoMultiple *operationInfoMultiple,
const size_t *operationSize);
* @brief Checks whether the algorithm is supported.
*
* @param algId Indicates the algorithm to check.
* @param element Indicates the cryptographic element.
*
* @return Returns <b>TEE_SUCCESS</b> if the algorithm is supported.
* Returns <b>TEE_ERROR_NOT_SUPPORTED</b> otherwise.
*
* @since 20
*/
TEE_Result TEE_IsAlgorithmSupported(uint32_t algId, uint32_t element);
#ifdef __cplusplus
}
#endif
#endif