summaryrefslogtreecommitdiff
path: root/src/qcam/assets/feathericons/corner-down-left.svg
blob: 9fffb3e9ffed6372a8a64735cba52c085bc25a85 (plain)
1
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-corner-down-left"><polyline points="9 10 4 15 9 20"></polyline><path d="M20 4v7a4 4 0 0 1-4 4H4"></path></svg>
ss="hl com"> * Copyright (C) 2023, Ideas on Board Oy * * Verify signature on an IPA module */ #include <iostream> #include <libgen.h> #include <libcamera/base/file.h> #include <libcamera/base/span.h> #include "libcamera/internal/ipa_manager.h" #include "libcamera/internal/ipa_module.h" using namespace libcamera; namespace { bool isSignatureValid(IPAModule *ipa) { File file{ ipa->path() }; if (!file.open(File::OpenModeFlag::ReadOnly)) return false; Span<uint8_t> data = file.map(); if (data.empty()) return false; return IPAManager::pubKey().verify(data, ipa->signature()); } void usage(char *argv0) { std::cout << "Usage: " << basename(argv0) << " ipa_name.so" << std::endl; std::cout << std::endl; std::cout << "Verify the signature of an IPA module. The signature file ipa_name.so.sign is" << std::endl; std::cout << "expected to be in the same directory as the IPA module." << std::endl; } } /* namespace */ int main(int argc, char **argv) { if (argc != 2) { usage(argv[0]); return EXIT_FAILURE; } IPAModule module{ argv[1] }; if (!module.isValid()) { std::cout << "Invalid IPA module " << argv[1] << std::endl; return EXIT_FAILURE; } if (!isSignatureValid(&module)) { std::cout << "IPA module signature is invalid" << std::endl; return EXIT_FAILURE; } std::cout << "IPA module signature is valid" << std::endl; return 0; }