/* * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "auth_pin_auth_fuzzer.h" #include #include #include "device_manager_service_listener.h" #include "dm_auth_state.h" #include "dm_auth_state_machine.h" #include "dm_freeze_process.h" namespace OHOS { namespace DistributedHardware { void AuthPinAuthFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size < sizeof(int32_t))) { return; } FreezeProcess freezeProcess; FuzzedDataProvider fdp(data, size); std::shared_ptr context = std::make_shared(); context->transmitData = fdp.ConsumeRandomLengthString(); context->requestId = fdp.ConsumeIntegral(); context->accesser.userId = fdp.ConsumeIntegral(); std::shared_ptr auth1 = std::make_shared(); std::shared_ptr auth2 = std::make_shared(); std::shared_ptr auth3 = std::make_shared(); std::shared_ptr auth4 = std::make_shared(); std::shared_ptr auth5 = std::make_shared(); std::shared_ptr auth6 = std::make_shared(); std::shared_ptr auth7 = std::make_shared(); std::shared_ptr auth8 = std::make_shared(); auth1->GetStateType(); auth2->GetStateType(); int32_t credType = fdp.ConsumeIntegral(); auth3->GetCredIdByCredType(context, credType); context->pinNegotiateStarted = false; auth3->ProcessPinBind(context); context->isAppCredentialVerified = true; context->accesser.isGenerateLnnCredential = false; context->listener = std::make_shared(); auth4->ShowStartAuthDialog(context); auth5->GetStateType(); auth6->GetStateType(); auth7->GetStateType(); auth8->GetStateType(); } } } /* Fuzzer entry point */ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ OHOS::DistributedHardware::AuthPinAuthFuzzTest(data, size); return 0; }