void TEE_DeriveKey(TEE_OperationHandle operation, const TEE_Attribute *params, uint32_t paramCount, TEE_ObjectHandle derivedKey) { TEE_Result res; TEE_ObjectInfo key_info; if (operation == TEE_HANDLE_NULL || derivedKey == 0) TEE_Panic(0); if (paramCount != 0 && params == NULL) TEE_Panic(0); if (operation->info.algorithm != TEE_ALG_DH_DERIVE_SHARED_SECRET) TEE_Panic(0); if (operation->info.operationClass != TEE_OPERATION_KEY_DERIVATION) TEE_Panic(0); if (operation->info.mode != TEE_MODE_DERIVE) TEE_Panic(0); if ((operation->info.handleState & TEE_HANDLE_FLAG_KEY_SET) == 0) TEE_Panic(0); res = utee_cryp_obj_get_info((uint32_t) derivedKey, &key_info); if (res != TEE_SUCCESS) TEE_Panic(0); if (key_info.objectType != TEE_TYPE_GENERIC_SECRET) TEE_Panic(0); if ((key_info.handleFlags & TEE_HANDLE_FLAG_INITIALIZED) != 0) TEE_Panic(0); if ((operation->info.algorithm == TEE_ALG_DH_DERIVE_SHARED_SECRET) && (paramCount != 1 || params[0].attributeID != TEE_ATTR_DH_PUBLIC_VALUE)) TEE_Panic(0); res = utee_cryp_derive_key(operation->state, params, paramCount, (uint32_t) derivedKey); if (res != TEE_SUCCESS) TEE_Panic(res); }
void TEE_DeriveKey(TEE_OperationHandle operation, const TEE_Attribute *params, uint32_t paramCount, TEE_ObjectHandle derivedKey) { TEE_Result res; TEE_ObjectInfo key_info; struct utee_attribute ua[paramCount]; if (operation == TEE_HANDLE_NULL || derivedKey == 0) TEE_Panic(0); if (params == NULL && paramCount != 0) TEE_Panic(0); if (TEE_ALG_GET_CLASS(operation->info.algorithm) != TEE_OPERATION_KEY_DERIVATION) TEE_Panic(0); if (operation->info.operationClass != TEE_OPERATION_KEY_DERIVATION) TEE_Panic(0); if (!operation->key1) TEE_Panic(0); if (operation->info.mode != TEE_MODE_DERIVE) TEE_Panic(0); if ((operation->info.handleState & TEE_HANDLE_FLAG_KEY_SET) == 0) TEE_Panic(0); res = utee_cryp_obj_get_info((unsigned long)derivedKey, &key_info); if (res != TEE_SUCCESS) TEE_Panic(0); if (key_info.objectType != TEE_TYPE_GENERIC_SECRET) TEE_Panic(0); if ((key_info.handleFlags & TEE_HANDLE_FLAG_INITIALIZED) != 0) TEE_Panic(0); __utee_from_attr(ua, params, paramCount); res = utee_cryp_derive_key(operation->state, ua, paramCount, (unsigned long)derivedKey); if (res != TEE_SUCCESS) TEE_Panic(res); }