Skip to content

Move reusable code from keylime-agent to the keylime library #1018

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

Merged
merged 10 commits into from
Jun 10, 2025
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion keylime-agent/src/agent_handler.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Keylime Authors

use crate::common::JsonWrapper;
use crate::{tpm, Error as KeylimeError, QuoteData};
use actix_web::{http, web, HttpRequest, HttpResponse, Responder};
use base64::{engine::general_purpose, Engine as _};
use keylime::json_wrapper::JsonWrapper;
use log::*;
use serde::{Deserialize, Serialize};

Expand Down
9 changes: 5 additions & 4 deletions keylime-agent/src/api.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use crate::{
agent_handler, common::JsonWrapper, config, errors_handler, keys_handler,
agent_handler, config, errors_handler, keys_handler,
notifications_handler, quotes_handler, QuoteData,
};
use actix_web::{http, web, HttpRequest, HttpResponse, Responder, Scope};
use keylime::{list_parser::parse_list, version::KeylimeVersion};
use keylime::{
config::SUPPORTED_API_VERSIONS, json_wrapper::JsonWrapper,
list_parser::parse_list, version::KeylimeVersion,
};
use log::*;
use serde::{Deserialize, Serialize};
use thiserror::Error;

pub static SUPPORTED_API_VERSIONS: &[&str] = &["2.1", "2.2"];

#[derive(Error, Debug, PartialEq)]
pub enum APIError {
#[error("API version \"{0}\" not supported")]
Expand Down
186 changes: 0 additions & 186 deletions keylime-agent/src/common.rs

This file was deleted.

10 changes: 4 additions & 6 deletions keylime-agent/src/errors_handler.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2021 Keylime Authors

use crate::{
common::{APIVersion, JsonWrapper},
QuoteData,
};
use crate::QuoteData;
use actix_web::{
body, dev,
error::{InternalError, JsonPayloadError, PathError, QueryPayloadError},
http,
middleware::{ErrorHandlerResponse, ErrorHandlers},
web, Error, HttpRequest, HttpResponse, Responder, Result,
};
use keylime::{json_wrapper::JsonWrapper, version::Version};
use log::*;

pub(crate) async fn app_default(
Expand Down Expand Up @@ -70,9 +68,9 @@ pub(crate) async fn app_default(

pub(crate) async fn version_not_supported(
req: HttpRequest,
version: web::Path<APIVersion>,
version: web::Path<Version>,
) -> impl Responder {
let message = format!("API version not supported: {version}");
let message = format!("API version not supported: v{version}");

warn!("{} returning 400 response. {}", req.head().method, message);

Expand Down
14 changes: 8 additions & 6 deletions keylime-agent/src/keys_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
// Copyright 2021 Keylime Authors

use crate::{
common::JsonWrapper,
config::KeylimeConfig,
payloads::{Payload, PayloadMessage},
Error, QuoteData, Result,
};
use actix_web::{http, web, HttpRequest, HttpResponse, Responder};
use base64::{engine::general_purpose, Engine as _};
use keylime::crypto::{
self,
auth_tag::AuthTag,
encrypted_data::EncryptedData,
symmkey::{KeySet, SymmKey},
use keylime::{
crypto::{
self,
auth_tag::AuthTag,
encrypted_data::EncryptedData,
symmkey::{KeySet, SymmKey},
},
json_wrapper::JsonWrapper,
};
use log::*;
use serde::{Deserialize, Serialize};
Expand Down
Loading