INNER CODE UNIT · Rust

persist_dev_conf

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

pub fn persist_dev_conf<S: Storage>(fs: &mut Fs<S>, blob: &[u8]) -> Result<(), DevConfError> {
    if blob.len() > DEV_CONF_WRITE_MAX {
        return Err(DevConfError::TooLong);
    }
    if !well_formed_writable(blob) {
        return Err(DevConfError::BadTlv);
    }
    // Never retain the config-lock tags (see `strip_config_lock`): we do not enforce
    // the lock, and READ CONFIG echoes this blob to any unauthenticated host, so a
    // 16-byte 0x0A would sit unsealed in flash and be disclosed (audit run-30).
    let mut stripped = [0u8; DEV_CONF_WRITE_MAX];
    let n = strip_config_lock(blob, &mut stripped);
    // Bound what is actually STORED, not what was sent: the two lock tags carry
    // 16-byte codes that never reach flash, and `ykman config set-lock-code` sends
    // both the old and the new one at once — 59 bytes of request for at most 23
    // bytes of config. Measuring the request would refuse that legitimate write.
    // MERGE onto the stored record; do not replace it. ykman sends only the fields
    // it is changing — `config set-lock-code` sends the 0x0A TLV and nothing else,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…