1 /* 2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef CM_FUZZ_TEST_COMMON_H 17 #define CM_FUZZ_TEST_COMMON_H 18 19 #include "cert_manager_service_ipc_interface_code.h" 20 #include "cm_mem.h" 21 #include "cm_param.h" 22 #include "cm_type.h" 23 #include "securec.h" 24 25 namespace CmFuzzTest { 26 bool GetUintFromBuffer(uint8_t *srcData, uint32_t *remSize, uint32_t *offset, uint32_t *outVal); 27 28 bool GetCmBlobFromBuffer(uint8_t *srcData, uint32_t *remSize, uint32_t *offset, struct CmBlob *outBlob); 29 30 bool GetCertListFromBuffer(uint8_t *srcData, uint32_t *remSize, uint32_t *offset, struct CertList *outList); 31 32 bool GetCertInfoFromBuffer(uint8_t *srcData, uint32_t *remSize, uint32_t *offset, struct CertInfo *outInfo); 33 34 bool CopyMyData(const uint8_t *data, const size_t size, const uint32_t minSize, uint8_t **myData); 35 36 bool ConstructParamSet(uint8_t *srcData, uint32_t *remainSize, uint32_t *offset, 37 CertManagerInterfaceCode code, struct CmParamSet **paramSetOut); 38 39 bool IpcServiceApiFuzzerTest(const uint8_t *data, const size_t size, CertManagerInterfaceCode code, 40 bool isParamsetToBlob, void (*ipcServiceApi)(const struct CmBlob *, struct CmBlob *, const struct CmContext *)); 41 } // namespace CmFuzzTest 42 #endif /* CM_FUZZ_TEST_COMMON_H */ 43