aboutsummaryrefslogtreecommitdiff
path: root/aes.c
diff options
context:
space:
mode:
authortoni <matzeton@googlemail.com>2017-01-18 16:26:08 +0100
committertoni <matzeton@googlemail.com>2017-01-18 16:26:08 +0100
commit4a30d5b93533bd2e70ebaff330a5dae0db3e0ffa (patch)
tree450b4813147c8544fa95f1d5c3706b462689838f /aes.c
parentc3bba3cf25d9f392bf7a972bd740721fe4fe13fa (diff)
rdtsc is only on x86 platforms available
Diffstat (limited to 'aes.c')
-rw-r--r--aes.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/aes.c b/aes.c
index c10589e..4eec962 100644
--- a/aes.c
+++ b/aes.c
@@ -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);