INNER CODE UNIT · Rust

DEV_CONF_MERGE_MAX

TheMaxMur/RS-Key · crates/rsk-devconf/src/lib.rs:111

const DEV_CONF_MERGE_MAX: usize = EF_DEV_CONF_READ_MAX + DEV_CONF_WRITE_MAX;

/// The device-owned part of every READ CONFIG response: the overall length byte,
/// `USB_SUPPORTED` + `SERIAL` + `FORM_FACTOR` + `VERSION`, and the trailing
/// `CONFIG_LOCK`. Each `push_tlv` costs 2 bytes of header plus its value.
const CONFIG_TLV_FIXED: usize = 1 + (2 + 2) + (2 + 4) + (2 + 1) + (2 + 3) + CONFIG_LOCK_TLV_LEN;

/// The trailing `CONFIG_LOCK` entry `config_tlv` always appends after the echo.
const CONFIG_LOCK_TLV_LEN: usize = 2 + 1;

/// Build the READ CONFIG TLV: a leading overall-length byte, then
/// USB_SUPPORTED / SERIAL / FORM_FACTOR / VERSION, then either the persisted
/// `EF_DEV_CONF` blob or the default USB_ENABLED / DEVICE_FLAGS / CONFIG_LOCK
/// tail. Public because the OTP applet serves the same TLV (P1=0x13).
pub fn config_tlv<S: Storage>(serial: &[u8; 4], fs: &mut Fs<S>, res: &mut ResBuf) -> Sw {
    let mut buf = [0u8; 128];
    let mut n = 1; // byte 0 = overall length, filled at the end.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…