| 93 | } |
| 94 | |
| 95 | void BasicStream::verifyRoms() |
| 96 | { |
| 97 | state = State::RomsComplete; |
| 98 | |
| 99 | debug_d("Signature/Checksum: %s", makeHexString(verificationData.data(), verificationData.size(), ' ').c_str()); |
| 100 | |
| 101 | if(!verifier.verify(verificationData)) { |
| 102 | if(slot.updated) { |
| 103 | // Destroy start sector of updated ROM to avoid accidentally booting an unsanctioned firmware |
| 104 | Storage::spiFlash->erase_range(slot.partition.address(), Storage::spiFlash->getBlockSize()); |
| 105 | } |
| 106 | setError(Error::VerificationFailed); |
| 107 | return; |
| 108 | } |
| 109 | |
| 110 | // In a future extension, there might be OTA files without ROM images (SPIFFS-only update, etc.) |
| 111 | if(fileHeader.romCount == 0) { |
| 112 | return; |
| 113 | } |
| 114 | |
| 115 | debug_i("ROM update complete"); |
| 116 | if(!slot.updated) { |
| 117 | setError(Error::NoRomFound); |
| 118 | return; |
| 119 | } |
| 120 | |
| 121 | if(ota.setBootPartition(slot.partition)) { |
| 122 | debug_i("ROM %u activated", toLongString(slot.partition.type(), slot.partition.subType()).c_str()); |
| 123 | } else { |
| 124 | setError(Error::RomActivationFailed); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | size_t BasicStream::write(const uint8_t* data, size_t size) |
| 129 | { |
nothing calls this directly
no test coverage detected