Commit Graph

11 Commits

Author SHA1 Message Date
Marc Hartmayer
e4e455630b pv + tools: Introduce versioned HostKey and Keyslot enums
Add a HostKey enum (currently V1(PKey<Public>)) and introduce a
versioned Keyslot enum (V1(KeyslotV1)). Rename the existing Keyslot type
to KeyslotV1 to prepare for future format extensions.

Update pv, pvattest, pvimg, and pvsecret to use the new enums.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Timo Keller <tkeller@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:45 +02:00
Marc Hartmayer
f8fb9ce32a rust: Run rustfmt with some experimental options
+ Sort and group the imports
+ Normalize and format comments (100 characters width)

Command used:

$ cargo +nightly fmt --

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:02 +02:00
Steffen Eiden
c403208332 rust: Apply suggested fixes from clippy
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:40:51 +01:00
Steffen Eiden
8929d21948 rust: Upgrade zerocopy dependency to 0.8.X
This enables some const constructors, Dataful Enums,
Dynamically Sized Types and much more.

v0.8 introduces breaking changes including, but not limited to:
  - Rename AsBytes to IntoBytes
  - Fine-grain (derive) Traits that need to be implemented on top.
  - Rename FromZeroes to FromZeros
for which this patch takes care of as well.

Also a direct FromZeros derive is no longer necessary. As it is touched
anyways, remove it where appropriate.

See: https://github.com/google/zerocopy/discussions/1680

Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-05-05 17:20:37 +02:00
Marc Hartmayer
4cd7e8fd9a rust/crypto: Improve AEAD en-/decryption functions
Rename "Authenticated Encryption with Associated Data" (AEAD)
encryption/decryption functions and change the result type. This makes
the functions easier extendable. In addition, it's now possible to use
the functions as following:

`encrypt(decrypt(data)) == decrypt(encrypt(data) == data`

Add more AES and SHA related constants and use them whenever possible.
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2024-11-22 17:20:02 +01:00
Steffen Eiden
339ad5c2ed rust/pv: Add new attestation additional-data flags
Add additional data for the Attestation request. The secret store hash
measures all added secrets and the state of the store (locked or not)
with a single hash. The hash is computed by concatenating all add-secret
request tags (16 bytes each) and a byte stating the locked state (1 for
locked, 0 for not locked). The firmware state is an opaque state
description of the systems firmware status to be interpreted by an IBM
service. Add request flags and fields in the additional data structure.
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2024-11-22 17:20:01 +01:00
Steffen Eiden
413adbe7bb rust/pv: Rename additional-data size constant
Rename 'ATT_ADD_HASH_SIZE' to 'PHKH_SIZE'. The new name describes the
value better. It is the size of the Public Host-Key Hash and not the
size of a generic additional-data item.
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2024-11-22 17:20:00 +01:00
Steffen Eiden
db6c500e6d rust/pv: Get authenticated data from a binary attestation request
Allows API users to inspect the value of additional data to use it as
part of a policy check.
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2024-11-22 17:18:37 +01:00
Steffen Eiden
d30d272523 rust: Use Self wherever possible
Use Self instead of the struct name whenever possible.
Automagically replace struct name with Self:
`cargo clippy --fix -- -W clippy::use_self`

This streamlines the code.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2024-10-25 11:57:44 +02:00
Steffen Eiden
4d57ff046d rust: Prepare Cargo.toml for crates.io
Renames pv crate to s390_pv and pv_core to s390_pv_core. pv was already
taken on crates.io.

Bump the versions of all crates to 0.10.0. From now on we follow Semver
compatibility rules when it comes to updates. patch-level updates will
not introduce any backwards incompatible changes. For now all crates in
this directory will have the same version number. A version update may,
therefore, not add any new things.

Library users in this repository still use the non prefixed names and
rename the crate in the Cargo.toml. Doc-tests have to use the new name
however.

Add some Cargo metadata to the Cargo.toml.

Acked-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2024-05-27 16:53:57 +02:00
Steffen Eiden
61c5d7d431 rust/pv: Attestation generation and verification support
Add functionality to generate Attestation Measurement requests.
Add functionality to verify Attestation Measurement responses.

Acked-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2024-05-27 16:53:32 +02:00