Skip to content

RoT Hubris update_server rollback protection #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gateway-messages/src/sp_to_mgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,7 @@ pub enum UpdateError {
ImageMismatch,
SignatureNotValidated,
VersionNotSupported,
RollbackProtection,
}

impl fmt::Display for UpdateError {
Expand Down Expand Up @@ -1292,6 +1293,9 @@ impl fmt::Display for UpdateError {
Self::InvalidComponent => {
write!(f, "invalid component for operation")
}
Self::RollbackProtection => {
write!(f, "invalid epoch compared to active image")
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions gateway-messages/tests/versioning/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod v14;
mod v15;
mod v16;
mod v17;
mod v18;

pub fn assert_serialized<T: Serialize + SerializedSize + std::fmt::Debug>(
expected: &[u8],
Expand Down
36 changes: 36 additions & 0 deletions gateway-messages/tests/versioning/v18.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! This source file is named after the protocol version being tested,
//! e.g. v01.rs implements tests for protocol version 1.
//! The tested protocol version is represented by "$VERSION" below.
//!
//! The tests in this module check that the serialized form of messages from MGS
//! protocol version $VERSION have not changed.
//!
//! If a test in this module fails, _do not change the test_! This means you
//! have changed, deleted, or reordered an existing message type or enum
//! variant, and you should revert that change. This will remain true until we
//! bump the `version::MIN` to a value higher than $VERSION, at which point these
//! tests can be removed as we will stop supporting $VERSION.

use super::assert_serialized;
use gateway_messages::SerializedSize;
use gateway_messages::SpResponse;
use gateway_messages::UpdateError;

#[test]
fn error_enums() {
let mut out = [0; SpResponse::MAX_SIZE];

let response: [UpdateError; 5] = [
UpdateError::InvalidArchive,
UpdateError::ImageMismatch,
UpdateError::SignatureNotValidated,
UpdateError::VersionNotSupported,
UpdateError::RollbackProtection,
];
let expected = vec![30, 31, 32, 33, 34];
assert_serialized(&mut out, &expected, &response);
}
Loading