Protocol updates
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
//! Embedded keystore blob (standard encrypted + VAG raw).
|
||||
//! Data is stored as binary to avoid plain-text keys in config.
|
||||
//! Format: "KATK" magic, n_entries (u16 LE), then per entry: type_id (u32 LE), key (u64 LE), then "VAG " + 64 bytes.
|
||||
//! All manufacture keys from the encrypted keystore list are included for current and future protocols.
|
||||
//! Type 20 (Star Line) is also included so KeyStore.star_line_mf_key is populated from the same key as SL_A2-A4.
|
||||
|
||||
/// Blob: KATK + 30 entries (all manufacture keys + type 20 for Star Line) + VAG 64 bytes.
|
||||
#[rustfmt::skip]
|
||||
pub const KEYSTORE_BLOB: &[u8] = &[
|
||||
b'K', b'A', b'T', b'K',
|
||||
0x1E, 0x00, // 30 entries
|
||||
// type 10 KIA
|
||||
0x0A, 0x00, 0x00, 0x00, 0xDB, 0x5C, 0xAA, 0x8D, 0xFC, 0xDF, 0xF5, 0xA8,
|
||||
// type 11 KIAV6A
|
||||
0x0B, 0x00, 0x00, 0x00, 0xFC, 0x23, 0xAA, 0x80, 0xA8, 0x64, 0x86, 0x63,
|
||||
// type 12 KIAV6B
|
||||
0x0C, 0x00, 0x00, 0x00, 0xF4, 0x2B, 0xA2, 0x88, 0xA0, 0x6C, 0x8E, 0x6B,
|
||||
// type 13 KIAV5
|
||||
0x0D, 0x00, 0x00, 0x00, 0x30, 0x30, 0x45, 0x4B, 0x52, 0x46, 0x54, 0x53,
|
||||
// type 1 Alligator
|
||||
0x01, 0x00, 0x00, 0x00, 0x78, 0x55, 0x6C, 0x62, 0xB2, 0xD4, 0xF3, 0xEE,
|
||||
// type 2 Mongoose
|
||||
0x02, 0x00, 0x00, 0x00, 0xBA, 0xA0, 0xC1, 0xA7, 0xB2, 0xE7, 0xA5, 0xD5,
|
||||
// type 1 SL_A6-A9/Tomahawk_9010
|
||||
0x01, 0x00, 0x00, 0x00, 0x03, 0x12, 0x30, 0x08, 0x57, 0x04, 0x04, 0x55,
|
||||
// type 1 Pantera
|
||||
0x01, 0x00, 0x00, 0x00, 0x65, 0x6E, 0x79, 0x64, 0x4E, 0x47, 0x41, 0x4D,
|
||||
// type 1 SL_A2-A4
|
||||
0x01, 0x00, 0x00, 0x00, 0xDA, 0x78, 0xFE, 0xF8, 0x9B, 0xF8, 0xF7, 0x9B,
|
||||
// type 1 Cenmax_St-5
|
||||
0x01, 0x00, 0x00, 0x00, 0xFC, 0xED, 0xCF, 0xF7, 0xA8, 0xFB, 0xFB, 0xAA,
|
||||
// type 1 SL_B6,B9_dop
|
||||
0x01, 0x00, 0x00, 0x00, 0xFE, 0xDC, 0xBA, 0x2A, 0xB3, 0xD4, 0xE5, 0xF6,
|
||||
// type 1 Harpoon
|
||||
0x01, 0x00, 0x00, 0x00, 0x64, 0x08, 0x07, 0x64, 0x07, 0x01, 0x87, 0x25,
|
||||
// type 1 Tomahawk_TZ-9030
|
||||
0x01, 0x00, 0x00, 0x00, 0x25, 0x87, 0x01, 0x07, 0x64, 0x07, 0x08, 0x64,
|
||||
// type 1 Tomahawk_Z,X_3-5
|
||||
0x01, 0x00, 0x00, 0x00, 0xEF, 0xCD, 0xAB, 0x2A, 0x3B, 0x4D, 0x5E, 0x6F,
|
||||
// type 1 Cenmax_St-7
|
||||
0x01, 0x00, 0x00, 0x00, 0x2B, 0x75, 0xAC, 0x80, 0xB9, 0x46, 0xB4, 0x66,
|
||||
// type 1 Sheriff
|
||||
0x01, 0x00, 0x00, 0x00, 0x78, 0x94, 0x18, 0xA9, 0x94, 0x25, 0x33, 0x12,
|
||||
// type 1 Pantera_CLK
|
||||
0x01, 0x00, 0x00, 0x00, 0x14, 0x0A, 0x61, 0x82, 0x0A, 0x85, 0x30, 0x41,
|
||||
// type 1 Cenmax
|
||||
0x01, 0x00, 0x00, 0x00, 0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12,
|
||||
// type 1 Alligator_S-275
|
||||
0x01, 0x00, 0x00, 0x00, 0xF9, 0x84, 0x62, 0x67, 0xB7, 0x5C, 0x36, 0x54,
|
||||
// type 2 Guard_RF-311A
|
||||
0x02, 0x00, 0x00, 0x00, 0x47, 0x88, 0x19, 0xEB, 0xC2, 0xDA, 0x61, 0x19,
|
||||
// type 1 Partisan_RX
|
||||
0x01, 0x00, 0x00, 0x00, 0x1E, 0xF1, 0x28, 0x70, 0xA1, 0x12, 0x3C, 0xAD,
|
||||
// type 1 APS-1100_APS-2550
|
||||
0x01, 0x00, 0x00, 0x00, 0x28, 0x47, 0x33, 0x56, 0x50, 0x2C, 0x73, 0x68,
|
||||
// type 1 Pantera_XS/Jaguar
|
||||
0x01, 0x00, 0x00, 0x00, 0x27, 0x46, 0x33, 0x56, 0x50, 0x2C, 0x73, 0x67,
|
||||
// type 0 Teco
|
||||
0x00, 0x00, 0x00, 0x00, 0xD7, 0xD1, 0x26, 0xF1, 0xE8, 0x26, 0x15, 0xB5,
|
||||
// type 0 Leopard
|
||||
0x00, 0x00, 0x00, 0x00, 0x46, 0x8A, 0xD8, 0xE7, 0x33, 0xDC, 0x67, 0x10,
|
||||
// type 0 Faraon
|
||||
0x00, 0x00, 0x00, 0x00, 0xF5, 0x87, 0x22, 0xB6, 0x38, 0x64, 0x32, 0x8A,
|
||||
// type 0 Reff
|
||||
0x00, 0x00, 0x00, 0x00, 0x8A, 0x41, 0xC2, 0x7D, 0x55, 0xFA, 0x12, 0x69,
|
||||
// type 0 ZX-730-750-1055
|
||||
0x00, 0x00, 0x00, 0x00, 0x96, 0x15, 0x35, 0x27, 0xAB, 0x7A, 0x1A, 0xB5,
|
||||
// type 20 Star Line (same key as SL_A2-A4, for KeyStore.star_line_mf_key)
|
||||
0x14, 0x00, 0x00, 0x00, 0xDA, 0x78, 0xFE, 0xF8, 0x9B, 0xF8, 0xF7, 0x9B,
|
||||
b'V', b'A', b'G', b' ',
|
||||
// VAG raw 64 bytes
|
||||
0x01, 0x37, 0x6C, 0x86, 0xAD, 0xAB, 0xCC, 0x43, 0x07, 0x4D, 0xE8, 0x59, 0xC1, 0x2F, 0x36, 0xAB,
|
||||
0x02, 0x37, 0x7C, 0x65, 0xCE, 0xDC, 0x42, 0xEA, 0xA4, 0x53, 0xE8, 0x61, 0xD9, 0xB7, 0x20, 0xFC,
|
||||
0x03, 0x8A, 0xA3, 0x7B, 0x1E, 0x56, 0x1F, 0x83, 0x84, 0xB6, 0x19, 0xC5, 0x2E, 0x0A, 0x3F, 0xD7,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
@@ -0,0 +1,53 @@
|
||||
//! Embedded keystore: binary blob of protocol keys (KIA, Star Line, VAG).
|
||||
//! Matches ProtoPirate key types (keys.c: KIA_KEY1..4). Loaded at startup instead of keystore_dir.
|
||||
|
||||
mod embedded;
|
||||
|
||||
use std::convert::TryInto;
|
||||
|
||||
const MAGIC: &[u8; 4] = b"KATK";
|
||||
const VAG_TAG: &[u8; 4] = b"VAG ";
|
||||
const VAG_SIZE: usize = 64;
|
||||
const ENTRY_SIZE: usize = 4 + 8; // u32 type + u64 key
|
||||
|
||||
/// Parsed result from the embedded blob: (type_id, key) pairs and raw VAG bytes.
|
||||
pub struct ParsedKeystore {
|
||||
pub entries: Vec<(u32, u64)>,
|
||||
pub vag_bytes: Vec<u8>,
|
||||
}
|
||||
|
||||
/// Parse the embedded keystore blob. Returns KIA/Star Line entries and VAG raw bytes.
|
||||
pub fn parse_blob(blob: &[u8]) -> Option<ParsedKeystore> {
|
||||
if blob.len() < 4 || &blob[0..4] != MAGIC {
|
||||
return None;
|
||||
}
|
||||
let n = u16::from_le_bytes(blob[4..6].try_into().ok()?) as usize;
|
||||
let mut off = 6;
|
||||
let mut entries = Vec::with_capacity(n);
|
||||
for _ in 0..n {
|
||||
if off + ENTRY_SIZE > blob.len() {
|
||||
return None;
|
||||
}
|
||||
let ty = u32::from_le_bytes(blob[off..off + 4].try_into().ok()?);
|
||||
let key = u64::from_le_bytes(blob[off + 4..off + 12].try_into().ok()?);
|
||||
entries.push((ty, key));
|
||||
off += ENTRY_SIZE;
|
||||
}
|
||||
if off + 4 + VAG_SIZE > blob.len() || &blob[off..off + 4] != VAG_TAG {
|
||||
return Some(ParsedKeystore {
|
||||
entries,
|
||||
vag_bytes: Vec::new(),
|
||||
});
|
||||
}
|
||||
off += 4;
|
||||
let vag_bytes = blob[off..off + VAG_SIZE].to_vec();
|
||||
Some(ParsedKeystore {
|
||||
entries,
|
||||
vag_bytes,
|
||||
})
|
||||
}
|
||||
|
||||
/// Return the embedded keystore blob for loading.
|
||||
pub fn embedded_blob() -> &'static [u8] {
|
||||
embedded::KEYSTORE_BLOB
|
||||
}
|
||||
Reference in New Issue
Block a user