mirror of
https://git.eta.st/eta/rsp6-decoder.git
synced 2024-11-25 02:55:48 +00:00
add support for PKCS#1 v2 padding (used by seatfrog)
This commit is contained in:
parent
d4918a2b00
commit
11b41c3281
42
src/main.rs
42
src/main.rs
@ -16,19 +16,38 @@ fn base26_decode(input: &str) -> BigUint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn strip_padding(tkt: &[u8]) -> Option<&[u8]> {
|
fn strip_padding(tkt: &[u8]) -> Option<&[u8]> {
|
||||||
if tkt.is_empty() || tkt[0] != 1 {
|
if tkt.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let tkt = &tkt[1..];
|
match tkt[0] {
|
||||||
let mut iter = tkt.iter();
|
1 => {
|
||||||
loop {
|
// PKCS#1 v1
|
||||||
match iter.next()? {
|
let tkt = &tkt[1..];
|
||||||
0 => {
|
let mut iter = tkt.iter();
|
||||||
return Some(iter.as_slice());
|
loop {
|
||||||
|
match iter.next()? {
|
||||||
|
0 => {
|
||||||
|
return Some(iter.as_slice());
|
||||||
|
}
|
||||||
|
255 => {}
|
||||||
|
_ => return None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
255 => {}
|
|
||||||
_ => return None,
|
|
||||||
}
|
}
|
||||||
|
2 => {
|
||||||
|
// PKCS#1 v2
|
||||||
|
let tkt = &tkt[1..];
|
||||||
|
let mut iter = tkt.iter();
|
||||||
|
loop {
|
||||||
|
match iter.next()? {
|
||||||
|
0 => {
|
||||||
|
return Some(iter.as_slice());
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,9 +78,8 @@ fn main() -> anyhow::Result<()> {
|
|||||||
.get(issuer_id)
|
.get(issuer_id)
|
||||||
.ok_or_else(|| anyhow!("unknown issuer ID {}", issuer_id))?;
|
.ok_or_else(|| anyhow!("unknown issuer ID {}", issuer_id))?;
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let message = ticket
|
let message = ticket.modpow(&key.public_exponent, &key.modulus);
|
||||||
.modpow(&key.public_exponent, &key.modulus)
|
let message = message.to_bytes_be();
|
||||||
.to_bytes_be();
|
|
||||||
if let Some(unpadded) = strip_padding(&message) {
|
if let Some(unpadded) = strip_padding(&message) {
|
||||||
eprintln!("[+] decrypt done!");
|
eprintln!("[+] decrypt done!");
|
||||||
let ticket_ref_inner = Rsp6Ticket::base64(unpadded, 8, 62);
|
let ticket_ref_inner = Rsp6Ticket::base64(unpadded, 8, 62);
|
||||||
|
Loading…
Reference in New Issue
Block a user