2020-07-27 15:55:24 +00:00
|
|
|
// TODO: cut-in xcrypt-ecb
|
|
|
|
#include <cstdlib>
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
2020-08-06 01:43:23 +00:00
|
|
|
unsigned int msr=0;
|
|
|
|
unsigned int divisor=2;
|
2020-07-27 15:55:24 +00:00
|
|
|
unsigned int buffer;
|
|
|
|
|
2020-08-06 01:43:23 +00:00
|
|
|
__asm__ __volatile__
|
|
|
|
(
|
2020-07-27 16:46:11 +00:00
|
|
|
#if defined(__x86_64__) || defined(__amd64__)
|
2020-08-06 02:10:31 +00:00
|
|
|
"mov %1, %%rdi ;\n"
|
|
|
|
"movl %2, %%edx ;\n"
|
2020-07-27 15:55:24 +00:00
|
|
|
#else
|
2020-08-06 02:10:31 +00:00
|
|
|
"mov %1, %%edi ;\n"
|
|
|
|
"movl %2, %%edx ;\n"
|
2020-07-27 15:55:24 +00:00
|
|
|
#endif
|
|
|
|
|
2020-08-06 02:10:31 +00:00
|
|
|
// xstore-rng
|
|
|
|
".byte 0x0f, 0xa7, 0xc0 ;\n"
|
2020-07-27 15:55:24 +00:00
|
|
|
|
2020-07-27 16:46:11 +00:00
|
|
|
#if defined(__x86_64__) || defined(__amd64__)
|
2020-08-06 02:10:31 +00:00
|
|
|
"andq %%rax, 0x1f ;\n"
|
|
|
|
"movl %%eax, %0 ;\n"
|
2020-07-27 15:55:24 +00:00
|
|
|
#else
|
2020-08-06 02:10:31 +00:00
|
|
|
"andl %%eax, 0x1f ;\n"
|
|
|
|
"movl %%eax, %0 ;\n"
|
2020-07-27 15:55:24 +00:00
|
|
|
#endif
|
|
|
|
|
2020-08-06 02:10:31 +00:00
|
|
|
: "=g" (msr) : "g" (buffer), "g" (divisor)
|
2020-07-27 16:46:11 +00:00
|
|
|
#if defined(__x86_64__) || defined(__amd64__)
|
2020-08-06 02:10:31 +00:00
|
|
|
: "rax", "rdx", "rdi", "cc"
|
2020-07-27 15:55:24 +00:00
|
|
|
#else
|
2020-08-06 02:10:31 +00:00
|
|
|
: "eax", "edx", "edi", "cc"
|
2020-07-27 15:55:24 +00:00
|
|
|
#endif
|
2020-08-06 01:43:23 +00:00
|
|
|
);
|
2020-07-27 15:55:24 +00:00
|
|
|
|
2020-08-06 01:43:23 +00:00
|
|
|
return 0;
|
2020-07-27 15:55:24 +00:00
|
|
|
}
|