#Add simpleserial project to build
include …/simpleserial/Makefile.simpleserial
FIRMWAREPATH = …/.
include $(FIRMWAREPATH)/Makefile.inc
I use ASRC += macros.i as your suggestion in the makefile (either line 24, 25, or 26) but it makes no change in the error. Am I wrong with the SRC and the makefile you mentioned?
I’m guessing pqclean is all x86_64 since it’s got avx instructions, so I don’t think you should include any assembly files from there. I’m not familiar with this project, but pqclean might just be there for some .c/.h files.
We don’t have any plans to add Kyber as a crypto library to ChipWhisperer. That being said, I’m happy to answer questions about the build system if you want to try adding it in yourself.
Thanks for the reply.
So I am currently using the pqm4 library. I have went through several of the guides from the chipwhisperer github repo, and have done a report on the CW and how a CPA works and can be constructed.
My first intention for the Master´s is simply to be able to run a single instance of Kyber (using the pqm4 library) and experiment with where I can put the triggers to capture the traces. I am fully able to run the tests from pqm4 (python files) and it seems to work properly.
You should be able to stitch together a full trace based on smaller traces of varying offsets (this is done for the Lite in our ECC example on the F3: chipwhisperer-jupyter/uecc.ipynb at master · newaetech/chipwhisperer-jupyter · GitHub). Of course, you can also move trigger_high() around in the code to help you understand which parts of the power trace correspond to which parts of the code.
Setup your ChipWhisperer. Typically connecting and running scope.default_setup() gets you good settings to work off of
Make sure your target is programmed
Optionally, set a key on the target
Arm the scope (scope.arm())
Trigger your algorithm (in this case Kyber) to run, which in turn causes a rising edge on TIO4. In our default firmware, this is done via a serial message
Capture the trace (scope.capture())
Get the trace data (scope.get_last_trace())
Optionally, read the result of the encryption back
Thank you for your reply.
I have gotten further in my research, and the pieces are slowing coming together.
I have now managed to create a .hex-file with Kyber1024 ready to be tested. My next milestone would therefore be to implement the triggers around appropriate functions.
I am currently not working in the Simpleserial repo, so I do not have the same header files in my project. Is there a way to be able to use the trigger_high() and trigger_low() functions in my own project?
Hi,
I’m attempting to implement Kyber512 from the pqm4 library, but I have some issues. I have done some debugging through gdb, and I’m getting the error “[stm32f3x.cpu] clearing lockup after double fault” when reaching the assembly code “vpush.w {s16-s24}”. The code should be compatible as my target is the CW308-STM32F3 which the pqm4 library is designed for. I have attempted changing some gcc flags according to the pqm4 build process as “-mfloat-abi=hard -mfpu=fpv4-sp-d16 -ggdb3 -MD” without success. Any help is greatly appreciated.
Erlend
Hi,
Have you succeeded in debugging this issue? I am also trying to test Kyber512 from pqm4 on a STM32F3 CW Lite and, after finally compiling the firmware and programming the target, the program is stuck on any asm function. Didn’t get to find the root cause, the script just tries to run a key_gen() and get’s blocked/unresponsive. I tried with various mfpus, but for my board it only seems to compile a with a soft vfp. Any help or advice would be much appreciated.
I cannot provide more suggestion wwithout further information.
However, the hard fpu is available in the STM32F3 board, have you tried to modify the compilation script in “Makefile.inc” and “hal/stm32f3/Makefile.hal” ?
This thread was exactly what I needed. I added the missing code to hal/stm32f3/stm32f3_hal.c and recompiled the firmware. Works like a charm now. Thank you so much!
Hello, may I ask if MAX_SS_CMDS has a maximum value? My current main function can only add 34 simpleserial_addcmd commands, and the following simpleserial_addcmd will no longer respond.
I really appreciate you being able to answer my questions.
The hardware I use is cw-lite, cw308 and stm32f405.
Hi Alex and Tuan,
I wrote ‘ASRC += /path/to/macros.i’ but it still cannot be recognized. I tried adding rules to convert .i files to .s and .o, but they did not work. The error is as follows:
crypto_kem/kyber768/m4/macros.i:1:1: error: stray ‘#’ in program
1 | #ifndef MACROS_I
| ^
crypto_kem/kyber768/m4/macros.i:1:2: error: unknown type name ‘ifndef’
1 | #ifndef MACROS_I
| ^~~~~~
crypto_kem/kyber768/m4/macros.i:4:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘.’ token
4 | .macro load a, a0, a1, a2, a3, mem0, mem1, mem2, mem3
| ^
crypto_kem/kyber768/m4/macros.i:5:9: error: stray '' in program
5 | ldr.w \a0, [\a, \mem0]
| ^
crypto_kem/kyber768/m4/macros.i:5:15: error: stray '' in program
5 | ldr.w \a0, [\a, \mem0]
| ^
crypto_kem/kyber768/m4/macros.i:5:19: error: stray '' in program
5 | ldr.w \a0, [\a, \mem0]
| ^
crypto_kem/kyber768/m4/macros.i:6:9: error: stray '' in program
6 | ldr.w \a1, [\a, \mem1]
…
Hi there,
I had a similar problem when adding the .I files to the ASRC, namely “file format not recognized treating as linker script” + syntax error. I tried ignoring the files first and then changing their extension to .S in order to be recognized and both methods seem to work, as I get the firmware to compile and run Kyber procedures on the device.
However, I am not entirely sure this is ideal, nor if it fully works, because I found out that I can’t perform more than 40 kem procedures (keygen, enc, dec), after which the board becomes unresponsive. Other operations work smoothly, so the problem might very well be linked to this issue.
If anyone has any insight on this, it would be really helpful.