Skip to content
Snippets Groups Projects
Commit 5f394d89 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski
Browse files

initial check in of sources

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski>
parents
No related branches found
No related tags found
No related merge requests found
COPYING 0 → 100644
MIT License
Copyright (c) [year] [fullname]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
/**
* Copyright (c) 2023 Qualcomm Technologies, Inc. All Rights Reserved.
* Qualcomm Technologies Proprietary and Confidential.
*/
/*
* IQceTest - Interface for QCE test framework
*/
#pragma once
// AUTOGENERATED FILE: DO NOT EDIT
#include <stdint.h>
#include "object.h"
#define KEY_LEN_128 UINT32_C(16)
#define KEY_LEN_192 UINT32_C(24)
#define KEY_LEN_256 UINT32_C(32)
#define KEY_LEN_128_BITS UINT32_C(128)
#define KEY_LEN_192_BITS UINT32_C(192)
#define KEY_LEN_256_BITS UINT32_C(256)
typedef struct {
uint8_t key[32];
uint64_t key_len;
uint64_t timer;
uint32_t pause_sensitive;
uint32_t algo_mode;
uint32_t ops_allowed;
uint32_t pipe;
} IQceTest_key_params;
typedef struct {
uint8_t tag[16];
} IQceTest_auth_tag;
typedef struct {
uint8_t iv[32];
uint64_t in_smmu_va;
uint64_t out_smmu_va;
uint32_t in_size;
uint32_t out_size;
uint32_t block_offset;
uint32_t pattern_size;
uint32_t pattern_data;
uint32_t pattern_offset;
uint32_t iv_size;
uint32_t iv_ctr_size;
uint32_t op;
uint32_t reserved;
} IQceTest_data_params;
#define IQceTest_ALGO_MODE_AES_CBC UINT32_C(1)
#define IQceTest_ALGO_MODE_AES_CTR UINT32_C(2)
#define IQceTest_ALGO_MODE_AES_GCM UINT32_C(3)
#define IQceTest_PIPE_OFFLOAD_HLOS_HLOS UINT32_C(1)
#define IQceTest_PIPE_OFFLOAD_HLOS_CPB UINT32_C(2)
#define IQceTest_PIPE_OFFLOAD_CPB_HLOS UINT32_C(3)
#define IQceTest_PIPE_TZ_HLOS_HLOS UINT32_C(4)
#define IQceTest_PIPE_TZ_HLOS_CPB UINT32_C(5)
#define IQceTest_PIPE_TZ_CPB_HLOS UINT32_C(6)
#define IQceTest_OPERATION_ENCRYPT_ALLOWED UINT32_C(1)
#define IQceTest_OPERATION_DECRYPT_ALLOWED UINT32_C(2)
#define IQceTest_OPERATION_ENCRYPT UINT32_C(1)
#define IQceTest_OPERATION_DECRYPT UINT32_C(2)
#define IQceTest_OP_set_key 0
#define IQceTest_OP_set_pause 1
#define IQceTest_OP_set_timer 2
#define IQceTest_OP_tz_decrypt 3
#define IQceTest_OP_tz_auth_decrypt 4
#define IQceTest_OP_tz_auth_encrypt 5
static inline int32_t
IQceTest_release(Object self)
{
return Object_invoke(self, Object_OP_release, 0, 0);
}
static inline int32_t
IQceTest_retain(Object self)
{
return Object_invoke(self, Object_OP_retain, 0, 0);
}
static inline int32_t
IQceTest_set_key(Object self, const IQceTest_key_params *params_ptr)
{
ObjectArg a[1]={{{0,0}}};
a[0].bi = (ObjectBufIn) { params_ptr, sizeof(IQceTest_key_params) };
return Object_invoke(self, IQceTest_OP_set_key, a, ObjectCounts_pack(1, 0, 0, 0));
}
static inline int32_t
IQceTest_set_pause(Object self, uint32_t pause_val, uint32_t pipe_val)
{
ObjectArg a[1]={{{0,0}}};
struct {
uint32_t m_pause;
uint32_t m_pipe;
} i = {0, 0};
a[0].b = (ObjectBuf) { &i, 8 };
i.m_pause = pause_val;
i.m_pipe = pipe_val;
return Object_invoke(self, IQceTest_OP_set_pause, a, ObjectCounts_pack(1, 0, 0, 0));
}
static inline int32_t
IQceTest_set_timer(Object self, uint64_t us_val, uint32_t pipe_val)
{
ObjectArg a[1]={{{0,0}}};
struct {
uint64_t m_us;
uint32_t m_pipe;
} i = {0, 0};
a[0].b = (ObjectBuf) { &i, 12 };
i.m_us = us_val;
i.m_pipe = pipe_val;
return Object_invoke(self, IQceTest_OP_set_timer, a, ObjectCounts_pack(1, 0, 0, 0));
}
static inline int32_t
IQceTest_tz_decrypt(Object self, const IQceTest_key_params *key_params_ptr, const IQceTest_data_params *data_params_ptr)
{
ObjectArg a[2]={{{0,0}}};
a[0].bi = (ObjectBufIn) { key_params_ptr, sizeof(IQceTest_key_params) };
a[1].bi = (ObjectBufIn) { data_params_ptr, sizeof(IQceTest_data_params) };
return Object_invoke(self, IQceTest_OP_tz_decrypt, a, ObjectCounts_pack(2, 0, 0, 0));
}
static inline int32_t
IQceTest_tz_auth_decrypt(Object self, const IQceTest_key_params *key_params_ptr, const IQceTest_data_params *data_params_ptr, const IQceTest_auth_tag *tag_ptr, const void *ibuf_ptr, size_t ibuf_len, void *obuf_ptr, size_t obuf_len, size_t *obuf_lenout)
{
ObjectArg a[5]={{{0,0}}};
a[0].bi = (ObjectBufIn) { key_params_ptr, sizeof(IQceTest_key_params) };
a[1].bi = (ObjectBufIn) { data_params_ptr, sizeof(IQceTest_data_params) };
a[2].bi = (ObjectBufIn) { tag_ptr, sizeof(IQceTest_auth_tag) };
a[3].bi = (ObjectBufIn) { ibuf_ptr, ibuf_len * 1 };
a[4].b = (ObjectBuf) { obuf_ptr, obuf_len * 1 };
int32_t result = Object_invoke(self, IQceTest_OP_tz_auth_decrypt, a, ObjectCounts_pack(4, 1, 0, 0));
*obuf_lenout = a[4].b.size / 1;
return result;
}
static inline int32_t
IQceTest_tz_auth_encrypt(Object self, const IQceTest_key_params *key_params_ptr, const IQceTest_data_params *data_params_ptr, IQceTest_auth_tag *tag_ptr, const void *ibuf_ptr, size_t ibuf_len, void *obuf_ptr, size_t obuf_len, size_t *obuf_lenout)
{
ObjectArg a[5]={{{0,0}}};
a[0].bi = (ObjectBufIn) { key_params_ptr, sizeof(IQceTest_key_params) };
a[1].bi = (ObjectBufIn) { data_params_ptr, sizeof(IQceTest_data_params) };
a[3].b = (ObjectBuf) { tag_ptr, sizeof(IQceTest_auth_tag) };
a[2].bi = (ObjectBufIn) { ibuf_ptr, ibuf_len * 1 };
a[4].b = (ObjectBuf) { obuf_ptr, obuf_len * 1 };
int32_t result = Object_invoke(self, IQceTest_OP_tz_auth_encrypt, a, ObjectCounts_pack(3, 2, 0, 0));
*obuf_lenout = a[4].b.size / 1;
return result;
}
This diff is collapsed.
#include <gtest/gtest.h>
#include <stdint.h>
#include <unistd.h>
#include <vector>
#include "IQceTest.h"
#include <linux/qcedev.h>
#include "object.h"
#include "trusted_app_loader.h"
typedef struct {
uint8_t* cpu_va;
uint64_t crypto_smmu_va;
int fd;
} data_buf_t;
typedef struct {
std::vector<uint8_t> iv;
std::vector<uint8_t> tag;
uint32_t key_size;
data_buf_t* input;
data_buf_t* output;
enum qcedev_cipher_alg_enum algo;
enum qcedev_cipher_mode_enum mode;
enum qcedev_offload_oper_enum offload_op;
uint32_t iv_ctr_size;
uint32_t data_len;
bool is_copy_op;
bool encrypt;
uint32_t byteoffset;
uint8_t block_offset;
uint8_t pattern_sz;
uint8_t pattern_proc_data_sz;
uint8_t pattern_offset;
} crypt_params_t;
class QceTest : public ::testing::Test {
protected:
bool Alloc(size_t buf_size);
bool DoCrypt(crypt_params_t crypt, int* result);
bool DoTzCrypt(IQceTest_key_params params, crypt_params_t crypt);
bool SetKey(const IQceTest_key_params* params);
bool SetTimer(const IQceTest_key_params* params);
bool SetPause(const IQceTest_key_params* params, uint32_t pause);
bool GetCipherText(const std::vector<uint8_t>& key, const std::vector<uint8_t>& iv,
const std::vector<uint8_t>& plaintext, std::vector<uint8_t>& ciphertext);
bool GetCipherText(const std::vector<uint8_t>& key, const std::vector<uint8_t>& iv,
const std::vector<uint8_t>& plaintext, std::vector<uint8_t>& ciphertext,
std::vector<uint8_t>& tag);
void CryptAvg(bool enc, bool hlos, bool cbc, std::vector<size_t> data_size, size_t iters,
std::vector<uint32_t> &results);
int OpenTA();
int CloseTA();
void SetUp() override;
void TearDown() override;
std::shared_ptr<TrustedAppLoader> app_loader;
Object qce_test_app_obj;
IQceTest_key_params key_params;
IQceTest_auth_tag auth_tag;
data_buf_t in_buf;
data_buf_t out_buf;
crypt_params_t crypt;
size_t buf_size;
int qce_fd;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment