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 
21 namespace OHOS {
22 namespace SignatureTools {
DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)23 bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
24 {
25     if (!data || !size) {
26         return true;
27     }
28 
29     char arg0[] = "";
30     char arg1[] = "generate-keypair";
31     char arg2[] = "-keyAlias";
32     char arg3[] = "oh-app1-key-v1";
33     char arg4[] = "-keyPwd";
34     char arg5[] = "123456";
35     char arg6[] = "-keyAlg";
36     char arg7[] = "ECC";
37     char arg8[] = "-keySize";
38     char arg9[] = "NIST-P-384";
39     char arg10[] = "-keystoreFile";
40     char arg11[] = "./generateKeyPair/OpenHarmonyTest.p12";
41     char arg12[] = "-keystorePwd";
42     char arg13[] = "123456";
43     char* argv[] = {arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13};
44 
45     int argc = 14;
46 
47     bool ret = ParamsRunTool::ProcessCmd(argv, argc);
48     return ret;
49 }
50 } // namespace SignatureTools
51 } // namespace OHOS
52 
53 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)54 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
55 {
56     /* Run your code on data */
57     OHOS::SignatureTools::DoSomethingInterestingWithMyAPI(data, size);
58     return 0;
59 }
60