mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
rust/pv: Fix padding of retrievable private keys
Fix the padding of keys that are smaller than the architected slot for
the retrievable key. Previously the keys where appended with zeros.
However, processing software expects a left-padding.
Affected key types:
* Ed448
* SecP521
While at it, fix documentation in the retrievable key struct.
Fixes: fd024387d7 ("rust/pv: Retrievable secrets support")
Acked-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
7bd159de1d
commit
26d2e2d786
@@ -146,7 +146,8 @@ pub enum EcCurves {
|
||||
}
|
||||
|
||||
impl EcCurves {
|
||||
const fn exp_size(&self) -> usize {
|
||||
/// Returns the expected key-byte-size for this curve.
|
||||
pub const fn exp_key_size(&self) -> usize {
|
||||
match self {
|
||||
Self::Secp256R1 => 32,
|
||||
Self::Secp384R1 => 48,
|
||||
@@ -155,14 +156,6 @@ impl EcCurves {
|
||||
Self::Ed448 => 64,
|
||||
}
|
||||
}
|
||||
|
||||
/// Resizes the raw key to the expected size.
|
||||
///
|
||||
/// See [`Vec::resize`]
|
||||
pub fn resize_raw_key(&self, mut raw: Vec<u8>) -> Vec<u8> {
|
||||
raw.resize(self.exp_size(), 0);
|
||||
raw
|
||||
}
|
||||
}
|
||||
|
||||
// The names have to stay constant, otherwise the PEM contains invalid types
|
||||
|
||||
Reference in New Issue
Block a user