I have recently read about AES cache timing attacks. More specifically, I read Daniel Bernstein paper Cache-timing attacks on AES. I have a question about the code in Appendix A:

unsigned int timestamp(void)
unsigned int bottom;
unsigned int top;
asm volatile(".byte15;.byte 49" : "=a"(bottom),"=d"(top));
return bottom;

What does timestamp methode do?

  • 4
    $\begingroup$ This question appears to be off-topic because it is about the meaning of Intel x86 assembly instructions; this site is for questions about cryptography. $\endgroup$ – D.W. Jan 14 '15 at 23:46

The opcode 15 49 (0F 31 - Intel opcodes are more typically listed in hexidecimal) is the RDTSC instruction; this loads the number of cycles since the last rest into EDX:EAX.

By running this function, running some code, and then running this function again, and subtracting the results, you get precisely how long the code takes (in number of CPU cycles).

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.