Skip to content

Commit

Permalink
Add yhsm-audit for working with yubihsm2 audit log objects & encodi…
Browse files Browse the repository at this point in the history
…ngs.
  • Loading branch information
flihp committed Jul 29, 2023
1 parent 4b3a2ed commit fd05e1e
Show file tree
Hide file tree
Showing 5 changed files with 484 additions and 1 deletion.
184 changes: 183 additions & 1 deletion Cargo.lock

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

14 changes: 14 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,18 @@ members = [
"dice-cert-tmpl",
"dice-mfg",
"dice-mfg-msgs",
"yhsm-audit",
]

[workspace.dependencies]
anyhow = { version = "1", features = ["backtrace"] }
clap = { version = "4", features = ["derive"] }
derive_more = "0.99"
env_logger = "0.10"
hex = "0.4"
log = { version = "0.4", features = ["std"] }
ron = "0.8"
serde = "1"
serde_json = { version = "1", features = ["std", "alloc"] }
sha2 = "0.10"
yubihsm = { git = "https://github.com/oxidecomputer/yubihsm.rs", branch="v0.42.0-with-audit", features = ["default", "usb"] }
19 changes: 19 additions & 0 deletions yhsm-audit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "yubihsm-audit"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow.workspace = true
clap.workspace = true
derive_more.workspace = true
env_logger.workspace = true
hex.workspace = true
log.workspace = true
ron.workspace = true
serde.workspace = true
serde_json.workspace = true
sha2.workspace = true
yubihsm.workspace = true
37 changes: 37 additions & 0 deletions yhsm-audit/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use clap::ValueEnum;
use std::fmt;

#[derive(Clone, Debug, ValueEnum)]
pub enum Kind {
LogEntries,
LogEntry,
}

impl fmt::Display for Kind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Kind::LogEntries => write!(f, "LogEntries"),
Kind::LogEntry => write!(f, "LogEntry"),
}
}
}

#[derive(Clone, Debug, ValueEnum)]
pub enum Encoding {
// The binary serializer from upstream is not exposed publicly.
// We maintain a patch here:
// https://github.com/oxidecomputer/yubihsm.rs/tree/v0.42.0-with-audit
Bin,
Json,
Ron,
}

impl fmt::Display for Encoding {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Encoding::Bin => write!(f, "bin"),
Encoding::Json => write!(f, "json"),
Encoding::Ron => write!(f, "ron"),
}
}
}
Loading

0 comments on commit fd05e1e

Please sign in to comment.