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[] = "sign-profile";
31 char arg2[] = "-keyAlias";
32 char arg3[] = "oh-profile1-key-v1";
33 char arg4[] = "-keyPwd";
34 char arg5[] = "123456";
35 char arg6[] = "-mode";
36 char arg7[] = "localSign";
37 char arg8[] = "-signAlg";
38 char arg9[] = "SHA384withECDSA";
39 char arg10[] = "-inFile";
40 char arg11[] = "./generateKeyPair/profile.json";
41 char arg12[] = "-keystoreFile";
42 char arg13[] = "./generateKeyPair/OpenHarmony.p12";
43 char arg14[] = "-keystorePwd";
44 char arg15[] = "123456";
45 char arg16[] = "-outFile";
46 char arg17[] = "./generateKeyPair/signed-profile.p7b";
47 char arg18[] = "-profileCertFile";
48 char arg19[] = "./generateKeyPair/profile-release1.pem";
49 char* argv[] = { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
50 arg13, arg14, arg15, arg16, arg17, arg18, arg19 };
51 int argc = 20;
52
53 bool ret = ParamsRunTool::ProcessCmd(argv, argc);
54 return ret;
55 }
56 } // namespace SignatureTools
57 } // namespace OHOS
58
59 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)60 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
61 {
62 /* Run your code on data */
63 OHOS::SignatureTools::DoSomethingInterestingWithMyAPI(data, size);
64 return 0;
65 }