返回资讯中心
外部精选
软件工程
#开发者实时流

BeachWhisperer: DPA Against NRF52840 Hardware AES with Claude

My DPA Dog-friend (Bergen) is my faithful research assistant out here.

Hacker News 最新hasheddan2026/11/23 · 今天30 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

My DPA Dog-friend (Bergen) is my faithful research assistant out here.

There is a not-too-untrue caricature of hardware hackers as being people in a dark lab, surrounded by test equipment and blinking lights. Unlike software attacks, with hardware you’ve got to be “near the equipment”. Or at least, that was what I always thought.

Over late summer/fall I gave Claude access to a ChipWhisperer-Husky with a nRF52840 target. I was curious to see if it could attack one of the the nRF52840 AES cores, specifically the Arm CryptoCell 310 AES core.

Around this time eShard published a successful attack as well, although this was’t used as input (and we ended up with an attack from the other end they looked at interestingly, described below).

At the same time it was quite a nice day out - so I’d like to go enjoy some time outside. Using Claude remote control I decided to kick off the attack and from there let it work semi-autonomously. From my phone I could request power traces and do other things that one cannot easily code from a mobile phone.

In total from my first prompt until a successful attack was about nine hours, and I had about 13 prompts in-between. This successfully broke both nRF AES accelerators with almost no special knowledge input from me, giving an interesting snapshot into the future of security research.

I plugged in my ChipWhisperer-Husky with a nRF52840 board from a drawer that I was pretty sure worked (I use a lot of “R&D” models so here my husky has no enclosure):

The nRF52840 Target of unknown providence.

I started with an empty folder. I had run a few other attacks before with Claude, but I figured I’d like it deal with most of the setup, so kick off the session with my initial prompt:

Attached is a chipwhisperer-husky with an nrf52840 target - there is a HAL in the CW folder. A J-Trace is attached for programming. Can you get the hardware AES running and perform a SCA attack on it?

There was previous examples in ../f5_hwc and ../sca_toolkit of attacking chipwhisperer targets. ChipWhisperer is available at C:\ChipWhisperer6 .

The previous project had a batched segmented capture mode (that Claude also wrote) that eventually got me from 40 encryptions/second to 36,000 traces/second. It did this by running a pseudorandom generator on the target & not sending back any plain/ciphertext, but checks every “so often” that things are still in sync.

Thirteen prompts over the day of “work”, many of them one line, sometimes just minor pointers to the setup. e.g., I had a (typos-included) prompt to point it to the nRF HAL early on:

There is a hal int he chipwhisperer-extra submodule of the hal

Here is a list of all prompts + time, a few were typed while it was still working and sat queued, so sometimes the time doesn’t match when it was working:

The only two with any technical input were at 12:36 and 14:20. So in terms of “expertise required” it still felt low.

Programming worked but the serial link was dead. I had grabbed a random nRF52840 board I had lying around - I couldn’t remember if it actually worked, so I would have otherwise had to go debug it. But Claude came back with:

Firmware is alive - PC is inside nrf_serial_read, waiting for a character. So the issue is the UART link. Let me probe it raw.

Then it mapped the pins: drive each ChipWhisperer TIO pin in turn, read the nRF’s GPIO.IN back over SWD, and disambiguate the floating ones. TIO1, TIO3 and TIO4 answered. TIO2 never did, which is the net the stock HAL puts UART RX on. It then went and read the board schematic PDF to confirm the net:

TIO2/GPIO2 is dead at the physical level (the Husky configures identically for tio1/3/4 and those work). I’ll work around it by moving the target’s UART RX to GPIO3.

So this particular board has an open circuit on GPIO2 and I didn’t know. Amazingly it just “wrote around” the hardware problem with almost no input from me.

The initial capture showed no real AES signal. Rather than guess, it read the schematic for the board. I had designed this board to have a nice SCA measurement path, but actually Claude didn’t “know” what was in my mind, although basically “figured out” that the caps were designed to simplify DPA measurements (what it means to “figure out” we can argue, for now lets just brush over that):

Remove C5 (1 µF) first. Per the schematic netlist, C5 is on the SHUNTL net - i.e. directly across DEC4/DEC6, on the chip side of the shunt. It shunts exactly the AC core current we’re trying to measure through R1. It is the one cap that is actively cancelling our signal.

I did indeed have C5 on the board still, so removed that, and gain required changed from about from 50 dB down to 12 dB to get a good signal.

The other thing standing between us and the cipher was software: the CPU sits in a while(!EVENTS_ENDECB) polling loop for the whole encryption and drowns a 40-cycle AES. Again, this wasn’t my direction but it did figure out that it needs to sleep the core instead of a busy-wait loop to reduce noise. It even did some debugging to figure out why it didn’t work first time:

Confirmed - WFE hangs. The cause: with the ECB IRQ disabled in the NVIC, a pending interrupt doesn’t generate a wake-up event unless SCR.SEVONPEND is set.

With the CPU asleep the round structure is fairly clear, showing ten rounds at 4 cycles each, then EasyDMA writing the ciphertext out one byte per 4 cycles (a few rounds don’t show up due to noise):

Every AES round transition located in time, with the CPU asleep. The staircase is rounds 3-4 through 8-9; the first two and last two don’t clear the noise floor at 20k traces. Right panel is the same capture a hundred samples later, where EasyDMA pushes the ciphertext out one byte at a time.

At this point, we can do the rest from our phone somewhere outside our dark lab (such as the beach) and fix our Vitamin-D deficiency.

I should emphasize heavily: from here on the majority of work is done automatically - changing leakage points, filters, etc was mostly done at Claude’s own impetus with minor prompting. All figures in the post are generated via scripts from Claude. This post is mostly me + Claude. LLM generated text reads weirdly I find, so it’s mostly me cleaning up or fixing stuff although sometimes it did a pretty good job on paragraphs I just left alone, and sorry for being lazy and subjecting you to it’s stringed-together-words. At least you have warning?

NRF_ECB is the AES-128 block the BLE stack uses: 486 core cycles a block, of which the ten rounds are only about 40. Here it is next to the more interesting (CC310) core on the same time axis (NB: This figure was generated with knowledge of the leakage - it cannot be known at “this point in time” if you are reading the work linearily).

Both cores with the AES of each zoomed below. Rhe cipher takes about the same time on both, roughly 40 core cycles, so the 486 against 716 per block is wrapper rather than silicon. Every boundary comes out of a correlation or NICV profile, and the shaded bands (relevant samples) mark where leakage is measurable rather than the exact extent of the cipher, which is why the ECB band looks the narrower of the two. The dotted red lines in the zooms are measured round transitions, some never clear the noise floor at 20k traces so are not marked.

Its first-round attack on HW(pt ⊕ Sbox(pt⊕k)), and the core falls over completely: 16 of 16 key bytes exactly right, full key rank 2^0, from 2 M traces, which is 90 seconds of capture at 23,000 traces/s. Crossing 2^32 (the point where you’d just enumerate the rest) takes 150-250k traces depending on the key, about ten seconds of capture. Verified on three independent random keys.

Two names are about to keep coming up, so to get them out of the way: HW is Hamming weight, the number of set bits in a byte. CPA correlates each trace sample against the Hamming weight of the byte you’re guessing, which quietly assumes all eight bits of it cost the same power. LRA drops that assumption and fits a weight per bit instead, nine numbers rather than one fixed yardstick, so it is more honest about the leakage and more expensive in variance. Which of the two is the better choice on a given core is not obvious at all, and getting that wrong is one of the retractions further down.

The filter is doing real work there. Unfiltered CPA gets 13/16 and rank 2^32; subtract a local moving average (bandpass4-14) and it’s 16/16 at 2^0. This will be described in more detail later.

The other core is an Arm CryptoCell CC310, reached through Nordic’s SaSi runtime, 716 cycles a call, which as the figure above shows is nearly all wrapper. After it did a longer (500k) capture, it reported no success. Wanting to see for myself, I asked it from my phone to give me some graphs to satisfy my curiosity:

My first mobile query after kicking off from my computer, asking for some better graphics.

This showed no observable leakage. But leakage below the noise looks like no leakage, so I knew we could just go harder.

With the new capture method, we could capture millions of traces quickly. So the next goal was to tell it to kill my SSD and just go wild with captures. My next beach prompt was telling it to go ahead with a longer capture, at which point I picked back up from home (since the next step took a few hours, but without me):

My request for Claude to go harder. I didn’t provide real technical direction, just a vibe.

A few hours later it had come back with a successful attack, and I knew it would be possible to improve this (as it always is once you see some leakage):

Both cores on the same axes. The grey curve is the CC310 attacked over the whole trigger window - pinned at 2^128, which is what failed at first.

The CC310’s AES is 6% of what we were capturing. Sweeping blocks-per-call gives duration = 642 + 40.8 x blocks core cycles, so a single-block SaSi_AesBlock() call is 94% library overhead: DMA setup and a status-register poll. The ECB core is no better on that measure, about 40 cycles of cipher inside 486, it just has less wrapper to hide in and the wrapper it does have is EasyDMA moving the key and the result rather than a CPU in a polling loop. And at 500k traces the NICV floor sat at 5.1e-4 while the round leakage is about 4e-4. Buried, not absent.

“We” (aka Claude) can make some nice figures for us on request, like showing where the leakage should become detectable:

The floor for a 256-class NICV is 255/N, so it moves and the leakage doesn’t. The ten rounds aren’t one level but a band, 2.2e-4 to 1.08e-3 measured at 2 M, round 8 quietest and round 6 loudest. At 500k the floor sits above all but the loudest of them, which is the ’no measurable leakage’. At 2 M rounds 1 to 7 clear twice the floor, and round 8 at 1.75x so still reads as nothing.

Finding the cipher needed a detector that assumes nothing, since the whole question was whether it leaks at all. The trick that worked: encrypt n blocks in one call and look for where the mean trace stops agreeing with the n=1 mean.

No leakage model, no key, no assumption about the cipher. mean(n=2) and mean(n=4) part company with mean(n=1) around sample 1030, which is where block one’s AES ends; the legend numbers are where each curve crosses the dotted threshold, which is deliberately blunt, so they land a little late. n=16 and n=32 diverge much earlier because the library’s DMA setup scales with buffer length, so only the small-n curves locate the cipher.

That cut is also the reason any of the big captures were affordable. Throughput here is ADC samples coming off the Husky rather than anything the target does, about 2.6 M samples/s, so the trace rate

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →