diff options
author | toni <matzeton@googlemail.com> | 2017-01-18 16:26:08 +0100 |
---|---|---|
committer | toni <matzeton@googlemail.com> | 2017-01-18 16:26:08 +0100 |
commit | 4a30d5b93533bd2e70ebaff330a5dae0db3e0ffa (patch) | |
tree | 450b4813147c8544fa95f1d5c3706b462689838f /aes.c | |
parent | c3bba3cf25d9f392bf7a972bd740721fe4fe13fa (diff) |
rdtsc is only on x86 platforms available
Diffstat (limited to 'aes.c')
-rw-r--r-- | aes.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -94,16 +94,23 @@ char* aes_crypt_s(aes_ctx_t* ctx, char* input, size_t siz, size_t* newsiz, bool return output; } -static uint64_t __rdtsc(void) +#ifdef __i386__ +static uint64_t __rnd(void) { unsigned int lo, hi; __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); return ((uint64_t)hi << 32) | lo; } +#else +static uint64_t __rnd(void) +{ + return 0; +} +#endif static void __pseudoRandom(unsigned char* buf, size_t siz) { - time_t seed = time(NULL) + __rdtsc(); + time_t seed = time(NULL) + __rnd(); for (size_t i = 0; i < siz; ++i) { buf[i] = (unsigned char)((seed * time(NULL)) % 256); |