Hi,
I am currently trying to implement a crypto algorithm in Chipwhisperer 1200 XMEGA platform.
The inputs are plaintext (64 bits) and key (128 bits). The cipher text output is also 64 bits.
So based on the previous discussions I have made my simpleserial.c file as
#include "hal.h"
#include "simpleserial.h"
#include "newcrypto_independant.h"
#include <stdint.h>
#include <stdlib.h>
uint8_t get_key(uint8_t* k, uint8_t len)
{
newcrypto_indep_key(k);
return 0x00;
}
uint8_t get_pt(uint8_t* pt, uint8_t len)
{
newcrypto_indep_enc_pretrigger(pt);
trigger_high();
#ifdef ADD_JITTER
for (volatile uint8_t k = 0; k < (*pt & 0x0F); k++);
#endif
newcrypto_indep_enc(pt); /* encrypting the data block */
trigger_low();
newcrypto_indep_enc_posttrigger(pt);
simpleserial_put('r', 8, pt); //value returned from the target pt is updated and returned
return 0x00;
}
uint8_t reset(uint8_t* x, uint8_t len)
{
return 0x00;
}
int main(void)
{
platform_init();
init_uart();
trigger_setup();
newcrypto_indep_init();
simpleserial_init();
simpleserial_addcmd('k', 16, get_key);
simpleserial_addcmd('p', 8, get_pt); //plaintext is 64bits and key is 128 bits
simpleserial_addcmd('x', 0, reset);
while(1)
simpleserial_get();
}
The python code is
keyd1=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
textd1=[0,0,0,0,0,0,0,0]
text=bytearray(textd1)
key=bytearray(keyd1)
scope.arm()
target.simpleserial_write('k', key)
target.simpleserial_write('p', text)
target.simpleserial_wait_ack()
ret = scope.capture()
if ret:
print("Target timed out!")
response = target.simpleserial_read('r', 8,timeout=10000)
print(response)
The output is CWbytearray(b’00 6a 75 e3 11 09 01 ff’) as desired
but when the following is executed
trace3=cw.capture_trace(scope,target,text,key)
results in
WARNING:ChipWhisperer Target:Unexpected start to command:
printing trace3 results in the following with textout = None :
Trace(wave=array([ 0.08007812, -0.125 , -0.15625 , …, -0.0078125 ,
0.02832031, 0.02246094]), textin=CWbytearray(b’ff ff ff ff ff ff ff ff’), textout=None, key=CWbytearray(b’00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00’))
I have earlier posted the related query in
were it was suggested to run
scope.adc.trig_count
So the output is 16554520 (which I found to be varying)
And I the earlier suggestion was the warning is because the encryption takes longer time. And yes I have replaced the component in encryption algorithm with three more additional functions. Now how can I increase the timeout period to read the generated cipher text?
Also the encryption operation was able to produce output through response = target.simpleserial_read(‘r’, 8,timeout=10000) but why not the same output through cw.capture_trace(scope,target,text,key) ?