Struct Keyset

Source
pub struct Keyset {
    pub raw_keys: HashMap<String, Vec<u8>>,
    pub header_key_cache: Option<[u8; 32]>,
}

Fields§

§raw_keys: HashMap<String, Vec<u8>>§header_key_cache: Option<[u8; 32]>

Implementations§

Source§

impl Keyset

Source

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self>

Create a new keyset from a file path

Source

pub fn from_reader(reader: impl Read + Seek) -> Result<Self>

Parse a key file to extract Nintendo Switch keys

Source

pub fn header_crypt(&self) -> Option<Xts128<Aes128>>

Creates an XTS128 cipher for NCA header encryption/decryption

The header key is split into two 128-bit keys for XTS, with the first half used for the data unit key and the second half used for the tweak key.

Source

pub fn get_key_prefixes(&self) -> Vec<String>

Get a list of all key prefixes in the keyset

Source

pub fn get_keys_with_prefix(&self, prefix: &str) -> HashMap<String, Vec<u8>>

Get all keys with a specific prefix

Source

pub fn get_raw_key(&self, key_name: &str) -> Option<&[u8]>

Try to get a raw key by its exact name

Source

pub fn get_key<const N: usize>(&self, key_name: &str) -> Option<[u8; N]>

Try to get a fixed-size key by its exact name

Source

pub fn header_key(&self) -> Option<&[u8; 32]>

Get the header key (cached for performance)

Source

pub fn get_indexed_keys<const N: usize>( &self, prefix: &str, ) -> HashMap<u8, [u8; N]>

Extract indexes from keys with a specific format (e.g., titlekek_10 => 0x10)

Source

pub fn get_key_area_key_application(&self, idx: usize) -> Option<[u8; 16]>

Get an application key area key by index

Source

pub fn get_key_area_key_ocean(&self, idx: usize) -> Option<[u8; 16]>

Get an ocean key area key by index

Source

pub fn get_key_area_key_system(&self, idx: usize) -> Option<[u8; 16]>

Get a system key area key by index

Source

pub fn get_title_kek(&self, key_generation: usize) -> Option<[u8; 16]>

Get the title KEK for the specified key generation

Source

pub fn title_keks(&self) -> HashMap<u8, [u8; 16]>

Get all title KEKs as a HashMap indexed by generation

Source

pub fn key_area_keys_application(&self) -> HashMap<u8, [u8; 16]>

Get all application key area keys as a HashMap indexed by generation

Source

pub fn key_area_keys_ocean(&self) -> HashMap<u8, [u8; 16]>

Get all ocean key area keys as a HashMap indexed by generation

Source

pub fn key_area_keys_system(&self) -> HashMap<u8, [u8; 16]>

Get all system key area keys as a HashMap indexed by generation

Source

pub fn has_required_nca_keys(&self) -> bool

Check if the keyset has the necessary keys for NCA decryption

Source

pub fn get_key_area_key( &self, key_type: u8, crypto_type: u8, ) -> Option<[u8; 16]>

Get key area key by key type and crypto index

Trait Implementations§

Source§

impl Clone for Keyset

Source§

fn clone(&self) -> Keyset

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Keyset

Source§

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

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

impl Default for Keyset

Source§

fn default() -> Keyset

Returns the “default value” for a type. Read more
Source§

impl Display for Keyset

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Keyset

§

impl RefUnwindSafe for Keyset

§

impl Send for Keyset

§

impl Sync for Keyset

§

impl Unpin for Keyset

§

impl UnwindSafe for Keyset

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> CustomError for T
where T: Display + Debug + Send + Sync + 'static,

Source§

fn as_any(&self) -> &(dyn Any + Send + Sync + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + Send + Sync + 'static)

Source§

fn as_box_any(self: Box<T>) -> Box<dyn Any + Send + Sync>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more