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-csr";
31     char arg2[] = "-keyAlias";
32     char arg3[] = "oh-app1-key-v1";
33     char arg4[] = "-keyPwd";
34     char arg5[] = "123456";
35     char arg6[] = "-subject";
36     char arg7[] = "C=CN;O=OpenHarmony;OU=OpenHarmony Community;CN=App1 Release";
37     char arg8[] = "-signAlg";
38     char arg9[] = "SHA256withECDSA";
39     char arg10[] = "-keystoreFile";
40     char arg11[] = "./generateKeyPair/OpenHarmony.p12";
41     char arg12[] = "-keystorePwd";
42     char arg13[] = "123456";
43     char arg14[] = "-outFile";
44     char arg15[] = "./generateKeyPair/oh-app1-key-v1.csr";
45     char* argv[] = { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,
46         arg10, arg11, arg12, arg13, arg14, arg15 };
47 
48     int argc = 16;
49     bool ret = ParamsRunTool::ProcessCmd(argv, argc);
50     return ret;
51 }
52 } // namespace SignatureTools
53 } // namespace OHOS
54 
55 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)56 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
57 {
58     /* Run your code on data */
59     OHOS::SignatureTools::DoSomethingInterestingWithMyAPI(data, size);
60     return 0;
61 }