mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
generate actual private keys instead of using random data
by doing this we make this safer by ensuring that the public keys are valid public keys, allowing us to sign these images with production keys and not accidentally signing a weak public key.
This commit is contained in:
parent
0caf0bb2d7
commit
cf267f096c
2 changed files with 13 additions and 3 deletions
|
|
@ -22,7 +22,7 @@ pem = "0.8.3"
|
|||
svd2utra = "0.1.25"
|
||||
xmas-elf = "0.9.0"
|
||||
xous-semver = "0.1.5"
|
||||
ed25519-dalek = { version = "2.1.0", features = ["digest"] }
|
||||
ed25519-dalek = { version = "2.1.0", features = ["digest", "rand_core"] }
|
||||
sha2 = { version = "0.10.8" }
|
||||
pkcs8 = { version = "0.8.0", features = ["pem"] }
|
||||
base64 = "0.20.0"
|
||||
|
|
|
|||
|
|
@ -242,10 +242,20 @@ pub fn sign_image(
|
|||
dst.populate_from(src);
|
||||
}
|
||||
} else {
|
||||
// populate with fake, random data. The data changes every time.
|
||||
// populate with a random key. Use actual key generation to ensure that the committed
|
||||
// public key is actually a valid public key.
|
||||
for dst in header.sealed_data.pubkeys.iter_mut() {
|
||||
use ed25519_dalek::VerifyingKey;
|
||||
use rand::rngs::OsRng;
|
||||
|
||||
let mut fake_pk = Pubkey::default();
|
||||
rand::rngs::OsRng.fill_bytes(&mut fake_pk.pk);
|
||||
// Generate a random signing (private) key
|
||||
let signing_key = SigningKey::generate(&mut OsRng);
|
||||
// Derive the verifying (public) key
|
||||
let verifying_key: VerifyingKey = signing_key.verifying_key();
|
||||
let public_bytes = verifying_key.to_bytes();
|
||||
fake_pk.pk.copy_from_slice(&public_bytes);
|
||||
|
||||
rand::rngs::OsRng.fill_bytes(&mut fake_pk.tag);
|
||||
dst.populate_from(&fake_pk);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue