Storing values sent via simpleserial_write?

Hey, wanted to ask regarding simpleserial.
I’m using simpleserial-base, I can send an array to the chipwhisperer, like this:

msg = bytearray([0] * 32) 
target.simpleserial_write('p', msg)
print(target.simpleserial_read('r', 32))

and on the chipwhisperer in get_pt() : simpleserial_put('r', 32, pt);

and i get back the array.

I want to ask, how is it possible to store this value as a variable on the chipwhisperer, so that i can expose it and use it in other functions.

Or is it simply stored in “pt” and can be used in other functions?

Regards

What do you mean by “on the chipwhisperer”? Are you referring to:

  1. The target? That’s up to you, you can implement this as you wish in the target’s firmware.
  2. The capture unit? Not really.
  3. The host software? This is trivial; it’s what we do in most/all of our notebooks. The cw.capture_trace() function returns a Trace object which contains not only the power measurements but the key, plaintext, and ciphertext associated with that measurement.

Thank you for the answer.

I just want to have the bytearray that I send using python/simpleserial to the target board (dummy value [0]*32 ) as a usable variable (array of 32 elements) in my simpleserial-base.c, but i don’t understand how exactly this works, namely, how to access pt and how to later convert it to format i need (int array).

I think if I can somehow access the value of pt on my target board and save it as a global(?) variable on the target, it will not be hard to convert it to the format I need.

Sorry if this is very trivial, but could you give me a pointer?

Yup, you can fairly easily save pt as a global variable. As an example:

#define PT_LEN 32
uint8_t PT_GLOBAL[PT_LEN] = {0};
uint8_t get_pt(uint8_t* pt, uint8_t len)
{
    memcpy(PT_GLOBAL, pt, PT_LEN);
    simpleserial_put('r', PT_LEN, pt);
    return 0x00;
}

EDIT: Fixed simpleserial_put call

1 Like