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?


closed as off-topic by D.W., Stephen Touset, DrLecter, yyyyyyy, e-sushi Jan 17 '15 at 22:32

  • This question does not appear to be about cryptography within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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).


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