refactor(crypto): hash and encrypt through stela-crypto in the mount crates

This commit is contained in:
Tyler Smith committed 2026-10-29 20:04:17 +00:00
1 parent 0dacca4c66
commit 1ebaeb3fd6
59 files changed
+94 -101

No files matched your search

Generated
+3 -5
View File
@@ -2208,7 +2208,7 @@ dependencies = [
name = "stela-driver-core"
version = "0.1.0"
dependencies = [
"sha2",
"stela-crypto",
]
[[package]]
@@ -2221,7 +2221,6 @@ dependencies = [
"libc",
"object",
"p256",
"sha1",
"sha2",
"stela-crypto",
"stela-driver-core",
@@ -2239,7 +2238,6 @@ dependencies = [
"libc",
"serde",
"serde_json",
"sha2",
"stela-compiler",
"stela-contracts",
"stela-crypto",
@@ -2284,6 +2282,7 @@ dependencies = [
"serde_json",
"sha2",
"stela-contracts",
"stela-crypto",
"stela-driver-core",
"stela-engine",
"stela-formats",
@@ -2295,7 +2294,7 @@ dependencies = [
name = "stela-metal-input"
version = "0.1.0"
dependencies = [
"sha2",
"stela-crypto",
]
[[package]]
@@ -2316,7 +2315,6 @@ dependencies = [
"rustls",
"serde",
"serde_json",
"sha1",
"sha2",
"smoltcp",
"stela-compiler",
+2 -1
View File
@@ -14,7 +14,6 @@ native-acpi = ["stela-drivers/native-acpi"]
stela-crypto = { path = "../stela-crypto" }
stela-drivers = { path = "../stela-drivers" }
serde_json = { version = "1", default-features = false, features = ["alloc"] }
sha2 = { version = "0.10", default-features = false }
uefi-raw = "0.17"
# The freestanding crates for stela.efi; on the host, as `stela setup` and
@@ -39,6 +38,8 @@ stela-soc-data = { path = "../stela-soc-data" }
[dev-dependencies]
serde_json.workspace = true
# An independent SHA-256 the tests check digests against.
sha2 = { version = "0.10", default-features = false }
[lints]
workspace = true
@@ -411,8 +411,8 @@ impl<'a> Source<'a> {
profile: CpuProfile,
host: &[native::CoreClass],
) -> Result<Prepared<'s>> {
use sha2::Digest;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
let resources = self.resources.resources();
if resources.slots.len() != roster.cores().len() {
return Err(refuse!(
+1 -1
View File
@@ -5,9 +5,9 @@ mod clpc;
mod cpus;
use crate::Result;
use alloc::{collections::BTreeSet, string::String, vec::Vec};
use sha2::Digest;
use stela_contracts::refuse;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
use stela_loader::{apple_device_tree::DeviceTree, boot_bundle::ORIGINAL_DEVICE_TREE_FILE};
use {
stela_contracts::Chip, stela_formats::boot_bundle::Manifest,
+1 -1
View File
@@ -5,8 +5,8 @@ use crate::Result;
use crate::handoff_records::Region;
use alloc::{format, sync::Arc, vec::Vec};
use core::fmt;
use sha2::Digest;
use stela_contracts::refuse;
use stela_crypto::digest::Digest;
use stela_drivers::firmware::{Catalog, Provider, Requirement, Target};
use stela_drivers::net::wifi::intel::platform::{
CapturedVariable, Observation, Observations, VARIABLE_DESCRIPTORS,
@@ -4,8 +4,8 @@
//! DSP0134 §5.2 authorize reading their published tables. Never use this after
//! root replacement/EBS, or for undescribed/reserved/MMIO/protected memory.
use crate::handoff_records::Region;
use sha2::Digest;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
use stela_drivers::firmware::smbios::{self, Error, Format, MAX_ENTRY_BYTES};
use uefi_raw::table::boot::MemoryType;
@@ -2,9 +2,9 @@
//! copied observations and immutable LOADER_DATA regions leave this module.
use crate::Result;
use crate::handoff_records::Region;
use sha2::Digest;
use stela_contracts::refuse;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
use stela_drivers::net::wifi::intel::platform::{Observation, Stage, Variable};
use uefi_raw::Status;
+2 -10
View File
@@ -862,8 +862,6 @@ name = "stela-boot"
version = "0.1.0"
dependencies = [
"serde_json",
"sha1",
"sha2",
"stela-boot-core",
"stela-compiler",
"stela-contracts",
@@ -883,7 +881,6 @@ name = "stela-boot-core"
version = "0.1.0"
dependencies = [
"serde_json",
"sha2",
"stela-compiler",
"stela-contracts",
"stela-crypto",
@@ -929,20 +926,18 @@ dependencies = [
name = "stela-driver-core"
version = "0.1.0"
dependencies = [
"sha2",
"stela-crypto",
]
[[package]]
name = "stela-drivers"
version = "0.1.0"
dependencies = [
"aes 0.8.4",
"cc",
"hmac",
"libc",
"object",
"p256",
"sha1",
"sha2",
"stela-crypto",
"stela-driver-core",
@@ -959,7 +954,6 @@ dependencies = [
"libc",
"serde",
"serde_json",
"sha2",
"stela-compiler",
"stela-contracts",
"stela-crypto",
@@ -985,7 +979,6 @@ dependencies = [
"miniz_oxide",
"serde",
"serde_json",
"sha1",
"sha2",
"stela-contracts",
"stela-crypto",
@@ -1001,6 +994,7 @@ dependencies = [
"serde_json",
"sha2",
"stela-contracts",
"stela-crypto",
"stela-driver-core",
"stela-formats",
"stela-soc-data",
@@ -1010,7 +1004,6 @@ dependencies = [
name = "stela-runtime"
version = "0.1.0"
dependencies = [
"aes 0.8.4",
"crypto-bigint",
"hex",
"hmac",
@@ -1020,7 +1013,6 @@ dependencies = [
"p256",
"serde",
"serde_json",
"sha1",
"sha2",
"smoltcp",
"stela-compiler",
-9
View File
@@ -43,15 +43,6 @@ stela-runtime = { path = "../stela-runtime", default-features = false }
stela-loader = { path = "../stela-loader", default-features = false }
stela-compiler = { path = "../stela-compiler", default-features = false }
serde_json = { version = "1", default-features = false, features = ["alloc"] }
# The soft-float UEFI target cannot codegen the optional hardware intrinsics in the local
# LLVM toolchain. Use the crate's real baseline SHA implementation.
sha2 = { version = "0.10", default-features = false, features = ["force-soft"] }
# LLVM cannot codegen the SHA-1 x86 intrinsics for the soft-float UEFI
# target. Unify this existing transitive dependency on its real software
# backend only for the boot target; hosted runtime keeps its normal selection.
[target.'cfg(target_os = "uefi")'.dependencies]
sha1 = { version = "0.10", default-features = false, features = ["force-soft"] }
[profile.dev]
panic = "abort"
+1 -1
View File
@@ -4,9 +4,9 @@ use super::bundle::Bytes;
use crate::Result;
use crate::{firmware, handoff::Region, output, paging::PAGE};
use alloc::boxed::Box;
use sha2::Digest;
use stela_contracts::refuse;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
use stela_drivers::block::{BlockDevice, Shared};
use stela_runtime::{
pc::{boot_log, fat32::Fat32, fdr_store, gpt::Guid},
+1 -1
View File
@@ -27,10 +27,10 @@ use crate::{
};
use alloc::string::ToString;
use alloc::{format, string::String, vec, vec::Vec};
use sha2::Digest;
use stela_boot_core::screen::{disk_size as size, window};
use stela_contracts::refuse;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
use uefi::{
Handle,
boot::{self, OpenProtocolAttributes, OpenProtocolParams, ScopedProtocol},
@@ -13,9 +13,9 @@ use core::{
ops::Range,
sync::atomic::{AtomicU64, Ordering},
};
use sha2::Digest;
use stela_contracts::refuse;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
use stela_drivers::{
Clock,
bus::{
@@ -287,8 +287,8 @@ impl Prepared {
Ok(format!(
"INTx gsi=22 high+shared+level vector={vector:#x} first=2 second=1 hold→EOI→retrigger=verified RemoteIRR=observed/drained group_refs=released late_delivery=absent DSDT={:x} MADT={:x} FADT={:x} SCI_gsi={} SCI_polarity={:?} SCI_trigger={:?}",
Sha256::digest(self.dsdt),
sha2::digest::generic_array::GenericArray::from(self.madt_hash),
sha2::digest::generic_array::GenericArray::from(self.fadt_hash),
stela_crypto::digest::generic_array::GenericArray::from(self.madt_hash),
stela_crypto::digest::generic_array::GenericArray::from(self.fadt_hash),
self.sci.gsi,
self.sci.polarity,
self.sci.trigger
+1 -1
View File
@@ -9,8 +9,8 @@ use core::{
mem::ManuallyDrop,
sync::atomic::{AtomicU64, Ordering},
};
use sha2::Digest;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
use stela_drivers::{
bus::{
irq::{IrqError, LineRoute, Platform},
+1 -1
View File
@@ -15,11 +15,11 @@ use core::{
ptr::NonNull,
sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering},
};
use sha2::Digest;
use stela_boot_core::work_check_fixture as fixture;
use stela_contracts::Refusal;
use stela_contracts::refuse;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
use stela_drivers::{
Clock,
platform::work::{
+1 -1
View File
@@ -24,9 +24,9 @@ use alloc::{
vec,
vec::Vec,
};
use sha2::Digest;
use stela_contracts::refuse;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
use uefi::{
CString16, Handle,
boot::{self, OpenProtocolAttributes, OpenProtocolParams, ScopedProtocol},
+7
View File
@@ -4,6 +4,12 @@
//! pointers and integers, so the UEFI soft-float ABI does not need vector
//! arguments or LLVM intrinsics. Every kernel restores the XMM registers it
//! uses; legacy SSE encodings leave upper vector state and MXCSR unchanged.
//!
//! The crates built into `stela.efi` hash with SHA-1 and SHA-256 and encrypt
//! with AES only through this crate, so the mount reaches the same SHA and
//! AES instructions as the host. SHA-384 and SHA-512 stay RustCrypto's: no
//! supported host has instructions for them. Tests keep RustCrypto as an
//! independent oracle.
#![no_std]
extern crate alloc;
#[cfg(test)]
@@ -16,6 +22,7 @@ mod sha256;
#[cfg(target_arch = "x86_64")]
mod x86_64;
pub use ::aes::cipher;
pub use ::sha2::digest;
pub use aes::{Aes128, Aes192, Aes256};
pub use sha1::Sha1;
+1 -1
View File
@@ -8,4 +8,4 @@ license.workspace = true
workspace = true
[dependencies]
sha2 = { version = "0.10", default-features = false }
stela-crypto = { path = "../stela-crypto" }
+1 -1
View File
@@ -41,7 +41,7 @@ pub mod smbios;
use alloc::{string::String, vec::Vec};
use core::fmt;
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
/// An owned diagnostic name. Copying borrowed bytes uses a fallible reserve;
/// OOM keeps the original byte count and SHA-256 instead of aborting. This
@@ -5,7 +5,7 @@
use super::{Image, Provenance, Provider, Requirement, Resource, Target};
use crate::bytes::{le16, le32};
use alloc::{format, string::String};
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
pub const MAX_ENTRY_BYTES: usize = 255;
/// Native collection bound, not a maximum imposed by the SMBIOS specification.
+8 -6
View File
@@ -14,7 +14,7 @@ workspace = true
# Native x86 ACPICA interpreter; builds freestanding C with clang.
native-acpi = ["dep:cc"]
# Common native Linux kernel services; selecting this attaches no GPU.
linux-kernel = ["dep:cc", "dep:stela-crypto"]
linux-kernel = ["dep:cc"]
# `block::RamDisk`, the in-memory disk the runtime's tests run models on.
ram-disk = []
# Build the implemented native NVIDIA OS hooks, not a complete GPU driver.
@@ -30,15 +30,12 @@ metal = []
[dependencies]
stela-driver-core = { path = "../stela-driver-core" }
stela-crypto = { path = "../stela-crypto", optional = true }
# BIP-CMAC uses the shared checked AES backend; expanded keys clear on retirement.
aes = { version = "0.8", default-features = false, features = ["zeroize"] }
# SHA-1, SHA-256 and AES (key wrap, BIP-CMAC/GMAC); expanded keys clear on retirement.
stela-crypto = { path = "../stela-crypto" }
# WPA2-Personal: PBKDF2/PRF/MIC over HMAC-SHA1 and HMAC-SHA256.
hmac = { version = "0.12", default-features = false }
# WPA3-Personal: SAE over P-256, hash-to-element through its simplified SWU map.
p256 = { version = "0.13", default-features = false, features = ["arithmetic", "expose-field", "hash2curve"] }
sha1 = { version = "0.10", default-features = false }
sha2 = { version = "0.10", default-features = false }
# Cryptographic MIC comparison retains an explicit optimization barrier.
subtle = { version = "2.6", default-features = false }
# Retained source GTK/IGTK batch material must clear after actual retirement.
@@ -46,6 +43,11 @@ zeroize = { version = "1.9", default-features = false, features = ["alloc"] }
# Fallible native mapping metadata; the maintained owner supports alloc-only UEFI.
triomphe = { version = "=0.1.16", default-features = false }
[dev-dependencies]
# Independent SHA-256 and AES the tests check fixtures and ciphers against.
sha2 = { version = "0.10", default-features = false }
aes = { version = "0.8", default-features = false }
[build-dependencies]
# Reuse retained shared-input/object/digest versions; no new crate fetch.
libc = "0.2"
@@ -4,7 +4,7 @@
use super::{Error, Result};
use crate::{bus::pci::Address, firmware::Target};
use alloc::{format, string::String};
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
pub const OTP_BYTES: usize = 0xe0;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -7,7 +7,7 @@
//! GPL-2.0 property-address setup semantics. No Linux execution is required.
use super::*;
use crate::bluetooth::hci::{self, Response};
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
const CALIBRATION: &str = "brcm,taurus-cal-blob";
const BEAMFORMING: &str = "brcm,taurus-bf-cal-blob";
@@ -7,7 +7,7 @@ use crate::firmware::Target;
use crate::usb::xhci::Device;
use alloc::{format, string::String, vec::Vec};
use core::fmt::Write;
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
const CNVI_TOP: u8 = 0x10;
const CNVR_TOP: u8 = 0x11;
@@ -12,4 +12,4 @@ path = "lib.rs"
crate-type = ["rlib", "staticlib"]
[dependencies]
sha2 = { version = "0.10", default-features = false }
stela-crypto = { path = "../../../../../stela-crypto" }
@@ -6,7 +6,7 @@ pub mod library;
use core::{mem, ptr, slice};
use library::{Air, Library};
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
const ABI: u32 = 1;
const MTLB: u32 = 1;
@@ -5,7 +5,7 @@
//! metadata and digest remain borrowed from the original input.
use alloc::vec::Vec;
use core::{fmt, ops::Range, str};
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
const HEADER_BYTES: usize = 88;
const LLVM_WRAPPER_MAGIC: u32 = 0x0b17_c0de;
@@ -8,7 +8,7 @@
use super::{firmware::Family, identity::Profile};
use crate::firmware as resources;
use alloc::{boxed::Box, format, string::String, vec::Vec};
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
pub const WIFI_BT_GUID: &str = "e65d8884-d4af-4b20-8d03-772ecc3da531";
pub const WIFI_GUID: &str = "92daaf2f-c02b-455b-b2ec-f5a3594f4aea";
@@ -11,7 +11,7 @@ use crate::net::wifi::{
management::{self, ManagementCipher},
},
};
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
use zeroize::Zeroizing;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
@@ -11,7 +11,7 @@
use crate::firmware::{self, Provider, Requirement, Target};
use alloc::{boxed::Box, sync::Arc, vec::Vec};
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
/// The catalog name of wireless-regdb's database, which boot places in the
/// handoff firmware catalog from setup's pinned host firmware.
@@ -27,7 +27,7 @@
use super::{Aggregation, frame::Mpdu};
use crate::net::Mac;
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
pub mod aggregate;
pub mod management;
@@ -16,11 +16,11 @@
use super::{KeyIdentity, KeyScope, PacketNumber, valid_receive_observations};
use crate::net::wifi::{Aggregation, frame};
use aes::{
Aes128, Aes256,
cipher::{BlockEncrypt, KeyInit},
};
use alloc::boxed::Box;
use stela_crypto::{
Aes128, Aes256,
cipher::{BlockEncrypt, KeyInit, generic_array::GenericArray},
};
use subtle::ConstantTimeEq;
use zeroize::Zeroizing;
@@ -300,7 +300,7 @@ impl Aes {
.map_err(|_| Error::InvalidKey)
}
fn encrypt(&self, block: &mut [u8; 16]) {
let block = aes::Block::from_mut_slice(block);
let block = GenericArray::from_mut_slice(block);
match self {
Self::Aes128(cipher) => cipher.encrypt_block(block),
Self::Aes256(cipher) => cipher.encrypt_block(block),
@@ -17,14 +17,12 @@ use super::{
station::wire::pmf,
};
use crate::net::Mac;
use aes::{
Aes128,
cipher::{BlockDecrypt, BlockEncrypt, KeyInit},
};
use alloc::vec::Vec;
use hmac::{Hmac, Mac as _};
use sha1::Sha1;
use sha2::Sha256;
use stela_crypto::{
Aes128, Sha1, Sha256,
cipher::{BlockDecrypt, BlockEncrypt, KeyInit},
};
use subtle::ConstantTimeEq;
use zeroize::Zeroizing;
@@ -5,7 +5,7 @@
use super::FormatError;
use crate::bytes::le32;
use alloc::vec::Vec;
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
const HEADER: usize = 32;
const GLOBAL: usize = 64;
const MAP: usize = 64;
@@ -3,7 +3,7 @@
//! WMT headers/status interpretation adapted from btmtk_usb_hci_wmt_sync.
use super::{Error, Result};
use alloc::vec::Vec;
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
pub(super) const OPCODE: u16 = 0xfc6f;
pub(super) const PATCH: u8 = 1;
pub(super) const FUNCTION: u8 = 6;
@@ -7,7 +7,7 @@ use super::{Configuration, FormatError, Project, Staged};
use crate::bytes::le32;
use alloc::vec::Vec;
use core::cmp::Reverse;
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
const HEADER: usize = 20;
const MAX_IMAGE: usize = 4 * 1024 * 1024;
const SNIPPETS: u32 = 1;
@@ -12,7 +12,7 @@ use crate::bytes::{le16, le32};
use crate::{block::BlockError, firmware as resources};
use alloc::{boxed::Box, format, string::String, vec::Vec};
use core::fmt;
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
const HEADER: usize = 64;
const MAX_BYTES: usize = 128 * 1024;
-1
View File
@@ -18,7 +18,6 @@ serde.workspace = true
serde_json = { version = "1", default-features = false, features = ["alloc"] }
tempfile = { workspace = true, optional = true }
libc = { workspace = true, optional = true }
sha2 = { version = "0.10", default-features = false }
hex = { version = "0.4", default-features = false, features = ["alloc"] }
stela-compiler = { path = "../stela-compiler", default-features = false }
stela-contracts = { path = "../stela-contracts", default-features = false }
+1 -1
View File
@@ -10,7 +10,6 @@
pub mod pack;
use alloc::{string::String, vec::Vec};
use sha2::Digest as _;
use stela_compiler::block::Features;
use stela_compiler::{
GuestAddress, NativeBlock,
@@ -21,6 +20,7 @@ use stela_compiler::{
x86_64::chain::DirectExit,
};
use stela_crypto::Sha256;
use stela_crypto::digest::Digest as _;
/// The bytes of the fetch page a record covers: no block leaves it.
pub const PAGE_BYTES: usize = 4096;
+1 -1
View File
@@ -24,8 +24,8 @@ use alloc::{
vec::Vec,
};
use core::mem::size_of;
use sha2::Digest as _;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest as _;
pub const MAGIC: [u8; 8] = *b"STLTPACK";
pub const SCHEMA: u32 = 1;
+3 -1
View File
@@ -17,7 +17,7 @@ stela-crypto = { path = "../stela-crypto" }
stela-contracts = { path = "../stela-contracts", default-features = false }
serde.workspace = true
serde_json = { version = "1", default-features = false, features = ["alloc"] }
sha1 = { version = "0.10", default-features = false }
# SHA-384 and SHA-512 for signatures and APFS; SHA-1/SHA-256 are stela-crypto's.
sha2 = { version = "0.10", default-features = false }
crypto-bigint = { version = "0.5", default-features = false }
hex = { version = "0.4", default-features = false, features = ["alloc"] }
@@ -27,3 +27,5 @@ iri-string = { version = "=0.7.14", default-features = false, features = ["alloc
[dev-dependencies]
lzfse_rust = "0.2"
# An independent SHA-1 for the CMS hash-agility fixtures.
sha1 = { version = "0.10", default-features = false }
+1 -1
View File
@@ -1,7 +1,7 @@
//! SHA-256 hex digests, shared by hosted and freestanding code.
use alloc::string::String;
use sha2::Digest;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
pub fn sha256(data: &[u8]) -> String {
hex::encode(Sha256::digest(data))
+1 -1
View File
@@ -20,8 +20,8 @@ use alloc::{
};
use core::fmt;
use serde::{Deserialize, Serialize};
use sha2::Digest;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
pub mod gpt;
pub mod pieces;
+1 -1
View File
@@ -12,8 +12,8 @@
//! piece's name.
use super::{Layout, PayloadError, PayloadManifest, ReadAt, piece_name};
use alloc::{format, vec, vec::Vec};
use sha2::Digest;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
/// A run of a piece's bytes on the device.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+2
View File
@@ -25,6 +25,8 @@ hex = { version = "0.4", default-features = false, features = ["alloc"] }
object = { version = "0.37", default-features = false, features = ["read"] }
serde.workspace = true
serde_json = { version = "1", default-features = false, features = ["alloc"] }
stela-crypto = { path = "../stela-crypto" }
# SHA-384 for Image4 manifests; SHA-256 is stela-crypto's.
sha2 = { version = "0.10", default-features = false }
[dev-dependencies]
@@ -23,8 +23,8 @@
use super::{DeviceTree, Node};
use crate::Result;
use alloc::{collections::BTreeSet, format, string::String, vec::Vec};
use sha2::{Digest, Sha256};
use stela_contracts::{refuse, require};
use stela_crypto::{Sha256, digest::Digest};
use stela_soc_data::board::assigned::{
CacheId, GuestSlotId, InterruptId, Plan, PlanIdentity, StartId,
};
@@ -2,13 +2,13 @@
//! objects live below a content-addressed package directory, so replacing the
//! active manifest never overwrites bytes the previous manifest still names.
use super::*;
use sha2::{Digest, Sha256};
use std::{
fs::{self, File, OpenOptions},
io::{Read, Write},
path::{Path, PathBuf},
time::{SystemTime, UNIX_EPOCH},
};
use stela_crypto::{Sha256, digest::Digest};
pub struct Package {
manifest: Vec<u8>,
@@ -36,7 +36,7 @@ impl Artifact {
}
}
pub fn verify(&self, bytes: &[u8]) -> Result<(), Error> {
use sha2::{Digest, Sha256};
use stela_crypto::{Sha256, digest::Digest};
if bytes.len() != self.length || hex::encode(Sha256::digest(bytes)) != self.sha256 {
return Err(Error(format!(
"pinned host firmware artifact differs: {}",
+3 -3
View File
@@ -27,7 +27,7 @@ serde.workspace = true
serde_json = { version = "1", default-features = false, features = ["alloc"] }
tempfile = { workspace = true, optional = true }
libc = { workspace = true, optional = true }
sha1 = { version = "0.10", default-features = false }
# SHA-384 for Image4 and SEP evidence; SHA-1/SHA-256 and AES are stela-crypto's.
sha2 = { version = "0.10", default-features = false }
# SEP root derivations and secret lifetime; both work without std.
hmac = { version = "0.12", default-features = false }
@@ -36,8 +36,6 @@ zeroize = { version = "1.9", default-features = false, features = ["alloc"] }
p256 = { version = "0.13.2", default-features = false, features = ["arithmetic", "ecdsa"] }
# Public RSA verification for Image4 evidence; no private-key operations.
crypto-bigint = { version = "0.5", default-features = false }
# The AES engine model's cipher: constant-time, no_std, AES-NI when present.
aes = { version = "0.8", default-features = false }
hex = { version = "0.4", default-features = false, features = ["alloc"] }
# Inflates deflate IPSW members in place, in no_std: no unsafe code, and the
# same inflater flate2 and the zip crate already use on the host.
@@ -62,6 +60,8 @@ smoltcp = { version = "0.14", default-features = false, features = ["socket-udp"
stela-drivers = { path = "../stela-drivers", features = ["ram-disk"] }
# The reference LZFSE encoder the no_std decoder is checked against.
lzfse_rust = "0.2"
# An independent AES the cipher models are checked against.
aes = { version = "0.8", default-features = false }
[target.'cfg(not(target_os = "uefi"))'.dev-dependencies]
rustls = { version = "=0.23.45", default-features = false, features = ["std", "tls12"] }
@@ -82,12 +82,12 @@
//! commands, DKey distribution, DATA bit 24 and the reserved bits of the
//! address words are refused until their values or behavior are known.
use crate::Result;
use aes::cipher::{BlockDecrypt, BlockEncrypt, KeyInit};
use alloc::collections::VecDeque;
#[cfg(not(feature = "std"))]
use alloc::vec;
use stela_contracts::Refusal;
use stela_contracts::refuse;
use stela_crypto::cipher::{BlockDecrypt, BlockEncrypt, KeyInit, generic_array::GenericArray};
#[cfg(test)]
use stela_soc_data::aes::DEFAULT_ADDRESS_WIDTH;
#[cfg(test)]
@@ -204,7 +204,7 @@ impl Cipher {
}
fn encrypt(&self, block: &mut [u8; BLOCK]) {
let block = aes::Block::from_mut_slice(block);
let block = GenericArray::from_mut_slice(block);
match self {
Self::Aes128(cipher) => cipher.encrypt_block(block),
Self::Aes192(cipher) => cipher.encrypt_block(block),
@@ -213,7 +213,7 @@ impl Cipher {
}
fn decrypt(&self, block: &mut [u8; BLOCK]) {
let block = aes::Block::from_mut_slice(block);
let block = GenericArray::from_mut_slice(block);
match self {
Self::Aes128(cipher) => cipher.decrypt_block(block),
Self::Aes192(cipher) => cipher.decrypt_block(block),
@@ -10,9 +10,9 @@ use super::super::power::t6000::identity::Image;
#[cfg(test)]
use crate::Result;
#[cfg(test)]
use sha2::{Digest, Sha256};
#[cfg(test)]
use stela_contracts::refuse;
#[cfg(test)]
use stela_crypto::{Sha256, digest::Digest};
#[cfg(test)]
const HEADER: usize = 0x30;
@@ -24,9 +24,9 @@
//! the medium unchanged. NVMe 1.4 section 5.11 discards an uncommitted
//! download on a controller-level reset, and so does the model.
use crate::Result;
use sha2::Digest;
use stela_contracts::refuse;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
pub(super) const SECTIONS: usize = 3;
/// `BuildCommandFirmwareActivate` CDW10 for slot 0, commit action 1:
@@ -10,9 +10,9 @@ use super::{FirmwareStartup, firmware::FirmwareMemory};
use crate::Result;
use alloc::{vec, vec::Vec};
use core::ops::Range;
use sha2::Digest;
use stela_contracts::refuse;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
mod clock;
mod integrity;
use stela_soc_data::pmu::PmicEpoch;
@@ -7,9 +7,9 @@
pub mod signature;
use alloc::vec::Vec;
use sha2::Digest;
use stela_contracts::refuse;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
use {stela_contracts::dma::DmaError, stela_contracts::dma::Port};
const SEQUENCE: u8 = 0x30;
@@ -66,9 +66,9 @@ use super::{
};
use crate::Result;
use alloc::{string::String, vec, vec::Vec};
use sha2::Digest;
use stela_contracts::refuse;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
use zeroize::Zeroizing;
/// Stela's catalog ID for the service, after the xART pair.
@@ -17,9 +17,9 @@ use super::{
};
use crate::Result;
use alloc::{boxed::Box, vec, vec::Vec};
use sha2::Digest;
use stela_contracts::refuse;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
use stela_drivers::block::{BlockDevice, Shared};
use zeroize::Zeroizing;
@@ -13,9 +13,9 @@
use super::{Backend, Head};
use crate::Result;
use alloc::{boxed::Box, vec, vec::Vec};
use sha2::Digest;
use stela_contracts::refuse;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
use stela_drivers::block::BlockDevice;
const MAGIC: &[u8; 8] = b"STXARTB1";
@@ -41,8 +41,8 @@ use core::{
convert::Infallible,
fmt::{self, Write as _},
};
use sha2::Digest;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
use stela_drivers::block::{BlockDevice, BlockError, Finished, Request};
use stela_soc_data::nor::CAPACITY;
@@ -6,8 +6,8 @@
//! block-device view of exactly [`FILE_BYTES`], never a whole filesystem.
use alloc::{vec, vec::Vec};
use core::fmt;
use sha2::Digest;
use stela_crypto::Sha256;
use stela_crypto::digest::Digest;
use stela_drivers::block::{BlockDevice, BlockError};
pub const FILE_BYTES: usize = 4 << 20;
@@ -23,9 +23,9 @@
//! recovered no key is installed, so the ANS key path still refuses; this
//! module is the interface and the verified cipher they will use.
use crate::Result;
use aes::cipher::{BlockDecrypt, BlockEncrypt, KeyInit, generic_array::GenericArray};
use alloc::collections::BTreeMap;
use stela_contracts::refuse;
use stela_crypto::cipher::{BlockDecrypt, BlockEncrypt, KeyInit, generic_array::GenericArray};
use stela_crypto::{Aes128, Aes256};
use zeroize::{Zeroize, Zeroizing};
@@ -76,7 +76,7 @@ fn double_tweak(tweak: &mut [u8; BLOCK]) {
}
}
fn xts<C: BlockEncrypt<BlockSize = aes::cipher::consts::U16> + BlockDecrypt + KeyInit>(
fn xts<C: BlockEncrypt<BlockSize = stela_crypto::cipher::consts::U16> + BlockDecrypt + KeyInit>(
data_key: &[u8],
tweak_key: &[u8],
sector: u64,
@@ -94,7 +94,8 @@ fn xts<C: BlockEncrypt<BlockSize = aes::cipher::consts::U16> + BlockDecrypt + Ke
let mut block = GenericArray::clone_from_slice(&tweak);
tweak_cipher.encrypt_block(&mut block);
tweak.copy_from_slice(&block);
let mut blocks: [aes::cipher::Block<C>; 8] = core::array::from_fn(|_| Default::default());
let mut blocks: [stela_crypto::cipher::Block<C>; 8] =
core::array::from_fn(|_| Default::default());
let mut masks = [[0u8; BLOCK]; 8];
let (chunks, _) = data.as_chunks_mut::<BLOCK>();
for group in chunks.chunks_mut(8) {