SecurityDataHuks.h 3.5 KB
Newer Older
W
wenjun 已提交
1
/*
M
mamingshuai 已提交
2
 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
W
wenjun 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
 * 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.
 */

#ifndef TEST_XTS_ACTS_SECURITY_LITE_DATAHUKS_POSIX_SRC_SECURITYDATAHUKS_H
#define TEST_XTS_ACTS_SECURITY_LITE_DATAHUKS_POSIX_SRC_SECURITYDATAHUKS_H
#include "hks_client.h"
#include "hks_types.h"
#include <securec.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <hks_file_api.h>
#include "gtest/gtest.h"
#include <stdarg.h>
#include <sys/stat.h>
#include <unistd.h>
#include "hks_errno.h"
#include <sys/time.h>
#include <hks_hardware_api.h>

#define DOUBLE_INT(x) ((x) * 2)
#define DOUBLE_STR_LEN(x) ((x) * 2 + 1)
#define FILE_ERROR -1
#define HICHAIN_FILEPATH "/storage/"
#define HKS_FREE_PTR1(p) { if ((p) != NULL) { free(p); (p) = NULL; }}

constexpr int NUM1 = 1;
constexpr int NUM2 = 2;
constexpr int NUM3 = 3;
constexpr int NUM4 = 4;
constexpr int NUM5 = 5;
constexpr int NUM6 = 6;
constexpr int NUM8 = 8;
constexpr int NUM9 = 9;
constexpr int NUM10 = 10;
constexpr int NUM11 = 11;
M
mamingshuai 已提交
50
constexpr int NUM12 = 12;
W
wenjun 已提交
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
constexpr int NUM15 = 15;
constexpr int NUM16 = 16;
constexpr int NUM20 = 20;
constexpr int NUM30 = 30;
constexpr int NUM21 = 21;
constexpr int NUM24 = 24;
constexpr int NUM32 = 32;
constexpr int NUM60 = 60;
constexpr int NUM62 = 62;
constexpr int NUM64 = 64;
constexpr int NUM65 = 65;
constexpr int NUM88 = 88;
constexpr int NUM100 = 100;
constexpr int NUM128 = 128;
constexpr int NUM192 = 192;
constexpr int NUM256 = 256;
constexpr int NUM1025 = 1025;
M
mamingshuai 已提交
68
constexpr unsigned NUM2048 = 2048;
W
wenjun 已提交
69 70 71 72 73 74 75 76 77 78 79
constexpr int NUM1234567 = 1234567;
constexpr int NUM1000000 = 1000000;
constexpr int NUM134 = -134;
constexpr int NUM135 = -135;
constexpr int NUM142 = -142;
constexpr int NUM1000 = -1000;
constexpr int NUM1006 = -1006;
constexpr int NUM1007 = -1007;
constexpr int NUM1010 = -1010;
constexpr int G_COUNT_MEM = 10000;
constexpr int MAX_INT = 2147483647;
M
mamingshuai 已提交
80
constexpr int FILE_PATH_LENGTH = 256;
W
wenjun 已提交
81 82 83 84 85

using namespace std;
using namespace testing::ext;
using errno_t = int32_t;

M
mamingshuai 已提交
86
errno_t FopenS(FILE **fp, const char *filename, const char *modes);
W
wenjun 已提交
87

M
mamingshuai 已提交
88
int32_t FileSize(const char *filename);
W
wenjun 已提交
89

M
mamingshuai 已提交
90
int32_t FileWrite(const char *filename, uint32_t offset, const uint8_t *buf, uint32_t len);
W
wenjun 已提交
91

M
mamingshuai 已提交
92
int32_t FileRead(const char *filename, uint32_t offset, uint8_t *buf, uint32_t len);
W
wenjun 已提交
93

M
mamingshuai 已提交
94
uint64_t GetTimeMs();
W
wenjun 已提交
95

M
mamingshuai 已提交
96
void AddLog(const char* logType, const char *tag, const char *func, const char *format, const va_list* ap);
W
wenjun 已提交
97

M
mamingshuai 已提交
98
void Logi(const char *tag, const char *func, const char *format, ...);
W
wenjun 已提交
99

M
mamingshuai 已提交
100
void Logw(const char *tag, const char *func, const char *format, ...);
W
wenjun 已提交
101

M
mamingshuai 已提交
102
void Loge(const char *tag, const char *func, const char *format, ...);
W
wenjun 已提交
103

M
mamingshuai 已提交
104
void Logd(const char *tag, const char *func, const char *format, ...);
W
wenjun 已提交
105

M
mamingshuai 已提交
106
int32_t HksTestGetHardwareUdid(uint8_t* udid, uint32_t udidLen);
W
wenjun 已提交
107

M
mamingshuai 已提交
108
void HksStBlobInit1(struct hks_blob *blob, size_t nmemb, size_t size, uint8_t type);
W
wenjun 已提交
109

M
mamingshuai 已提交
110
void HksBlobDestroyT1(struct hks_blob *blob);
W
wenjun 已提交
111

M
mamingshuai 已提交
112
void HexStringToByte(const char *str, int nLen, unsigned char *pHex);
W
wenjun 已提交
113

M
mamingshuai 已提交
114
void BuildBlobData(struct hks_blob *param, const char *str, uint8_t type, uint32_t size, uint8_t isDataNull);
W
wenjun 已提交
115 116

#endif