#pragma once #include #include #include "update_parser.h" namespace roro { // Checks Update File signatures against the public key compiled into the firmware (ADR 0003). class EcdsaVerifier : public SignatureVerifier { public: EcdsaVerifier(); ~EcdsaVerifier() override; bool verify(const uint8_t digest[32], const uint8_t* signature, size_t len) override; private: mbedtls_pk_context key_; bool ready_ = false; }; // Writes the image to the app slot that isn't running, and makes it the next boot on finish(). class EspOtaSink : public UpdateSink { public: EspOtaSink() : slot_(esp_ota_get_next_update_partition(nullptr)) {} size_t capacity() const { return slot_ ? slot_->size : 0; } bool begin(size_t imageSize) override; bool write(const uint8_t* data, size_t len) override; bool finish() override; void abort() override; private: const esp_partition_t* slot_; esp_ota_handle_t handle_ = 0; bool open_ = false; }; } // namespace roro