Connecting to Hardware (Capturing Traces)

scope.arm()
target.simpleserial_write('p', msg)
## fill in the rest...

What do i fill in the rest ?

tried to write few scripts but nothing worked.

%%bash
cd ../firmware/mcu/simpleserial-aes/
make PLATFORM=CWLITEARM CRYPTO_TARGET=TINYAES128C SS_VER=SS_VER_2_1

msg = bytearray([0x43]*16) #simpleserial uses bytearrays
target.simpleserial_write(‘p’, msg)

print(target.simpleserial_read(‘r’, 16))

msg = bytearray([0x42]*16) #simpleserial uses bytearrays
target.simpleserial_write(‘k’, msg)

print(target.simpleserial_wait_ack()) #should return 0

target.write(‘p’ + “00”*16) #fill in the rest here

recv_msg = “”

recv_msg += target.read() #you might have to run this block a few times to get the full message
print(recv_msg)

import chipwhisperer as cw

scope = cw.scope()
target = cw.target(scope, cw.targets.SimpleSerial2)

scope.default_setup()

Example key and plaintext

key = bytearray([0x00]*16)
msg = bytearray([0x42]*16)

Sending the key first

target.simpleserial_write(‘k’, key)

Arm the scope

scope.arm()

Send plaintext (this triggers encryption + scope capture)

target.simpleserial_write(‘p’, msg)

Wait for capture to complete

ret = scope.capture()
if ret:
print(“Timeout happened during capture”)
else:

Get the captured waveform

trace = scope.get_last_trace()

# Read back ciphertext from target
ciphertext = target.simpleserial_read('r', 16)

# Print results
print("Plaintext:", msg)
print("Ciphertext:", ciphertext)
print("Trace length:", len(trace))
print("First 10 samples:", trace\[:10\])

It’s hard to make out where you’ve run into trouble from what you’ve pasted.

I will assume that everything until the “Capturing Traces” section ran normally.

If so, then “fill in the rest” is spelled out very clearly in the “Capturing Traces” explanation: all you need to do is:

scope.capture()
trace = scope.get_last_trace()

If this doesn’t work for you, then run the notebook from the start, carefully following all instructions, and show all the errors or warnings that you get.