The Kimesh Tamper Sensing Mesh Plugin for Kicad

Tamper Sensing Mesh Basics

Tamper Sensing Meshes are patterns of PCB traces that cover an area to detect attempts at drilling or sawing into a device. Tamper sensing meshes are used across a wide variety of applications such as Hardware Security Modules (HSMs), Card Payment Terminals, and many others. Tamper sensing meshes are a very old technology that has its fundamental approach date back to the early days of electricity in the late 1800s. Despite this legacy, they are still considered a cost efficient and effective countermeasure to physical tampering. When combined with other tamper sensors, tamper sensing meshes provide the core of a device's defense against advanced attacks.

Kimesh's Approach

Tamper-sensing meshes are labor-intensive to lay out by hand. Modern PCB manufacturing processes offer structure sizes in the dozens of micrometer range. High-resolution tamper sensing meshes manufactured at such structure sizes consist of thousands of segments and many meters of PCB traces. Kimesh automates the geometry generation for tamper sensing meshes. Using Kimesh, the EDA engineer defines the area to be filled with the mesh and places a special footprint demarking the connection between the monitoring circuit and the mesh. The generator itself is invoked from the PCB editor GUI and has a GUI for configuring additional layout parameters such as the degree of layout randomization.

Kimesh supports any number of parallel mesh traces. While generating the mesh, kimesh automatically avoids obstacles such as footprints or traces, and automatically stays within the board's outline. The following figure illustrates Kimesh's algorithm.

Kimesh's Mesh Generation Process

Kimesh generates meshes by first overlaying the PCB layout with a grid. This grid is then filled with pre-configured tiles to fill all cells that lie with the mesh's area, that are within the board's outline, and that do not contain other PCB geometry such as footprints or traces.

Kimesh's core algorithm performs a depth-first search of the grid starting at the mesh's entry point. The search eventually visits each reachable grid exactly once. The resulting graph is a tree and looks similar to a labyrinth with no loops. Similar to how you would navigate a labyrinth by following the wall on one side, Kimesh lays out the mesh traces by walking this tree graph depth first from left to right.

Since the grid's cells are square shaped, there are only 16 possible trace patterns that can result inside once cell from this approach. Each cell has four sides, and on each of these four sides, the cell either is connected to its neighboring cell, or it is not. When it is connected, a trace leaves and returns to the cell across that edge. When it is not connected, a trace runs parallel to that edge.

Looking closer, of those 16 patterns, one is invalid (a grid cell with no traces entering nor leaving), and among the remaining 15, 10 are rotations or mirror images of another pattern. The following figure illustrates this.

There are six possible tile types in our connectivity graph inside its square tiling. This graphic illustrates all sixteen rotations of these with how they would look in a two-conductor mesh.

Kimesh assembles the final trace pattern by looking up each grid cell in this set of patterns, and tiling the corresponding pattern on the PCB.

You can download kimesh from Kicad's built-in plugin manager. Kimesh's source code is available here.