• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     std::vector<X509*> certChain;
33     std::string inputType = "clientAuthentication";
34     CmdUtil::VerifyType(inputType);
35     Options options;
36     std::string key1 = "key1";
37     std::string key2 = "key2";
38     bool status = true;
39     (options)["booltype"] = status;
40     options.Equals(key1, key2);
41     options.GetBool("booltype");
42     std::shared_ptr<SignToolServiceImpl> serviceImplPtr = std::make_shared<SignToolServiceImpl>();
43     serviceImplPtr->PrintX509CertFromMemory(cert);
44     serviceImplPtr->PrintX509CertChainFromMemory(certChain);
45     X509_free(cert);
46     CertTools certTool;
47     status = certTool.SetSubjectForCert(nullptr, nullptr);
48     certTool.GenerateRootCertificate(nullptr, nullptr, &options);
49     FileUtils::WriteInputToOutPut("", "");
50     FileUtils::DelDir("");
51 
52     return true;
53 }
54 } // namespace SignatureTools
55 } // namespace OHOS
56 
57 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)58 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
59 {
60     /* Run your code on data */
61     OHOS::SignatureTools::DoSomethingInterestingWithMyAPI(data, size);
62     return 0;
63 }
64