Loading keymaster/4.0/support/fuzzer/keymaster4_utils_fuzzer.cpp +35 −26 Original line number Diff line number Diff line Loading @@ -46,6 +46,9 @@ void KeyMaster4UtilsFuzzer::invokeKeyMasterUtils() { support::getOsVersion(); support::getOsPatchlevel(); while (mFdp->remaining_bytes() > 0) { auto keymaster_function = mFdp->PickValueInArray<const std::function<void()>>({ [&]() { VerificationToken token; token.challenge = mFdp->ConsumeIntegral<uint64_t>(); token.timestamp = mFdp->ConsumeIntegral<uint64_t>(); Loading @@ -53,26 +56,32 @@ void KeyMaster4UtilsFuzzer::invokeKeyMasterUtils() { size_t vectorSize = mFdp->ConsumeIntegralInRange<size_t>(0, kMaxVectorSize); token.mac.resize(vectorSize); for (size_t n = 0; n < vectorSize; ++n) { token.mac[n] = n; token.mac[n] = mFdp->ConsumeIntegral<uint8_t>(); } std::optional<std::vector<uint8_t>> serialized = serializeVerificationToken(token); std::optional<std::vector<uint8_t>> serialized = serializeVerificationToken(token); if (serialized.has_value()) { std::optional<VerificationToken> deserialized = deserializeVerificationToken(serialized.value()); } }, [&]() { std::vector<uint8_t> dataVector; size_t size = mFdp->ConsumeIntegralInRange<size_t>(0, sizeof(hw_auth_token_t)); dataVector = mFdp->ConsumeBytes<uint8_t>(size); support::blob2hidlVec(dataVector.data(), dataVector.size()); support::blob2hidlVec(dataVector); std::string str = mFdp->ConsumeRandomLengthString(kMaxCharacters); support::blob2hidlVec(str); HardwareAuthToken authToken = support::hidlVec2AuthToken(dataVector); hidl_vec<uint8_t> volatile hidlVector = support::authToken2HidlVec(authToken); }, [&]() { std::string str = mFdp->ConsumeRandomLengthString(kMaxCharacters); support::blob2hidlVec(str); }, }); keymaster_function(); } return; } void KeyMaster4UtilsFuzzer::process(const uint8_t* data, size_t size) { Loading Loading
keymaster/4.0/support/fuzzer/keymaster4_utils_fuzzer.cpp +35 −26 Original line number Diff line number Diff line Loading @@ -46,6 +46,9 @@ void KeyMaster4UtilsFuzzer::invokeKeyMasterUtils() { support::getOsVersion(); support::getOsPatchlevel(); while (mFdp->remaining_bytes() > 0) { auto keymaster_function = mFdp->PickValueInArray<const std::function<void()>>({ [&]() { VerificationToken token; token.challenge = mFdp->ConsumeIntegral<uint64_t>(); token.timestamp = mFdp->ConsumeIntegral<uint64_t>(); Loading @@ -53,26 +56,32 @@ void KeyMaster4UtilsFuzzer::invokeKeyMasterUtils() { size_t vectorSize = mFdp->ConsumeIntegralInRange<size_t>(0, kMaxVectorSize); token.mac.resize(vectorSize); for (size_t n = 0; n < vectorSize; ++n) { token.mac[n] = n; token.mac[n] = mFdp->ConsumeIntegral<uint8_t>(); } std::optional<std::vector<uint8_t>> serialized = serializeVerificationToken(token); std::optional<std::vector<uint8_t>> serialized = serializeVerificationToken(token); if (serialized.has_value()) { std::optional<VerificationToken> deserialized = deserializeVerificationToken(serialized.value()); } }, [&]() { std::vector<uint8_t> dataVector; size_t size = mFdp->ConsumeIntegralInRange<size_t>(0, sizeof(hw_auth_token_t)); dataVector = mFdp->ConsumeBytes<uint8_t>(size); support::blob2hidlVec(dataVector.data(), dataVector.size()); support::blob2hidlVec(dataVector); std::string str = mFdp->ConsumeRandomLengthString(kMaxCharacters); support::blob2hidlVec(str); HardwareAuthToken authToken = support::hidlVec2AuthToken(dataVector); hidl_vec<uint8_t> volatile hidlVector = support::authToken2HidlVec(authToken); }, [&]() { std::string str = mFdp->ConsumeRandomLengthString(kMaxCharacters); support::blob2hidlVec(str); }, }); keymaster_function(); } return; } void KeyMaster4UtilsFuzzer::process(const uint8_t* data, size_t size) { Loading