Skip to main content

KernelState

Struct KernelState 

Source
pub struct KernelState { /* private fields */ }
Expand description

Complete kernel state (TCB)

Corresponds to Lean: structure KernelState

Implementations§

Source§

impl KernelState

Source

pub fn initial(key: Key, policy: PolicyState) -> Self

Create initial kernel state

Corresponds to Lean: def KernelState.initial (key : Key) (pol : PolicyState) : KernelState

Source

pub fn tick(&self) -> Result<Self, KernelError>

Advance kernel time (immutable, checked)

Corresponds to Lean: def KernelState.tick (ks : KernelState) : KernelState

§Errors

Returns KernelError::CounterOverflow if the time counter would exceed u64::MAX.

Source

pub fn rotate_key(&mut self, new_key: Key)

Rotate HMAC key (kernel-only operation)

Corresponds to Lean: def KernelState.rotateKey

The current key becomes the previous key for grace period verification. The epoch is incremented.

SECURITY: This operation should only be callable by privileged kernel code.

Source

pub fn with_rotated_key(&self, new_key: Key) -> Self

Rotate HMAC key (immutable version)

Source

pub fn key_epoch(&self) -> u64

Get the current key epoch

Source

pub fn key_state(&self) -> &KeyState

Get a reference to the key state

Source

pub fn verify_cap_seal(&self, cap: &Capability) -> bool

Verify capability seal using key state (supports rotation)

Corresponds to Lean: def KernelState.verify_cap_seal

Source

pub fn alloc_cap_id(&mut self) -> Result<CapId, KernelError>

Allocate a fresh capability ID

Corresponds to Lean: def KernelState.alloc_cap_id

INVARIANT: The returned ID is guaranteed fresh (not in use).

§Errors

Returns KernelError::CapIdExhausted if the capability ID counter would overflow.

Source

pub fn next_cap_id(&self) -> CapId

Get the next capability ID (without allocating)

Source

pub fn tick_checked(&mut self) -> Result<(), KernelError>

Advance kernel time (mutating, checked)

§Errors

Returns KernelError::CounterOverflow if the time counter would exceed u64::MAX.

Source

pub fn cap_not_revoked(&self, cap: &Capability) -> bool

Check if capability is not revoked

Corresponds to Lean: def KernelState.cap_not_revoked

Source

pub fn now(&self) -> Time

Get the current time

Source

pub fn revocation(&self) -> &RevocationState

Get a reference to the revocation state

Source

pub fn policy(&self) -> &PolicyState

Get a reference to the policy state

Trait Implementations§

Source§

impl Clone for KernelState

Source§

fn clone(&self) -> KernelState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for KernelState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for KernelState

Source§

fn default() -> Self

Default kernel state: empty key, deny-all policy, no capabilities, time=0, next_cap_id=0

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.