File snphost-0.5.0.obscpio of Package snphost
07070100000000000041ED00000000000000000000000266DA69EB00000000000000000000000000000000000000000000001600000000snphost-0.5.0/.github07070100000001000081A400000000000000000000000166DA69EB000000EB000000000000000000000000000000000000002100000000snphost-0.5.0/.github/CODEOWNERS# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
* @tylerfanelli
07070100000002000081A400000000000000000000000166DA69EB00000053000000000000000000000000000000000000002D00000000snphost-0.5.0/.github/auto_assign-issues.ymladdAssignees: true
assignees:
- DGonzalezVillal
- tylerfanelli
- larrydewey
07070100000003000081A400000000000000000000000166DA69EB00000202000000000000000000000000000000000000002600000000snphost-0.5.0/.github/auto_assign.yml# Set to true to add reviewers to pull requests
addReviewers: true
# Set to true to add assignees to pull requests
addAssignees: true
# A list of reviewers to be added to pull requests (GitHub user name)
reviewers:
- DGonzalezVillal
- tylerfanelli
- larrydewey
# A list of keywords to be skipped the process that add reviewers if pull requests include it
skipKeywords:
- wip
- WIP
# A number of reviewers added to the pull request
# Set 0 to add all the reviewers (default: 0)
numberOfReviewers: 2
07070100000004000081A400000000000000000000000166DA69EB00000064000000000000000000000000000000000000002500000000snphost-0.5.0/.github/dependabot.ymlversion: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "daily"
07070100000005000041ED00000000000000000000000266DA69EB00000000000000000000000000000000000000000000002000000000snphost-0.5.0/.github/workflows07070100000006000081A400000000000000000000000166DA69EB00000089000000000000000000000000000000000000002800000000snphost-0.5.0/.github/workflows/dco.ymlname: Sign-off Check
on:
pull_request:
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: KineticCafe/actions-dco@v1
07070100000007000081A400000000000000000000000166DA69EB00000369000000000000000000000000000000000000002900000000snphost-0.5.0/.github/workflows/lint.ymlon: [push, pull_request]
name: lint
jobs:
fmt:
name: cargo fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
components: rustfmt
toolchain: nightly
profile: minimal
override: true
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
name: cargo clippy
runs-on: ubuntu-latest
steps:
- run: sudo apt-get install -y asciidoctor
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
components: clippy
toolchain: 1.80
profile: minimal
override: true
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets -- -D clippy::all -D unused_imports -Dwarnings
07070100000008000081A400000000000000000000000166DA69EB000002B4000000000000000000000000000000000000002900000000snphost-0.5.0/.github/workflows/test.ymlon: [push, pull_request]
name: test
jobs:
test:
name: ${{ matrix.toolchain }} (${{ matrix.profile.name }})
runs-on: ubuntu-latest
steps:
- run: sudo apt-get install -y asciidoctor
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: ${{ matrix.profile.flag }}
strategy:
fail-fast: false
matrix:
toolchain:
- nightly
- beta
- stable
profile:
- name: debug
- name: release
flag: --release
07070100000009000081A400000000000000000000000166DA69EB00000014000000000000000000000000000000000000001900000000snphost-0.5.0/.gitignore/target
*.sh
.vscode0707010000000A000081A400000000000000000000000166DA69EB00005671000000000000000000000000000000000000001900000000snphost-0.5.0/Cargo.lock# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]]
name = "anstream"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
[[package]]
name = "anstyle-parse"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
dependencies = [
"anstyle",
"windows-sys 0.52.0",
]
[[package]]
name = "anyhow"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3"
[[package]]
name = "base64"
version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
"serde",
]
[[package]]
name = "bitfield"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c821a6e124197eb56d907ccc2188eab1038fb919c914f47976e64dd8dbc855d1"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "cc"
version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.5.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
[[package]]
name = "codicon"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12170080f3533d6f09a19f81596f836854d0fa4867dc32c8172b8474b4e9de61"
[[package]]
name = "colorchoice"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]]
name = "colorful"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97af0562545a7d7f3d9222fcf909963bec36dcb502afaacab98c6ffac8da47ce"
[[package]]
name = "curl"
version = "0.4.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e2161dd6eba090ff1594084e95fd67aeccf04382ffea77999ea94ed42ec67b6"
dependencies = [
"curl-sys",
"libc",
"openssl-probe",
"openssl-sys",
"schannel",
"socket2",
"windows-sys 0.52.0",
]
[[package]]
name = "curl-sys"
version = "0.4.72+curl-8.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29cbdc8314c447d11e8fd156dcdd031d9e02a7a976163e396b548c03153bc9ea"
dependencies = [
"cc",
"libc",
"libz-sys",
"openssl-sys",
"pkg-config",
"vcpkg",
"windows-sys 0.52.0",
]
[[package]]
name = "dirs"
version = "5.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs-sys"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
dependencies = [
"libc",
"option-ext",
"redox_users",
"windows-sys 0.48.0",
]
[[package]]
name = "env_logger"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"
dependencies = [
"humantime",
"is-terminal",
"log",
"regex",
"termcolor",
]
[[package]]
name = "foreign-types"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
dependencies = [
"foreign-types-shared",
]
[[package]]
name = "foreign-types-shared"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "getrandom"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c"
dependencies = [
"cfg-if",
"libc",
"wasi",
]
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hermit-abi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]]
name = "hex"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "iocuddle"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8972d5be69940353d5347a1344cb375d9b457d6809b428b05bb1ca2fb9ce007"
[[package]]
name = "is-terminal"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b"
dependencies = [
"hermit-abi",
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
[[package]]
name = "libredox"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
dependencies = [
"bitflags 2.5.0",
"libc",
]
[[package]]
name = "libz-sys"
version = "1.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e143b5e666b2695d28f6bca6497720813f699c9602dd7f5cac91008b8ada7f9"
dependencies = [
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "log"
version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
[[package]]
name = "memchr"
version = "2.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
[[package]]
name = "msru"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15a014208ef068fd9eed02eceb063ecba151d9922de4f8b4bb3703ff3d2a3eaa"
[[package]]
name = "once_cell"
version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "openssl"
version = "0.10.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f"
dependencies = [
"bitflags 2.5.0",
"cfg-if",
"foreign-types",
"libc",
"once_cell",
"openssl-macros",
"openssl-sys",
]
[[package]]
name = "openssl-macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "openssl-probe"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2"
dependencies = [
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "option-ext"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]]
name = "pkg-config"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
[[package]]
name = "proc-macro2"
version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom",
]
[[package]]
name = "rdrand"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d92195228612ac8eed47adbc2ed0f04e513a4ccb98175b6f2bd04d963b533655"
dependencies = [
"rand_core",
]
[[package]]
name = "redox_users"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891"
dependencies = [
"getrandom",
"libredox",
"thiserror",
]
[[package]]
name = "regex"
version = "1.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
[[package]]
name = "schannel"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "serde"
version = "1.0.198"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde-big-array"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11fc7cc2c76d73e0f27ee52abbd64eec84d46f370c88371120433196934e4b7f"
dependencies = [
"serde",
]
[[package]]
name = "serde_bytes"
version = "0.11.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734"
dependencies = [
"serde",
]
[[package]]
name = "serde_derive"
version = "1.0.198"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "sev"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a97bd0b2e2d937951add10c8512a2dacc6ad29b39e5c5f26565a3e443329857d"
dependencies = [
"base64",
"bincode",
"bitfield",
"bitflags 1.3.2",
"byteorder",
"codicon",
"dirs",
"hex",
"iocuddle",
"lazy_static",
"libc",
"openssl",
"rdrand",
"serde",
"serde-big-array",
"serde_bytes",
"static_assertions",
"uuid",
]
[[package]]
name = "snphost"
version = "0.5.0"
dependencies = [
"anyhow",
"clap",
"colorful",
"curl",
"env_logger",
"libc",
"msru",
"sev",
]
[[package]]
name = "socket2"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871"
dependencies = [
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "2.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "termcolor"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
dependencies = [
"winapi-util",
]
[[package]]
name = "thiserror"
version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "utf8parse"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "uuid"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0"
dependencies = [
"serde",
]
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "winapi-util"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"windows-targets 0.48.5",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets 0.52.5",
]
[[package]]
name = "windows-targets"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm 0.48.5",
"windows_aarch64_msvc 0.48.5",
"windows_i686_gnu 0.48.5",
"windows_i686_msvc 0.48.5",
"windows_x86_64_gnu 0.48.5",
"windows_x86_64_gnullvm 0.48.5",
"windows_x86_64_msvc 0.48.5",
]
[[package]]
name = "windows-targets"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
dependencies = [
"windows_aarch64_gnullvm 0.52.5",
"windows_aarch64_msvc 0.52.5",
"windows_i686_gnu 0.52.5",
"windows_i686_gnullvm",
"windows_i686_msvc 0.52.5",
"windows_x86_64_gnu 0.52.5",
"windows_x86_64_gnullvm 0.52.5",
"windows_x86_64_msvc 0.52.5",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_gnu"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
0707010000000B000081A400000000000000000000000166DA69EB000004B1000000000000000000000000000000000000001900000000snphost-0.5.0/Cargo.toml[package]
name = "snphost"
version = "0.5.0"
authors = ["The VirTEE Project Developers"]
edition = "2021"
license = "Apache-2.0"
homepage = "https://github.com/virtee/snphost"
repository = "https://github.com/virtee/snphost"
description = "Administrative utility for AMD SEV-SNP"
readme = "README.md"
keywords = ["amd", "sev", "snp"]
categories = ["os", "os::linux-apis", "parsing", "cryptography", "hardware-support"]
exclude = [ ".gitignore", ".github/*" ]
rust-version = "1.74"
[badges]
# See https://doc.rust-lang.org/cargo/reference/manifest.html#the-badges-section
github = { repository = "virtee/snphost", workflow = "test" }
#github = { repository = "virtee/snphost", workflow = "lint" }
maintenance = { status = "actively-developed" }
is-it-maintained-issue-resolution = { repository = "virtee/snphost" }
is-it-maintained-open-issues = { repository = "virtee/snphost" }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0.83"
sev = { version = "4.0.0", features = ['openssl']}
env_logger = "0.10.1"
clap = { version = "4.5", features = [ "derive" ] }
colorful = "0.2.2"
libc = "0.2.154"
curl = "0.4"
msru = "0.2.0"
0707010000000C000081A400000000000000000000000166DA69EB00002C5D000000000000000000000000000000000000001600000000snphost-0.5.0/LICENSE Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
0707010000000D000081A400000000000000000000000166DA69EB000000B2000000000000000000000000000000000000001800000000snphost-0.5.0/README.md# snphost
Management CLI for SEV-SNP host system administrators
Please consult `docs/snphost.1.adoc` for an overview of `snphost` and
descriptions of each `snphost` subcommand.
0707010000000E000081A400000000000000000000000166DA69EB00000636000000000000000000000000000000000000001700000000snphost-0.5.0/build.rs// SPDX-License-Identifier: Apache-2.0
use std::path::Path;
use std::{env, fs, io, process};
const COMMANDS: [&str; 1] = ["snphost"];
fn main() {
let outdir = match env::var_os("OUT_DIR") {
Some(outdir) => outdir,
None => {
panic!("OUT_DIR environment variable not defined.");
}
};
fs::create_dir_all(&outdir).unwrap();
for command in COMMANDS {
if let Err(err) = generate_man_page(&outdir, command) {
println!(
"failed to generate man page: {} (is asciidoctor installed?)",
err
);
}
}
}
fn generate_man_page<P: AsRef<Path>>(outdir: P, command: &str) -> io::Result<()> {
// If asciidoctor isn't installed, fallback to asciidoc.
if let Err(err) = process::Command::new("asciidoctor").output() {
eprintln!("Error from running 'asciidoctor': {}", err);
return Err(err);
}
let outdir = outdir.as_ref();
let outfile = outdir.join(format!("{}.1", command));
let cwd = env::current_dir()?;
let txt_path = cwd.join("docs").join(format!("{}.1.adoc", command));
let result = process::Command::new("asciidoctor")
.arg("--doctype")
.arg("manpage")
.arg("--backend")
.arg("manpage")
.arg("--out-file")
.arg(&outfile)
.arg(&txt_path)
.spawn()?
.wait()?;
if !result.success() {
let msg = format!("'asciidoctor' failed with exit code {:?}", result.code());
return Err(io::Error::new(io::ErrorKind::Other, msg));
}
Ok(())
}
0707010000000F000041ED00000000000000000000000266DA69EB00000000000000000000000000000000000000000000001300000000snphost-0.5.0/docs07070100000010000081A400000000000000000000000166DA69EB00001920000000000000000000000000000000000000002200000000snphost-0.5.0/docs/snphost.1.adocsnphost(1)
==========
NAME
----
snphost - Command line tool for managing the AMD SEV-SNP environment.
SYNOPSIS
--------
*snphost* [GLOBAL_OPTIONS] [_COMMAND_] [_COMMAND_ARGS_] +
*snphost* [_-h, --help_] +
*snphost* *command* *--help*
DESCRIPTION
-----------
snphost is a CLI utility for managing and interacting with the AMD SEV-SNP
firmware device of a host system.
GLOBAL OPTIONS
--------------
*-q, --quiet*:: Don't print any output to the console.
COMMANDS
--------
*snphost export*::
usage: snphost export [der, pem] CERT-FILE DIR-PATH
This command exports the SEV-SNP certificate chain to the directory
provided by DIR-PATH. User has to provide the CERT-FILE where the certs
are currently stored in (in GHCB format). The user must also specify if
they want the certs to be exported in PEM or DER certificate format. These are the only
two encoding formats supported in this tool. Currently only AMD chain certificates (ARK, ASK, VCEK and VLEK)
are supported for export.
options:
-h, --help Show a help message.
*snphost import*::
usage: snphost import DIR-PATH CERT-FILE
This command imports serialized SEV-SNP certificates to the specified CERT-FILE.
This CERT-FILE can then be provided to QEMU to perform extended attestation on guest.
Currently, only the ASK, ARK, VCEK and VLEK are supported to serialize in the tool.
Note that there are a few user requirements for this command to work as intended.
All certificates must be located in the same directory with specific
names:
ARK certificate => ark.{pem, der}
ASK certificate => ask.{pem, der}
VCEK certificate => vcek.{pem, der}
VLEK certificate => vlek.{pem, der}
Not all certificates are needed in the directory, only the ones that a
user is looking to import to the CERT-FILE.
options:
-h, --help Show a help message
*snphost ok*::
usage: snphost ok
This command probes the processor, sysfs, and KVM for AMD SEV-SNP
related capabilities on the host and emits the results.
options:
-h, --help Show a help message
*snphost commit*::
usage: snphost commit
This command commits the current firmware and SNP platform config versions to the PSP.
This can't be undone and will not allow rollbacks to older versions.
options:
-h, --help Show a help message.
*snphost config set*::
usage: snphost config set BOOTLOADER TEE SNP-FW MICROCODE MASK-CHIP
This command allows the user to change the config of the SNP platform. The user can
provide the desired versions of the different TCB paramerters they would like to modify.
The command will change the reported values by the PSP. In order to have this changes commited, the
user would have to use snphost commit. The user can also provide a new mask-chip value that
will change the mask chip bit field values in the config.
Explanation of the different parmeters:
BOOTLOADER: Desired reported bootloader version
TEE: Desired reported PSP OS version
SNP-FW: Desired reported SNP Firmware level
MICROCODE: Desired reported patch level of all the cores
MASK-CHIP: Change the CHIP ID and CHIP KEY settings by changing the MASK-CHIP bits.
Valid values range from 0-3 depending on what bits the user wants enabled.
Bit[0] -> CHIP ID: Indicates that the CHIP_ID field in the attestation report
will always be 0.
Bit[1] -> MASK KEY: Indicates that the VCEK is not used in attestation and guest
key derivation.
For example, if the user would like MASK KEY to be enabled and CHIP ID disabled,
then the they would pass in a 2.
options:
-h, --help Show a help message.
*snphost config reset*::
usage: snphost config reset
This command resets the SEV-SNP platform. This will clear all
persistent data managed by the platform and reset the platform configuration
to its last committed version.
options:
-h, --help Show a help message.
*snphost show*::
usage: snphost show [guests, identifier, tcb, vcek-url, version ]
This command describes the state of the SEV-SNP platform. There are
several platform details to describe:
Guest count: snphost show guests
Platform identifier: snphost show identifier
TCB version: snphost show tcb
VCEK URL: snphost show vcek-url
Firmware version: snphost show version
options:
-h, --help Show a help message
*snphost verify*::
usage: snphost verify DIR-PATH
This command verifies the full SEV-SNP/CA certificate chain.
It will use the ask,ark, and vek (vcek or vlek) certificates that are
stored in the provided directory. If both the vlek and vcek are present,
then the tool will use the vlek by default.
options:
-h, --help Show a help message
*snphost fetch ca*::
usage: snphost fetch ca [ der, pem ] DIR-PATH
This command fetches the host system's CA certificate chain and writes
the encoded certificates to the directory at path DIR-PATH. Users must
specify which format they would like the certificate to be encoded
in (DER or PEM).
options:
-h, --help Show a help message
*snphost fetch vcek*::
usage: snphost fetch vcek [ der, pem ] DIR-PATH
This command fetches the host system's versioned chip endorsement
key (VCEK) and writes the encoded certificate to the directory at path
DIR-PATH. Users must specify which format they would like the
certificate to be encoded in (DER or PEM).
options:
-h, --help Show a help message
*snphost fetch crl*::
usage: snphost fetch crl DIR-PATH
This command fetches the host system's certificate revokation list
(CRL) and writes the encoded list to the directory at path DIR-PATH.
options:
-h, --help Show a help message
REPORTING BUGS
--------------
Please report all bugs to <https://github.com/virtee/snphost/issues>
07070100000011000041ED00000000000000000000000266DA69EB00000000000000000000000000000000000000000000001200000000snphost-0.5.0/src07070100000012000041ED00000000000000000000000266DA69EB00000000000000000000000000000000000000000000001700000000snphost-0.5.0/src/cert07070100000013000081A400000000000000000000000166DA69EB00000DA3000000000000000000000000000000000000002100000000snphost-0.5.0/src/cert/export.rs// SPDX-License-Identifier: Apache-2.0
use super::*;
use anyhow::{bail, Context, Result};
use sev::{
certs::snp::Certificate,
firmware::host::{CertTableEntry, CertType},
};
use std::{
fs::File,
io::{BufReader, Read, Write},
path::PathBuf,
};
// Convert kernel formatted certs into user readable certificates
fn cert_entries(cert_bytes: &mut [u8]) -> Result<Vec<CertTableEntry>> {
let certs = CertTableEntry::vec_bytes_to_cert_table(cert_bytes)
.context("Could not convert bytes to certs")?;
Ok(certs)
}
#[derive(Parser)]
pub struct Export {
/// The format the certs will be encoded in (PEM or DER)
#[arg(value_name = "encoding", required = true)]
pub encoding_fmt: EncodingFormat,
/// File where the formatted certificates are stored.
#[arg(value_name = "cert-file", required = true)]
pub cert_file: PathBuf,
/// The directory to write the certificates to
#[arg(value_name = "dir-path", required = true)]
pub dir_path: PathBuf,
}
pub fn cmd(export: Export) -> Result<()> {
let (mut ark, mut ask, mut vcek, mut vlek) = (false, false, false, false);
std::fs::create_dir_all(export.dir_path.clone()).context(format!(
"unable to find or create directory {}",
export.dir_path.display()
))?;
// Read the cert file with the kenrel formatted certs
let cert_file = File::open(export.cert_file)?;
let mut reader = BufReader::new(cert_file);
let mut cert_bytes = Vec::new();
// Read file into vector.
reader.read_to_end(&mut cert_bytes)?;
// Create a vec of CertTableEntry (x509 versioned)
let entries = cert_entries(&mut cert_bytes)?;
for e in entries {
let type_id = match e.cert_type {
CertType::ARK => {
if ark {
bail!("multiple ARKs found");
}
ark = true;
"ark"
}
CertType::ASK => {
if ask {
bail!("multiple ASKs found");
}
ask = true;
"ask"
}
CertType::VLEK => {
if vlek {
bail!("multiple VLEKs found");
}
vlek = true;
"vlek"
}
CertType::VCEK => {
if vcek {
bail!("multiple VCEKs found");
}
vcek = true;
"vcek"
}
_ => continue,
};
let certificate = Certificate::from_bytes(&e.data)?;
// Verify the certificate is in the requested format.
let formatted_data: Vec<u8> = match export.encoding_fmt {
EncodingFormat::Der => certificate.to_der()?,
EncodingFormat::Pem => certificate.to_pem()?,
};
// Build out the expected name of the file.
let name = format!(
"{}/{}.{}",
export.dir_path.display(),
type_id,
export.encoding_fmt
);
// Create the file for writing and open a file-handle.
let mut file = std::fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(name.clone())?;
// Write out the contents of the certificate to the file.
file.write_all(&formatted_data)
.context(format!("unable to cert data to file {}", name))?;
}
Ok(())
}
07070100000014000041ED00000000000000000000000266DA69EB00000000000000000000000000000000000000000000001D00000000snphost-0.5.0/src/cert/fetch07070100000015000081A400000000000000000000000166DA69EB00000911000000000000000000000000000000000000002300000000snphost-0.5.0/src/cert/fetch/ca.rs// SPDX-License-Identifier: Apache-2.0
use super::*;
use anyhow::{Context, Result};
use curl::easy::Easy;
use sev::certs::snp::{ca::Chain, Certificate};
use std::{
fs::{create_dir_all, OpenOptions},
io::Write,
path::PathBuf,
};
use super::super::EncodingFormat;
use crate::processor::ProcessorGeneration;
#[derive(Parser)]
pub struct Ca {
/// The format the certs are encoded in.
#[arg(value_name = "encoding", required = true)]
pub encoding_fmt: EncodingFormat,
/// The directory to write the certificates to
#[arg(value_name = "dir-path", required = true)]
pub dir_path: PathBuf,
}
fn write_cert(path: &PathBuf, bytes: &[u8]) -> Result<()> {
let mut file = OpenOptions::new()
.create(true)
.truncate(true)
.write(true)
.open(path)?;
file.write_all(bytes)
.context("Failed to write certificate!")
}
pub fn cmd(ca: Ca) -> Result<()> {
let url: String = ca_chain_url()?;
let cert_chain: Chain = fetch(&url)?;
let ((ask_path, ask_bytes), (ark_path, ark_bytes)) = match ca.encoding_fmt {
EncodingFormat::Der => (
("ask.der", cert_chain.ask.to_der()?),
("ark.der", cert_chain.ark.to_der()?),
),
EncodingFormat::Pem => (
("ask.pem", cert_chain.ask.to_pem()?),
("ark.pem", cert_chain.ark.to_pem()?),
),
};
// Create Directory if not exists first, then write the files.
if !ca.dir_path.exists() {
create_dir_all(&ca.dir_path)?;
}
write_cert(&ca.dir_path.join(ask_path), &ask_bytes)?;
write_cert(&ca.dir_path.join(ark_path), &ark_bytes)?;
Ok(())
}
pub fn fetch(url: &str) -> Result<Chain> {
let mut handle = Easy::new();
let mut buf: Vec<u8> = Vec::new();
handle.url(url)?;
handle.get(true)?;
let mut transfer = handle.transfer();
transfer.write_function(|data| {
buf.extend_from_slice(data);
Ok(data.len())
})?;
transfer.perform()?;
drop(transfer);
Ok(Chain {
ask: Certificate::from_pem(&buf[..2325])?,
ark: Certificate::from_pem(&buf[2325..])?,
})
}
fn ca_chain_url() -> Result<String> {
Ok(format!(
"https://kdsintf.amd.com/vcek/v1/{}/cert_chain",
ProcessorGeneration::current()?.to_kds_url()
))
}
07070100000016000081A400000000000000000000000166DA69EB000005F5000000000000000000000000000000000000002400000000snphost-0.5.0/src/cert/fetch/crl.rs// SPDX-License-Identifier: Apache-2.0
use super::*;
use crate::processor::ProcessorGeneration;
use anyhow::{Context, Result};
use curl::easy::Easy;
use std::{
fs::{create_dir_all, OpenOptions},
io::Write,
path::PathBuf,
};
fn crl_url() -> Result<String> {
Ok(format!(
"https://kdsintf.amd.com/vcek/v1/{}/crl",
ProcessorGeneration::current()?.to_kds_url()
))
}
#[derive(Parser)]
pub struct Crl {
/// The directory to write the CRL to
#[arg(value_name = "dir-path", required = true)]
pub dir_path: PathBuf,
}
pub fn cmd(crl: Crl) -> Result<()> {
let url: String = crl_url()?;
let bytes: Vec<u8> = fetch(&url)?;
// Create Directory if not exists first, then write the files.
if !crl.dir_path.exists() {
create_dir_all(&crl.dir_path)?;
}
let mut file = OpenOptions::new()
.create(true)
.truncate(true)
.write(true)
.open(crl.dir_path.join(format!(
"{}.crl",
ProcessorGeneration::current()?.to_kds_url()
)))?;
file.write_all(&bytes)
.context("Failed to write CRL to directory specified!")
}
pub fn fetch(url: &str) -> Result<Vec<u8>> {
let mut handle = Easy::new();
let mut buf: Vec<u8> = Vec::new();
handle.url(url)?;
handle.get(true)?;
let mut transfer = handle.transfer();
transfer.write_function(|data| {
buf.extend_from_slice(data);
Ok(data.len())
})?;
transfer.perform()?;
drop(transfer);
Ok(buf)
}
07070100000017000081A400000000000000000000000166DA69EB0000021D000000000000000000000000000000000000002400000000snphost-0.5.0/src/cert/fetch/mod.rs// SPDX-License-Identifier: Apache-2.0
use super::*;
pub(crate) mod ca;
pub(crate) mod crl;
pub(crate) mod vcek;
use anyhow::Result;
#[derive(Subcommand)]
pub enum Fetch {
/// Fetches the VCEK from the KDS
Vcek(vcek::Vcek),
/// Fetches the CA from the KDS
Ca(ca::Ca),
/// Fetches the CRL from the KDS
Crl(crl::Crl),
}
pub fn cmd(fetch: Fetch) -> Result<()> {
match fetch {
Fetch::Vcek(vcek) => vcek::cmd(vcek),
Fetch::Ca(ca) => ca::cmd(ca),
Fetch::Crl(crl) => crl::cmd(crl),
}
}
07070100000018000081A400000000000000000000000166DA69EB00000945000000000000000000000000000000000000002500000000snphost-0.5.0/src/cert/fetch/vcek.rs// SPDX-License-Identifier: Apache-2.0
use super::*;
use std::{
fs::{create_dir_all, OpenOptions},
io::Write,
path::PathBuf,
};
use crate::{firmware, processor::ProcessorGeneration, snp_platform_status};
use anyhow::{Context, Result};
use curl::easy::Easy;
use sev::certs::snp::Certificate;
#[derive(Parser)]
pub struct Vcek {
/// The format in which to encode the certificate
#[arg(value_name = "encoding", required = true)]
encoding_fmt: EncodingFormat,
/// The path of a directory to store the encoded VCEK in
#[arg(value_name = "path", required = true)]
path: PathBuf,
}
pub fn cmd(vcek: Vcek) -> Result<()> {
let url = vcek_url()?;
let cert = fetch(&url).context(format!("unable to fetch VCEK from {}", url))?;
let (vcek_name, vcek_bytes) = match vcek.encoding_fmt {
EncodingFormat::Der => ("vcek.der", cert.to_der()?),
EncodingFormat::Pem => ("vcek.pem", cert.to_pem()?),
};
// Create Directory if not exists first, then write the files.
if !vcek.path.exists() {
create_dir_all(&vcek.path)?;
}
let mut file = OpenOptions::new()
.create(true)
.truncate(true)
.write(true)
.open(vcek.path.join(vcek_name))?;
file.write_all(&vcek_bytes)?;
Ok(())
}
pub fn fetch(url: &str) -> Result<Certificate> {
let mut handle = Easy::new();
let mut buf: Vec<u8> = Vec::new();
handle.url(url)?;
handle.get(true)?;
let mut transfer = handle.transfer();
transfer.write_function(|data| {
buf.extend_from_slice(data);
Ok(data.len())
})?;
transfer.perform()?;
drop(transfer);
Ok(Certificate::from_der(buf.as_slice())?)
}
pub fn vcek_url() -> Result<String> {
let id = firmware()?
.get_identifier()
.map_err(|e| anyhow::anyhow!(format!("{:?}", e)))
.context("error fetching identifier")?;
let status = snp_platform_status()?;
let gen = ProcessorGeneration::current()?.to_kds_url();
Ok(format!("https://kdsintf.amd.com/vcek/v1/{}/{}?blSPL={:02}&teeSPL={:02}&snpSPL={:02}&ucodeSPL={:02}",
gen, id, status.reported_tcb_version.bootloader,
status.reported_tcb_version.tee,
status.reported_tcb_version.snp,
status.reported_tcb_version.microcode))
}
07070100000019000081A400000000000000000000000166DA69EB00000A96000000000000000000000000000000000000002100000000snphost-0.5.0/src/cert/import.rs// SPDX-License-Identifier: Apache-2.0
use super::*;
use sev::firmware::host::{CertTableEntry, CertType};
use std::{
fs::{read, read_dir, DirEntry, File},
io::Write,
path::PathBuf,
};
use anyhow::{bail, Context, Result};
#[derive(Parser)]
pub struct Import {
/// The directory where the certificates are stored
#[arg(value_name = "dir-path", required = true)]
pub dir_path: PathBuf,
/// File where the formatted certificates will be stored.
#[arg(value_name = "cert-file", required = true)]
pub cert_file: PathBuf,
}
pub fn cmd(import: Import) -> Result<()> {
if !import.dir_path.exists() {
bail!(format!("path {} does not exist", import.dir_path.display()));
}
let mut table: Vec<CertTableEntry> = vec![];
// For each cert in the directory convert into a kernel formatted cert and write into file
for dir_entry in read_dir(import.dir_path.clone())? {
match dir_entry {
Ok(de) => table_add_entry(de, &mut table)?,
Err(_) => {
bail!(format!(
"unable to read directory at path {}",
import.dir_path.display()
))
}
}
}
let cert_bytes = CertTableEntry::cert_table_to_vec_bytes(&table)
.context("Failed to convert certificates to GHCB bytes specification.")?;
// Write cert into directory
let mut file = if import.cert_file.exists() {
std::fs::OpenOptions::new()
.write(true)
.truncate(true)
.open(import.cert_file)
.context("Unable to overwrite kernel cert file contents")?
} else {
File::create(import.cert_file).context("Unable to create kernel cert file")?
};
file.write(&cert_bytes)
.context(format!("unable to write data to file {:?}", file))?;
Ok(())
}
fn table_add_entry(de: DirEntry, table: &mut Vec<CertTableEntry>) -> Result<()> {
match entry_get_type(&de.path())? {
Some(cert_type) => {
let data = read(de.path())?;
table.push(CertTableEntry::new(cert_type, data));
Ok(())
}
None => Ok(()),
}
}
fn entry_get_type(path: &PathBuf) -> Result<Option<CertType>> {
let file_name_string = path
.file_name()
.context(format!("unable to read file at path {:?}", path))?
.to_string_lossy()
.into_owned();
let subs: Vec<&str> = file_name_string.split('.').collect();
match subs[0] {
"ark" => Ok(Some(CertType::ARK)),
"ask" => Ok(Some(CertType::ASK)),
"vlek" => Ok(Some(CertType::VLEK)),
"vcek" => Ok(Some(CertType::VCEK)),
_ => Ok(None),
}
}
0707010000001A000081A400000000000000000000000166DA69EB000003D4000000000000000000000000000000000000001E00000000snphost-0.5.0/src/cert/mod.rs// SPDX-License-Identifier: Apache-2.0
use super::*;
pub(crate) mod export;
pub(crate) mod fetch;
pub(crate) mod import;
pub(crate) mod verify;
use std::str::FromStr;
use anyhow::{anyhow, Error};
#[derive(ValueEnum, Copy, Clone)]
pub enum EncodingFormat {
/// Certificates are encoded in DER format
Der,
/// Certificates are encoded in PEM format
Pem,
}
impl std::fmt::Display for EncodingFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Self::Der => "der",
Self::Pem => "pem",
}
)
}
}
impl FromStr for EncodingFormat {
type Err = Error;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
match s {
"der" => Ok(Self::Der),
"pem" => Ok(Self::Pem),
_ => Err(anyhow!("unrecognized certificate encoding format")),
}
}
}
0707010000001B000081A400000000000000000000000166DA69EB00000C85000000000000000000000000000000000000002100000000snphost-0.5.0/src/cert/verify.rs// SPDX-License-Identifier: Apache-2.0
use super::*;
use anyhow::{anyhow, Context, Result};
use std::{
fs::read,
path::{Path, PathBuf},
};
use colorful::*;
use sev::certs::snp::{ca, Certificate, Chain, Verifiable};
pub fn find_cert_in_dir(dir: &Path, cert: &str) -> Result<PathBuf, anyhow::Error> {
if dir.join(format!("{cert}.pem")).exists() {
Ok(dir.join(format!("{cert}.pem")))
} else if dir.join(format!("{cert}.der")).exists() {
Ok(dir.join(format!("{cert}.der")))
} else {
return Err(anyhow::anyhow!("{cert} certificate not found in directory"));
}
}
#[derive(Parser)]
pub struct Verify {
/// Path to directory containing certificates.
#[arg(value_name = "dir-path", required = true)]
pub dir_path: PathBuf,
}
pub fn cmd(verify: Verify, quiet: bool) -> Result<()> {
let ark_path = find_cert_in_dir(&verify.dir_path, "ark")?;
let ask_path = find_cert_in_dir(&verify.dir_path, "ask")?;
let mut vek_type: &str = "VCEK";
let vek_path = match find_cert_in_dir(&verify.dir_path, "vlek") {
Ok(vlek_path) => {
vek_type = "VLEK";
vlek_path
}
Err(_) => find_cert_in_dir(&verify.dir_path, "vcek")?,
};
// Get a cert chain from directory
let cert_chain = chain(ark_path, ask_path, vek_path, vek_type)?;
let ark = (&cert_chain.ca.ark, "ARK");
let ask = (&cert_chain.ca.ask, "ASK");
let vek = (&cert_chain.vek, vek_type);
let mut err = true;
if !quiet {
println!("\n • = self signed, ⬑ = signs, •̷ = invalid self sign, ⬑̸ = invalid signs\n");
}
err |= status(ark, ark, true, quiet);
err |= status(ark, ask, false, quiet);
err |= status(ask, vek, false, quiet);
match err {
true => Ok(()),
false => Err(anyhow!("SEV-SNP/CA certificate verification failed")),
}
}
fn status<'a, S>(
signer: (&'a S, &str),
signee: (&'a S, &str),
self_signed: bool,
quiet: bool,
) -> bool
where
(&'a S, &'a S): Verifiable,
{
let res = (signer.0, signee.0).verify().is_ok();
if !quiet {
println!("{}", ssym(res, self_signed, signer.1, signee.1));
}
res
}
fn ssym(res: bool, self_signed: bool, signer: &str, signee: &str) -> String {
let sym = match (res, self_signed) {
(true, true) => "•".green(),
(true, false) => "⬑".green(),
(false, true) => "•̷".red(),
(false, false) => "⬑̸".red(),
};
match self_signed {
true => format!("{} {}", signer, sym),
false => format!("{} {} {}", signer, sym, signee),
}
}
fn chain(ark_path: PathBuf, ask_path: PathBuf, vek_path: PathBuf, vek_type: &str) -> Result<Chain> {
Ok(Chain {
ca: ca::Chain {
ark: cert(ark_path, "ARK")?,
ask: cert(ask_path, "ASK")?,
},
vek: cert(vek_path, vek_type)?,
})
}
fn cert(path: PathBuf, name: &str) -> Result<Certificate> {
Certificate::from_bytes(
&read(path.clone()).context(format!("unable to read {}", path.display()))?,
)
.context(format!(
"unable to parse {} certificate from {}",
name,
path.display()
))
}
0707010000001C000081A400000000000000000000000166DA69EB00000941000000000000000000000000000000000000001C00000000snphost-0.5.0/src/config.rs// SPDX-License-Identifier: Apache-2.0
use super::*;
// Different config commands
#[derive(Subcommand)]
pub enum ConfigCmd {
/// Change the Platform Config (TCB and Mask chip) to the provided values
Set(set::Args),
/// Reset the SEV-SNP Config to the last comitted version
#[command(subcommand)]
Reset,
}
pub fn cmd(cmd: ConfigCmd) -> Result<()> {
match cmd {
ConfigCmd::Set(args) => set::set_config(args),
ConfigCmd::Reset => reset::reset_config(),
}
}
mod set {
use super::*;
#[derive(Parser)]
pub struct Args {
/// Bootloader version
/// (Unsigned 8-bit Integer)
#[arg(value_name = "bootloader", required = true)]
pub bootloader: u8,
/// PSP OS version (Unsigned 8-bit Integer)
#[arg(value_name = "tee", required = true)]
pub tee: u8,
/// Version of the SNP firmware (Unsigned 8-bit Integer)
#[arg(value_name = "snp-fw", required = true)]
pub snp_fw: u8,
/// Microcode Patch level of all the cores (Unsigned 8-bit Integer)
#[arg(value_name = "microcode", required = true)]
pub microcode: u8,
/// Change mask chip bit field (Unsigned 32-bit Integer) values by providing decimal representation of desired change (0-3). Bit[0]: CHIP_ID, Bit[1]: CHIP_KEY. Both are disabled by default
#[arg(value_name = "mask-chip", required = true)]
mask_chip: u32,
}
pub fn set_config(args: Args) -> Result<()> {
// Create Tcb with provided values
let tcb = TcbVersion::new(args.bootloader, args.tee, args.snp_fw, args.microcode);
// Create Mask Chip with provided value
let mask_chip = MaskId(args.mask_chip);
// Create new Config
let config = Config::new(tcb, mask_chip);
// Change Config
let mut fw = firmware()?;
fw.snp_set_config(config)
.map_err(|e| anyhow::anyhow!(format!("{:?}", e)))
.context("Error setting a new snp config")
}
}
mod reset {
use super::*;
pub fn reset_config() -> Result<()> {
let mut fw = firmware()?;
// Provide confing to set_config with all 0s
fw.snp_set_config(Config::default())
.map_err(|e| anyhow::anyhow!(format!("{:?}", e)))
.context("Error resetting SEV-SNP configuration")
}
}
0707010000001D000081A400000000000000000000000166DA69EB00000AAC000000000000000000000000000000000000001A00000000snphost-0.5.0/src/main.rs// SPDX-License-Identifier: Apache-2.0
#![deny(clippy::all)]
mod cert;
mod config;
mod processor;
mod show;
mod ok;
use cert::{export, fetch, import, verify};
use anyhow::{Context, Result};
use clap::{arg, Parser, Subcommand, ValueEnum};
use sev::firmware::host::*;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct SnpHost {
#[command(subcommand)]
pub cmd: SnpHostCmd,
/// Don't print anything to the console
#[arg(short, long, default_value_t = false)]
pub quiet: bool,
}
#[allow(clippy::large_enum_variant)]
/// Utilities for managing the SEV-SNP environment
#[derive(Subcommand)]
enum SnpHostCmd {
/// Display information about the SEV-SNP platform
#[command(subcommand)]
Show(show::Show),
/// Export a certificate chain from a kernel format file to a given directory
Export(export::Export),
/// Import a certificate chain to a file
Import(import::Import),
/// Probe system for SEV-SNP support
Ok,
/// Modify the SNP configuration
#[command(subcommand)]
Config(config::ConfigCmd),
/// Verify a certificate chain
Verify(verify::Verify),
/// Retrieve content from the AMD Key Distribution Server (KDS)
#[command(subcommand)]
Fetch(fetch::Fetch),
/// Commit current firmware and TCB versions to PSP
Commit,
}
// Commit command
mod commit {
use super::*;
pub fn cmd() -> Result<()> {
firmware()?.snp_commit()?;
Ok(())
}
}
fn firmware() -> Result<Firmware> {
Firmware::open().context("unable to open /dev/sev")
}
fn snp_platform_status() -> Result<SnpPlatformStatus> {
firmware()?
.snp_platform_status()
.map_err(|e| anyhow::anyhow!(format!("{:?}", e)))
.context("unable to retrieve SNP platform status")
}
fn sev_platform_status() -> Result<Status> {
firmware()?
.platform_status()
.map_err(|e| anyhow::anyhow!(format!("{:?}", e)))
.context("unable to retrieve SEV platform status")
}
fn main() -> Result<()> {
env_logger::init();
let snphost = SnpHost::parse();
let result = match snphost.cmd {
SnpHostCmd::Show(show) => show::cmd(show),
SnpHostCmd::Export(export) => export::cmd(export),
SnpHostCmd::Import(import) => import::cmd(import),
SnpHostCmd::Ok => ok::cmd(snphost.quiet),
SnpHostCmd::Config(subcmd) => config::cmd(subcmd),
SnpHostCmd::Verify(verify) => verify::cmd(verify, snphost.quiet),
SnpHostCmd::Fetch(fetch) => fetch::cmd(fetch),
SnpHostCmd::Commit => commit::cmd(),
};
if !snphost.quiet {
if let Err(ref e) = result {
eprintln!("ERROR: {}", e);
}
}
result
}
0707010000001E000081A400000000000000000000000166DA69EB00007D92000000000000000000000000000000000000001800000000snphost-0.5.0/src/ok.rs// SPDX-License-Identifier: Apache-2.0
use super::*;
use std::{
arch::x86_64,
fmt,
fs::{self, File},
mem::{transmute, MaybeUninit},
os::unix::io::AsRawFd,
str::from_utf8,
};
use colorful::*;
use msru::{Accessor, Msr};
type TestFn = dyn Fn() -> TestResult;
// SEV generation-specific bitmasks.
const SEV_MASK: usize = 1;
const ES_MASK: usize = 1 << 1;
const SNP_MASK: usize = 1 << 2;
struct Test {
name: &'static str,
gen_mask: usize,
run: Box<TestFn>,
sub: Vec<Test>,
}
struct TestResult {
name: String,
stat: TestState,
mesg: Option<String>,
}
#[derive(PartialEq, Eq)]
enum TestState {
Pass,
Skip,
Fail,
}
enum SevGeneration {
Sev,
Es,
Snp,
}
impl fmt::Display for TestState {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
TestState::Pass => format!("{}", "PASS".green()),
TestState::Skip => format!("{}", "SKIP".yellow()),
TestState::Fail => format!("{}", "FAIL".red()),
};
write!(f, "{}", s)
}
}
enum SnpStatusTest {
Tcb,
Rmp,
Snp,
}
enum SevStatusTests {
Sev,
Firmware,
Seves,
}
impl fmt::Display for SnpStatusTest {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
SnpStatusTest::Tcb => "Comparing TCB values",
SnpStatusTest::Rmp => "RMP INIT",
SnpStatusTest::Snp => "SNP INIT",
};
write!(f, "{}", s)
}
}
impl fmt::Display for SevStatusTests {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
SevStatusTests::Sev => "SEV INIT",
SevStatusTests::Firmware => "SEV Firmware Version",
SevStatusTests::Seves => "SEV-ES INIT",
};
write!(f, "{}", s)
}
}
fn collect_tests() -> Vec<Test> {
let tests = vec![
Test {
name: "AMD CPU",
gen_mask: SEV_MASK,
run: Box::new(|| {
let res = unsafe { x86_64::__cpuid(0x0000_0000) };
let name: [u8; 12] = unsafe { transmute([res.ebx, res.edx, res.ecx]) };
let name = from_utf8(&name[..]).unwrap_or("ERROR_FOUND");
let stat = if name == "AuthenticAMD" {
TestState::Pass
} else {
TestState::Fail
};
TestResult {
name: "AMD CPU".to_string(),
stat,
mesg: None,
}
}),
sub: vec![
Test {
name: "Microcode support",
gen_mask: SEV_MASK,
run: Box::new(|| {
let cpu_name = {
let mut bytestr = Vec::with_capacity(48);
for cpuid in 0x8000_0002_u32..=0x8000_0004_u32 {
let cpuid = unsafe { x86_64::__cpuid(cpuid) };
let mut bytes: Vec<u8> =
[cpuid.eax, cpuid.ebx, cpuid.ecx, cpuid.edx]
.iter()
.flat_map(|r| r.to_le_bytes().to_vec())
.collect();
bytestr.append(&mut bytes);
}
String::from_utf8(bytestr)
.unwrap_or_else(|_| "ERROR_FOUND".to_string())
.trim()
.to_string()
};
let stat = if cpu_name.to_uppercase().contains("EPYC") {
TestState::Pass
} else {
TestState::Fail
};
TestResult {
name: "Microcode support".to_string(),
stat,
mesg: None,
}
}),
sub: vec![],
},
Test {
name: "Secure Memory Encryption (SME)",
gen_mask: SEV_MASK,
run: Box::new(|| {
let res = unsafe { x86_64::__cpuid(0x8000_001f) };
let stat = if (res.eax & 0x1) != 0 {
TestState::Pass
} else {
TestState::Fail
};
TestResult {
name: "Secure Memory Encryption (SME)".to_string(),
stat,
mesg: None,
}
}),
sub: vec![Test {
name: "SME",
gen_mask: SEV_MASK,
run: Box::new(sme_test),
sub: vec![],
}],
},
Test {
name: "Secure Encrypted Virtualization (SEV)",
gen_mask: SEV_MASK,
run: Box::new(|| {
let res = unsafe { x86_64::__cpuid(0x8000_001f) };
let stat = if (res.eax & 0x1 << 1) != 0 {
TestState::Pass
} else {
TestState::Fail
};
TestResult {
name: "Secure Encrypted Virtualization (SEV)".to_string(),
stat,
mesg: None,
}
}),
sub: vec![
Test {
name: "Encrypted State (SEV-ES)",
gen_mask: ES_MASK,
run: Box::new(|| {
let res = unsafe { x86_64::__cpuid(0x8000_001f) };
let stat = if (res.eax & 0x1 << 3) != 0 {
TestState::Pass
} else {
TestState::Fail
};
TestResult {
name: "Encrypted State (SEV-ES)".to_string(),
stat,
mesg: None,
}
}),
sub: vec![Test {
name: "SEV-ES INIT",
gen_mask: ES_MASK,
run: Box::new(|| sev_ioctl(SevStatusTests::Seves)),
sub: vec![],
}],
},
Test {
name: "SEV INIT",
gen_mask: SNP_MASK,
run: Box::new(|| sev_ioctl(SevStatusTests::Sev)),
sub: vec![],
},
Test {
name: "Secure Nested Paging (SEV-SNP)",
gen_mask: SNP_MASK,
run: Box::new(|| {
let res = unsafe { x86_64::__cpuid(0x8000_001f) };
let stat = if (res.eax & 0x1 << 4) != 0 {
TestState::Pass
} else {
TestState::Fail
};
TestResult {
name: "Secure Nested Paging (SEV-SNP)".to_string(),
stat,
mesg: None,
}
}),
sub: vec![
Test {
name: "VM Permission Levels",
gen_mask: SNP_MASK,
run: Box::new(|| {
let res = unsafe { x86_64::__cpuid(0x8000_001f) };
let stat = if (res.eax & 0x1 << 5) != 0 {
TestState::Pass
} else {
TestState::Fail
};
TestResult {
name: "VM Permission Levels".to_string(),
stat,
mesg: None,
}
}),
sub: vec![Test {
name: "Number of VMPLs",
gen_mask: SNP_MASK,
run: Box::new(|| {
let res = unsafe { x86_64::__cpuid(0x8000_001f) };
let num_vmpls = (res.ebx & 0xF000) >> 12;
TestResult {
name: "Number of VMPLs".to_string(),
stat: TestState::Pass,
mesg: Some(format!("{}", num_vmpls)),
}
}),
sub: vec![],
}],
},
Test {
name: "SEV-SNP",
gen_mask: SNP_MASK,
run: Box::new(snp_test),
sub: vec![],
},
Test {
name: "SEV Firmware Version",
gen_mask: SNP_MASK,
run: Box::new(|| sev_ioctl(SevStatusTests::Firmware)),
sub: vec![],
},
Test {
name: "SNP INIT",
gen_mask: SNP_MASK,
run: Box::new(|| snp_ioctl(SnpStatusTest::Snp)),
sub: vec![],
},
],
},
Test {
name: "Physical address bit reduction",
gen_mask: SEV_MASK,
run: Box::new(|| {
let res = unsafe { x86_64::__cpuid(0x8000_001f) };
let field = (res.ebx & 0b1111_1100_0000) >> 6;
TestResult {
name: "Physical address bit reduction".to_string(),
stat: TestState::Pass,
mesg: Some(format!("{}", field)),
}
}),
sub: vec![],
},
Test {
name: "C-bit location",
gen_mask: SEV_MASK,
run: Box::new(|| {
let res = unsafe { x86_64::__cpuid(0x8000_001f) };
let field = res.ebx & 0b11_1111;
TestResult {
name: "C-bit location".to_string(),
stat: TestState::Pass,
mesg: Some(format!("{}", field)),
}
}),
sub: vec![],
},
Test {
name: "Number of encrypted guests supported simultaneously",
gen_mask: SEV_MASK,
run: Box::new(|| {
let res = unsafe { x86_64::__cpuid(0x8000_001f) };
let field = res.ecx;
TestResult {
name: "Number of encrypted guests supported simultaneously"
.to_string(),
stat: TestState::Pass,
mesg: Some(format!("{}", field)),
}
}),
sub: vec![],
},
Test {
name: "Minimum ASID value for SEV-enabled, SEV-ES disabled guest",
gen_mask: SEV_MASK,
run: Box::new(|| {
let res = unsafe { x86_64::__cpuid(0x8000_001f) };
let field = res.edx;
TestResult {
name:
"Minimum ASID value for SEV-enabled, SEV-ES disabled guest"
.to_string(),
stat: TestState::Pass,
mesg: Some(format!("{}", field)),
}
}),
sub: vec![],
},
Test {
name: "/dev/sev readable",
gen_mask: SEV_MASK,
run: Box::new(dev_sev_r),
sub: vec![],
},
Test {
name: "/dev/sev writable",
gen_mask: SEV_MASK,
run: Box::new(dev_sev_w),
sub: vec![],
},
],
},
Test {
name: "Page flush MSR",
gen_mask: SEV_MASK,
run: Box::new(|| {
let res = unsafe { x86_64::__cpuid(0x8000_001f) };
let msr_flag = if (res.eax & 0x1 << 2) != 0 {
"ENABLED".green()
} else {
"DISABLED".yellow()
};
let name = format!("Page flush MSR: {}", msr_flag);
TestResult {
name,
/*
* Page flush MSR can be enabled/disabled.
* Therefore, if the flag is disabled, it doesn't
* necessarily mean that Page flush MSR *isn't*
* supported, but rather that it is supported yet
* currently disabled. So instead of returning
* TestState::Fail (indicating that Page flush MSR
* isn't supported), return TestState::Pass and
* indicate to the caller whether it is enabled or
* disabled.
*/
stat: TestState::Pass,
mesg: None,
}
}),
sub: vec![],
},
],
},
Test {
name: "KVM Support",
gen_mask: SEV_MASK,
run: Box::new(has_kvm_support),
sub: vec![
Test {
name: "SEV enabled in KVM",
gen_mask: SEV_MASK,
run: Box::new(|| sev_enabled_in_kvm(SevGeneration::Sev)),
sub: vec![],
},
Test {
name: "SEV-ES enabled in KVM",
gen_mask: ES_MASK,
run: Box::new(|| sev_enabled_in_kvm(SevGeneration::Es)),
sub: vec![],
},
Test {
name: "SEV-SNP enabled in KVM",
gen_mask: SNP_MASK,
run: Box::new(|| sev_enabled_in_kvm(SevGeneration::Snp)),
sub: vec![],
},
],
},
Test {
name: "memlock limit",
gen_mask: SEV_MASK,
run: Box::new(memlock_rlimit),
sub: vec![],
},
Test {
name: "Read RMP tables",
gen_mask: SNP_MASK,
run: Box::new(get_rmp_address),
sub: vec![],
},
Test {
name: "RMP INIT",
gen_mask: SNP_MASK,
run: Box::new(|| snp_ioctl(SnpStatusTest::Rmp)),
sub: vec![],
},
Test {
name: "Compare TCB values",
gen_mask: SNP_MASK,
run: Box::new(|| snp_ioctl(SnpStatusTest::Tcb)),
sub: vec![],
},
];
tests
}
const INDENT: usize = 2;
pub fn cmd(quiet: bool) -> Result<()> {
let tests = collect_tests();
if run_test(&tests, 0, quiet, SEV_MASK | ES_MASK | SNP_MASK) {
Ok(())
} else {
Err(anyhow::anyhow!(
"One or more tests in sevctl-ok reported a failure"
))
}
}
fn run_test(tests: &[Test], level: usize, quiet: bool, mask: usize) -> bool {
let mut passed = true;
for t in tests {
// Skip tests that aren't included in the specified generation.
if (t.gen_mask & mask) != t.gen_mask {
test_gen_not_included(t, level, quiet);
continue;
}
let res = (t.run)();
emit_result(&res, level, quiet);
match res.stat {
TestState::Pass => {
if !run_test(&t.sub, level + INDENT, quiet, mask) {
passed = false;
}
}
TestState::Fail => {
passed = false;
emit_skip(&t.sub, level + INDENT, quiet);
}
// Skipped tests are marked as skip before recursing. They are just emitted and not actually processed.
TestState::Skip => unreachable!(),
}
}
passed
}
fn emit_result(res: &TestResult, level: usize, quiet: bool) {
if !quiet {
let msg = match &res.mesg {
Some(m) => format!(": {}", m),
None => "".to_string(),
};
println!(
"[ {:^4} ] {:width$}- {}{}",
format!("{}", res.stat),
"",
res.name,
msg,
width = level
)
}
}
fn test_gen_not_included(test: &Test, level: usize, quiet: bool) {
if !quiet {
let tr_skip = TestResult {
name: test.name.to_string(),
stat: TestState::Skip,
mesg: None,
};
println!(
"[ {:^4} ] {:width$}- {}",
format!("{}", tr_skip.stat),
"",
tr_skip.name,
width = level
);
emit_skip(&test.sub, level + INDENT, quiet);
}
}
fn emit_skip(tests: &[Test], level: usize, quiet: bool) {
if !quiet {
for t in tests {
let tr_skip = TestResult {
name: t.name.to_string(),
stat: TestState::Skip,
mesg: None,
};
println!(
"[ {:^4} ] {:width$}- {}",
format!("{}", tr_skip.stat),
"",
tr_skip.name,
width = level
);
emit_skip(&t.sub, level + INDENT, quiet);
}
}
}
fn dev_sev_r() -> TestResult {
let (stat, mesg) = match dev_sev_rw(fs::OpenOptions::new().read(true)) {
Ok(_) => (TestState::Pass, "/dev/sev readable".to_string()),
Err(e) => (TestState::Fail, format!("/dev/sev not readable: {}", e)),
};
TestResult {
name: "Reading /dev/sev".to_string(),
stat,
mesg: Some(mesg),
}
}
fn dev_sev_w() -> TestResult {
let (stat, mesg) = match dev_sev_rw(fs::OpenOptions::new().write(true)) {
Ok(_) => (TestState::Pass, "/dev/sev writable".to_string()),
Err(e) => (TestState::Fail, format!("/dev/sev not writable: {}", e)),
};
TestResult {
name: "Writing /dev/sev".to_string(),
stat,
mesg: Some(mesg),
}
}
fn dev_sev_rw(file: &fs::OpenOptions) -> Result<()> {
let path = "/dev/sev";
match file.open(path) {
Ok(_) => Ok(()),
Err(e) => Err(anyhow::Error::new(Box::new(e))),
}
}
fn has_kvm_support() -> TestResult {
let path = "/dev/kvm";
let (stat, mesg) = match File::open(path) {
Ok(kvm) => {
let api_version = unsafe { libc::ioctl(kvm.as_raw_fd(), 0xAE00, 0) };
if api_version < 0 {
(
TestState::Fail,
"Error - accessing KVM device node failed".to_string(),
)
} else {
(TestState::Pass, format!("API version: {}", api_version))
}
}
Err(e) => (TestState::Fail, format!("Error reading {}: ({})", path, e)),
};
TestResult {
name: "KVM supported".to_string(),
stat,
mesg: Some(mesg),
}
}
fn sev_enabled_in_kvm(gen: SevGeneration) -> TestResult {
let path_loc = match gen {
SevGeneration::Sev => "/sys/module/kvm_amd/parameters/sev",
SevGeneration::Es => "/sys/module/kvm_amd/parameters/sev_es",
SevGeneration::Snp => "/sys/module/kvm_amd/parameters/sev_snp",
};
let path = std::path::Path::new(path_loc);
let (stat, mesg) = if path.exists() {
match std::fs::read_to_string(path_loc) {
Ok(result) => {
if result.trim() == "1" || result.trim() == "Y" {
(TestState::Pass, "enabled".to_string())
} else {
(
TestState::Fail,
format!("Error - contents read from {}: {}", path_loc, result.trim()),
)
}
}
Err(e) => (
TestState::Fail,
format!("Error - (unable to read {}): {}", path_loc, e,),
),
}
} else {
(
TestState::Fail,
format!("Error - {} does not exist", path_loc),
)
};
TestResult {
name: match gen {
SevGeneration::Sev => "SEV enabled in KVM",
SevGeneration::Es => "SEV-ES enabled in KVM",
SevGeneration::Snp => "SEV-SNP enabled in KVM",
}
.to_string(),
stat,
mesg: Some(mesg),
}
}
fn memlock_rlimit() -> TestResult {
let mut rlimit = MaybeUninit::uninit();
let res = unsafe { libc::getrlimit(libc::RLIMIT_MEMLOCK, rlimit.as_mut_ptr()) };
let (stat, mesg) = if res == 0 {
let r = unsafe { rlimit.assume_init() };
(
TestState::Pass,
format!("Soft: {} | Hard: {}", r.rlim_cur, r.rlim_max),
)
} else {
(
TestState::Fail,
"Unable to retrieve memlock resource limits".to_string(),
)
};
TestResult {
name: "Memlock resource limit".to_string(),
stat,
mesg: Some(mesg),
}
}
fn msr_bit_read(reg: u32, cpu: u16) -> Result<u64, anyhow::Error> {
let mut msr = Msr::new(reg, cpu).context("Error Reading MSR")?;
let raw_value = msr.read()?;
Ok(raw_value)
}
fn sme_test() -> TestResult {
let raw_value = match msr_bit_read(0xC0010010, 0) {
Ok(raw) => raw,
Err(e) => {
return TestResult {
name: "SME".to_string(),
stat: TestState::Fail,
mesg: format!("MSR read failed: {}", e).into(),
}
}
};
let (testres, mesg) = match raw_value >> 23 & 1 {
1 => (TestState::Pass, "Enabled in MSR"),
0 => (TestState::Fail, "Disabled in MSR"),
_ => unreachable!(),
};
TestResult {
name: "SME".to_string(),
stat: testres,
mesg: Some(mesg.to_string()),
}
}
fn snp_test() -> TestResult {
let raw_value = match msr_bit_read(0xC0010010, 0) {
Ok(raw) => raw,
Err(e) => {
return TestResult {
name: "SNP".to_string(),
stat: TestState::Fail,
mesg: format!("MSR read failed: {}", e).into(),
}
}
};
let (testres, mesg) = match raw_value >> 24 & 1 {
1 => (TestState::Pass, "Enabled in MSR"),
0 => (TestState::Fail, "Disabled in MSR"),
_ => unreachable!(),
};
TestResult {
name: "SNP".to_string(),
stat: testres,
mesg: Some(mesg.to_string()),
}
}
fn get_rmp_address() -> TestResult {
let rmp_base = match msr_bit_read(0xC0010132, 0) {
Ok(raw) => raw,
Err(e) => {
return TestResult {
name: "Reading RMP table".to_string(),
stat: TestState::Fail,
mesg: format!("Failed to read the desired MSR: {}", e).into(),
}
}
};
let rmp_end = match msr_bit_read(0xC0010133, 0) {
Ok(raw) => raw,
Err(e) => {
return TestResult {
name: "Reading RMP table".to_string(),
stat: TestState::Fail,
mesg: format!("Failed to read the desired MSR: {}", e).into(),
}
}
};
if rmp_base == 0 || rmp_end == 0 {
TestResult {
name: "Reading RMP table".to_string(),
stat: TestState::Fail,
mesg: Some("RMP table was not read successfully".into()),
}
} else {
TestResult {
name: "RMP table addresses".to_string(),
stat: TestState::Pass,
mesg: format!("Addresses: {} - {}", rmp_base, rmp_end).into(),
}
}
}
fn snp_ioctl(test: SnpStatusTest) -> TestResult {
let status = match snp_platform_status() {
Ok(stat) => stat,
Err(e) => {
return TestResult {
name: test.to_string(),
stat: TestState::Fail,
mesg: Some(format!("Failed to get SNP Platform status {e}")),
}
}
};
match test {
SnpStatusTest::Tcb => {
if status.platform_tcb_version == status.reported_tcb_version {
TestResult{
name: format!("{}", SnpStatusTest::Tcb),
stat: TestState::Pass,
mesg: format!("TCB versions match \n\n Platform TCB version: {} \n Reported TCB version: {}",
status.platform_tcb_version, status.reported_tcb_version).into()
}
} else {
TestResult {
name: format!("{}", SnpStatusTest::Tcb),
stat: TestState::Fail,
mesg: format!("The TCB versions did NOT match \n\n Platform TCB version: {} \n Reported TCB version: {}",
status.platform_tcb_version, status.reported_tcb_version).into(),
}
}
}
SnpStatusTest::Rmp => {
if status.is_rmp_init == 1 {
TestResult {
name: format!("{}", SnpStatusTest::Rmp),
stat: TestState::Pass,
mesg: Some("RMP is INIT".to_string()),
}
} else {
TestResult {
name: format!("{}", SnpStatusTest::Rmp),
stat: TestState::Fail,
mesg: Some("RMP is UNINIT".to_string()),
}
}
}
SnpStatusTest::Snp => {
if status.state == 1 {
TestResult {
name: format!("{}", SnpStatusTest::Snp),
stat: TestState::Pass,
mesg: Some("SNP is INIT".to_string()),
}
} else {
TestResult {
name: format!("{}", SnpStatusTest::Snp),
stat: TestState::Fail,
mesg: Some("SNP is UNINIT".to_string()),
}
}
}
}
}
fn sev_ioctl(test: SevStatusTests) -> TestResult {
let status = match sev_platform_status() {
Ok(stat) => stat,
Err(e) => {
return TestResult {
name: test.to_string(),
stat: TestState::Fail,
mesg: Some(format!("Failed to get SEV Platform Status {e}")),
}
}
};
match test {
SevStatusTests::Sev => {
if status.state == State::Working {
TestResult {
name: format!("{}", SevStatusTests::Sev),
stat: TestState::Pass,
mesg: Some("SEV is INIT and currently running a guest".to_string()),
}
} else if status.state == State::Initialized {
TestResult {
name: format!("{}", SevStatusTests::Sev),
stat: TestState::Pass,
mesg: Some("SEV is INIT, but not currently running a guest".to_string()),
}
} else {
TestResult {
name: format!("{}", SevStatusTests::Sev),
stat: TestState::Fail,
mesg: Some("SEV is UNINIT".to_string()),
}
}
}
SevStatusTests::Firmware => {
if status.build.version == 0.into() {
TestResult {
name: format!("{}", SevStatusTests::Firmware),
stat: TestState::Fail,
mesg: Some(format!(
"Invalid Firmware version: {}",
status.build.version
)),
}
} else if status.build.version.minor < 51 {
TestResult {
name: format!("{}", SevStatusTests::Firmware),
stat: TestState::Fail,
mesg: format!(
"SEV firmware version needs to be at least 1.51,
current firmware version: {}",
status.build.version
)
.into(),
}
} else {
TestResult {
name: format!("{}", SevStatusTests::Firmware),
stat: TestState::Pass,
mesg: format!("Sev firmware version: {}", status.build.version).into(),
}
}
}
SevStatusTests::Seves => {
let (res, mesg) = match status.flags.bits() >> 8 & 1 {
1 => (TestState::Pass, "Enabled"),
0 => (TestState::Fail, "Disabled"),
_ => unreachable!(),
};
TestResult {
name: format!("{}", SevStatusTests::Seves),
stat: res,
mesg: Some(mesg.to_string()),
}
}
}
}
0707010000001F000081A400000000000000000000000166DA69EB00000CFB000000000000000000000000000000000000001F00000000snphost-0.5.0/src/processor.rs// SPDX-License-Identifier: Apache-2.0
use anyhow::{anyhow, Result};
use std::arch::x86_64;
pub enum ProcessorGeneration {
Milan,
Genoa,
Bergamo,
Siena,
Turin,
}
impl ProcessorGeneration {
// Get the SEV generation of the processor currently running on the machine.
// To do this, we execute a CPUID (label 0x80000001) and read the EAX
// register as an array of bytes (each byte representing 8 bits of a 32-bit
// value, thus the array is 4 bytes long). The formatting for these values is
// as follows:
//
// Base model: bits 4:7
// Base family: bits 8:11
// Extended model: bits 16:19
// Extended family: bits 20:27
//
// Extract the bit values from the array, and use them to calculate the MODEL
// and FAMILY of the processor.
//
// The family calculation is as follows:
//
// FAMILY = Base family + Extended family
//
// The model calculation is a follows:
//
// MODEL = Base model | (Extended model << 4)
//
// Compare these values with the models and families of known processor generations to
// determine which generation the current processor is a part of.
pub(crate) fn current() -> Result<Self> {
let cpuid = unsafe { x86_64::__cpuid(0x8000_0001) };
// Bits 31:28 are used to differentiate between Bergamo and Siena machines.
let socket = (cpuid.ebx & 0xF0000000u32) >> 0x1C;
let bytes: Vec<u8> = cpuid.eax.to_le_bytes().to_vec();
let base_model = (bytes[0] & 0xF0) >> 4;
let base_family = bytes[1] & 0x0F;
let ext_model = bytes[2] & 0x0F;
let ext_family = {
let low = (bytes[2] & 0xF0) >> 4;
let high = (bytes[3] & 0x0F) << 4;
low | high
};
let model = (ext_model << 4) | base_model;
let family = base_family + ext_family;
match family {
0x19 => match model {
0x0..=0xF => Ok(Self::Milan),
0x10..=0x1F => Ok(Self::Genoa),
0xA0..=0xAF => match socket {
0x4 => Ok(Self::Bergamo),
0x8 => Ok(Self::Siena),
_ => Err(anyhow!("processor is not of a known SEV-SNP generation")),
},
_ => Err(anyhow!("processor is not of a known SEV-SNP model")),
},
0x1A => match model {
0x0..=0x11 => Ok(Self::Turin),
_ => Err(anyhow!("processor is not of a known SEV-SNP model")),
},
_ => Err(anyhow!("processor is not of a known SEV-SNP family")),
}
}
pub(crate) fn to_kds_url(&self) -> String {
match self {
Self::Genoa | Self::Bergamo | Self::Siena => &Self::Genoa,
_ => self,
}
.to_string()
}
}
impl std::fmt::Display for ProcessorGeneration {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Self::Milan => "Milan",
Self::Genoa => "Genoa",
Self::Bergamo => "Bergamo",
Self::Siena => "Siena",
Self::Turin => "Turin",
}
)
}
}
07070100000020000081A400000000000000000000000166DA69EB0000049F000000000000000000000000000000000000001A00000000snphost-0.5.0/src/show.rs// SPDX-License-Identifier: Apache-2.0
use super::*;
use cert::fetch::vcek::vcek_url;
#[derive(Subcommand)]
pub enum Show {
/// Show the current number of guests
Guests,
/// Show the platform identifier
Identifier,
/// Show the current platform and reported TCB version
Tcb,
/// Show the VCEK DER download URL
VcekUrl,
/// Show the platform's firmware version
Version,
}
pub fn cmd(show: Show) -> Result<()> {
let status = snp_platform_status()?;
match show {
Show::Guests => println!("{}", status.guest_count),
Show::Identifier => {
let id = firmware()?
.get_identifier()
.map_err(|e| anyhow::anyhow!(format!("{:?}", e)))
.context("error fetching identifier")?;
println!("{}", id);
}
Show::Tcb => println!(
"Reported TCB: {}\nPlatform TCB: {}",
status.reported_tcb_version, status.platform_tcb_version
),
Show::VcekUrl => {
let url = vcek_url()?;
println!("{}", url);
}
Show::Version => println!("{}", status.version),
}
Ok(())
}
07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!214 blocks