From: server Date: Wed, 23 Aug 2023 00:36:47 +0000 (-0400) Subject: Tue Aug 22 08:36:47 PM EDT 2023 X-Git-Url: http://www.foleosoft.com/?a=commitdiff_plain;h=93c6d16f12111b80260677c15754418a0c3ac132;p=CryptoFoleo.git Tue Aug 22 08:36:47 PM EDT 2023 --- diff --git a/bin/CryptoFoleo.h b/bin/CryptoFoleo.h index 3fc192e..68e54e6 100644 --- a/bin/CryptoFoleo.h +++ b/bin/CryptoFoleo.h @@ -16,7 +16,9 @@ uint8_t* foleo_poly1305(uint8_t[32], uint8_t*, size_t); #define FOLEO_RSA_PADDING_PSS 4 #define FOLEO_RAND_MODE_DEVR 1 #define FOLEO_RAND_MODE_DEV 2 +#ifdef ENABLE_X86 #define FOLEO_RAND_MODE_X86 3 +#endif typedef struct { mpz_t n, k; @@ -51,4 +53,4 @@ uint8_t* foleo_hmac_prf(uint8_t, uint32_t, uint8_t*, uint32_t, uint8_t*, uint32_ uint8_t foleo_hash_size(uint8_t); void foleo_rand_mode(uint8_t, uint8_t*); -#endif \ No newline at end of file +#endif diff --git a/bin/libCryptoFoleo.so b/bin/libCryptoFoleo.so index 6ced20b..3276ad2 100755 Binary files a/bin/libCryptoFoleo.so and b/bin/libCryptoFoleo.so differ diff --git a/src/headers.h b/src/headers.h index 3fc192e..68e54e6 100644 --- a/src/headers.h +++ b/src/headers.h @@ -16,7 +16,9 @@ uint8_t* foleo_poly1305(uint8_t[32], uint8_t*, size_t); #define FOLEO_RSA_PADDING_PSS 4 #define FOLEO_RAND_MODE_DEVR 1 #define FOLEO_RAND_MODE_DEV 2 +#ifdef ENABLE_X86 #define FOLEO_RAND_MODE_X86 3 +#endif typedef struct { mpz_t n, k; @@ -51,4 +53,4 @@ uint8_t* foleo_hmac_prf(uint8_t, uint32_t, uint8_t*, uint32_t, uint8_t*, uint32_ uint8_t foleo_hash_size(uint8_t); void foleo_rand_mode(uint8_t, uint8_t*); -#endif \ No newline at end of file +#endif diff --git a/src/rand.c b/src/rand.c index 628da77..84a4d15 100644 --- a/src/rand.c +++ b/src/rand.c @@ -52,6 +52,7 @@ static void rand_get(void* context, uint8_t* buf, size_t bytes) fread(buf, 1, bytes, f); } } +#ifdef ENABLE_X86 else if (RAND_MODE == FOLEO_RAND_MODE_X86) { uint64_t r; @@ -68,6 +69,7 @@ static void rand_get(void* context, uint8_t* buf, size_t bytes) avail -= 1; } } +#endif } static uint8_t rand_getc(void* context) @@ -83,12 +85,14 @@ static uint8_t rand_getc(void* context) return fgetc((FILE*)context); } } +#ifdef ENABLE_X86 else if (RAND_MODE == FOLEO_RAND_MODE_X86) { uint64_t r; __asm__ volatile ("1:;rdseed %0;;jnc 1b;" : "=r" (r)); return r & 0xFF; } +#endif } static void rand_end(void* context) @@ -101,7 +105,14 @@ static void rand_end(void* context) void foleo_rand_mode(uint8_t mode, uint8_t* info) { - if (mode == FOLEO_RAND_MODE_DEVR || mode == FOLEO_RAND_MODE_DEV || mode == FOLEO_RAND_MODE_X86) + if + ( + mode == FOLEO_RAND_MODE_DEVR + || mode == FOLEO_RAND_MODE_DEV +#ifdef ENABLE_X86 + || mode == FOLEO_RAND_MODE_X86 +#endif + ) { if (mode == FOLEO_RAND_MODE_DEV) {