Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 1.11 KB

File metadata and controls

44 lines (32 loc) · 1.11 KB

ot_dsim

ot_dsim is a native C implementation of the CRYPTO emulator with a small CPython API.

Install

From the directory containing the repository:

pip3 install ot_dsim/

The build uses setuptools and a local C compiler. The emulator has no runtime Python dependencies. Execution of one engine is sequential, and the extension is small, so no THREADS environment variable is needed for either building or running it.

API

from ot_dsim import CryptoEngine

engine = CryptoEngine()
engine.set_imem(0, 0xFC000000)
engine.set_dmem(0, 0x12345678)
engine.set_pc(0)
engine.run_emulator()

assert engine.get_imem(0) == 0xFC000000
assert engine.get_dmem(0) == 0x12345678

The binding exposes:

  • reset_emulator_state(dmem=False, imem=False)
  • run_emulator()
  • set_pc(pc)
  • set_dmem(idx, value) and get_dmem(idx)
  • set_imem(idx, value) and get_imem(idx)

DMEM and IMEM are both exposed as 1,024 32-bit words. Values written to either memory are truncated to 32 bits. Resetting always clears execution state; DMEM and IMEM are retained unless their corresponding reset arguments are true.