1 /*
2 * Copyright (c) 2024 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 #include <cstddef>
17 #include <cstdint>
18 #include <cstdio>
19 #include "params_run_tool.h"
20 #include "cmd_util.h"
21 #include "options.h"
22 #include "file_utils.h"
23
24 namespace OHOS {
25 namespace SignatureTools {
DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)26 bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
27 {
28 if (!data || !size) {
29 return true;
30 }
31 X509* cert = X509_new();
32 X509* certRet = nullptr;
33 std::vector<X509*> certChain;
34 std::string inputType = "clientAuthentication";
35 CmdUtil::VerifyType(inputType);
36 Options options;
37 std::string key1 = "key1";
38 std::string key2 = "key2";
39 bool status = true;
40 (options)["booltype"] = status;
41 options.Equals(key1, key2);
42 options.GetBool("booltype");
43 std::shared_ptr<SignToolServiceImpl> serviceImplPtr = std::make_shared<SignToolServiceImpl>();
44 serviceImplPtr->PrintX509CertFromMemory(cert);
45 serviceImplPtr->PrintX509CertChainFromMemory(certChain);
46 X509_free(cert);
47 CertTools certTool;
48 status = certTool.SetSubjectForCert(nullptr, nullptr);
49 certRet = certTool.GenerateRootCertificate(nullptr, nullptr, &options);
50 status = FileUtils::WriteInputToOutPut("", "");
51 FileUtils::DelDir("");
52
53 return true;
54 }
55 } // namespace SignatureTools
56 } // namespace OHOS
57
58 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)59 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
60 {
61 /* Run your code on data */
62 OHOS::SignatureTools::DoSomethingInterestingWithMyAPI(data, size);
63 return 0;
64 }
65