]> foleosoft.com Git - CryptoFoleo.git/commitdiff
Tue Aug 22 08:36:47 PM EDT 2023
authorserver <[email protected]>
Wed, 23 Aug 2023 00:36:47 +0000 (20:36 -0400)
committerserver <[email protected]>
Wed, 23 Aug 2023 00:36:47 +0000 (20:36 -0400)
bin/CryptoFoleo.h
bin/libCryptoFoleo.so
src/headers.h
src/rand.c

index 3fc192efdb396c0f56a2c8325b0408e9727db209..68e54e6e12cc5314c8dc01e5b7b645a2b50a8068 100644 (file)
@@ -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
index 6ced20bbe12dcd8349440733ee232f60f586a360..3276ad20b3ac3cb6fafe79f588e37f3aae882237 100755 (executable)
Binary files a/bin/libCryptoFoleo.so and b/bin/libCryptoFoleo.so differ
index 3fc192efdb396c0f56a2c8325b0408e9727db209..68e54e6e12cc5314c8dc01e5b7b645a2b50a8068 100644 (file)
@@ -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
index 628da77ba774809e4d9f00dda370e98308b67d3e..84a4d15b4d556f25f24ea0130db771b210ba2c9b 100644 (file)
@@ -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)
         {