salty icon indicating copy to clipboard operation
salty copied to clipboard

[features] cycle counter instrumented library

Open enrikb opened this issue 5 years ago • 1 comments

Even though QEMU does not implement the cortex M4 DWT cycle counter, real hardware often does. I have successfully tested the commented out cycle counter code from qemu-test on a real STM32F411 board. Of course, the cycle count for sign() is not constant, as the message length varies. So, now it would be nice to have a feature in salty to enable cycle counting in 'the right places'. As a starting point, dedicated tests for low level calls would be fine, too.

** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
enabled cycle counter
keypair.sign took 5539346 cycles
keypair.sign took 5539196 cycles
keypair.sign took 5539230 cycles
keypair.sign took 5539254 cycles
keypair.sign took 5873812 cycles
keypair.sign took 5564848 cycles
All tests passed, including RFC 8032 test vectors!

(As a quick test, I wrapped all regular sign() calls with the counting code.)

enrikb avatar Oct 27 '20 16:10 enrikb

There's also the problem of caches, e.g. try and time signing the same message twice.

nickray avatar Oct 28 '20 14:10 nickray