Skip to content

Commit

Permalink
6v encrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
wanda-phi committed Jul 16, 2024
1 parent 4632244 commit 9af6c0b
Show file tree
Hide file tree
Showing 7 changed files with 223 additions and 87 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ hex = "0.4.3"
des = "0.8.1"
cbc = "0.1.2"
aes = "0.8.4"
sha2 = "0.10.8"

[profile.dev]
opt-level = 2
Expand Down
2 changes: 1 addition & 1 deletion databases/xc6v-tiledb.json

Large diffs are not rendered by default.

31 changes: 19 additions & 12 deletions prjcombine_ise_hammer/src/misc/virtex6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ pub fn add_fuzzers<'a>(session: &mut Session<IseBackend<'a>>, backend: &IseBacke
fuzz_one!(ctx, "PIN.GTS", "1", [(mode "STARTUP"), (nopin "GSR")], [(pin "GTS")]);
fuzz_one!(ctx, "PIN.GSR", "1", [(mode "STARTUP"), (nopin "GTS")], [(pin "GSR")]);
fuzz_one!(ctx, "PIN.USRCCLKO", "1", [(mode "STARTUP")], [(pin "USRCCLKO")]);
fuzz_one!(ctx, "PIN.KEYCLEARB", "1", [
(mode "STARTUP"),
(global_opt "ENCRYPT", "YES")
], [
(pin "KEYCLEARB")
]);
for attr in ["GSR_SYNC", "GTS_SYNC"] {
for val in ["YES", "NO"] {
fuzz_one!(ctx, attr, val, [], [(global_opt attr, val)]);
Expand Down Expand Up @@ -294,7 +300,6 @@ pub fn add_fuzzers<'a>(session: &mut Session<IseBackend<'a>>, backend: &IseBacke
TileBits::Reg(Reg::Ctl0),
);
// persist not fuzzed — too much effort
// decrypt not fuzzed — too much effort
for val in ["NONE", "LEVEL1", "LEVEL2"] {
fuzz_one!(ctx, "SECURITY", val, [], [(global_opt "SECURITY", val)]);
}
Expand All @@ -318,6 +323,7 @@ pub fn add_fuzzers<'a>(session: &mut Session<IseBackend<'a>>, backend: &IseBacke
fuzz_one!(ctx, "SEC_ALL", val, [], [(global_opt "SECALL", val)]);
fuzz_one!(ctx, "SEC_ERROR", val, [], [(global_opt "SECERROR", val)]);
fuzz_one!(ctx, "SEC_STATUS", val, [], [(global_opt "SECSTATUS", val)]);
fuzz_one!(ctx, "ENCRYPT", val, [], [(global_opt "ENCRYPT", val)]);
}

let ctx = FuzzCtx::new_fake_tile(
Expand Down Expand Up @@ -469,6 +475,8 @@ pub fn collect_fuzzers(ctx: &mut CollectorCtx) {
ctx.collect_enum_bool_wide(tile, bel, "PROG_USR", "FALSE", "TRUE");
let item = ctx.extract_bit_wide(tile, bel, "PIN.USRCCLKO", "1");
ctx.tiledb.insert(tile, bel, "USRCCLK_ENABLE", item);
let item = ctx.extract_bit_wide(tile, bel, "PIN.KEYCLEARB", "1");
ctx.tiledb.insert(tile, bel, "KEY_CLEAR_ENABLE", item);

let item0 = ctx.extract_enum(tile, "ICAP0", "ICAP_WIDTH", &["X8", "X16", "X32"]);
let item1 = ctx.extract_enum(tile, "ICAP1", "ICAP_WIDTH", &["X8", "X16", "X32"]);
Expand Down Expand Up @@ -607,18 +615,17 @@ pub fn collect_fuzzers(ctx: &mut CollectorCtx) {
ctx.collect_enum_bool(tile, bel, "SEC_ALL", "NO", "YES");
ctx.collect_enum_bool(tile, bel, "SEC_ERROR", "NO", "YES");
ctx.collect_enum_bool(tile, bel, "SEC_STATUS", "NO", "YES");
ctx.collect_enum_bool(tile, bel, "ENCRYPT", "NO", "YES");
// these are too much trouble to deal with the normal way.
for (attr, bit) in [("PERSIST", 3), ("DECRYPT", 6)] {
ctx.tiledb.insert(
tile,
bel,
attr,
TileItem {
bits: vec![FeatureBit::new(0, 0, bit)],
kind: TileItemKind::BitVec { invert: bitvec![0] },
},
);
}
ctx.tiledb.insert(
tile,
bel,
"PERSIST",
TileItem {
bits: vec![FeatureBit::new(0, 0, 3)],
kind: TileItemKind::BitVec { invert: bitvec![0] },
},
);
ctx.tiledb.insert(
tile,
bel,
Expand Down
1 change: 1 addition & 0 deletions prjcombine_virtex_bitstream/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ des.workspace = true
cbc.workspace = true
hex.workspace = true
aes.workspace = true
sha2.workspace = true

[lints]
workspace = true
3 changes: 2 additions & 1 deletion prjcombine_virtex_bitstream/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub enum Reg {
FakeDoubleGrestore,
FakeFreezeDciNops,
FakeIgnoreCrc,
FakeEncrypted,
}

#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
Expand Down Expand Up @@ -124,7 +125,7 @@ impl Bitstream {
let mut res = HashMap::new();
for ((die, da), db) in a.die.iter().zip(b.die.values()) {
for (reg, &va) in &da.regs {
if reg == Reg::RbCrcSw || reg == Reg::Key {
if matches!(reg, Reg::RbCrcSw | Reg::Key | Reg::FakeEncrypted) {
continue;
}
let vb = db.regs[reg];
Expand Down
Loading

0 comments on commit 9af6c0b

Please sign in to comment.