diff --git a/src/chat/crypto.c b/src/chat/crypto.c
index 65033fc..742266d 100644
--- a/src/chat/crypto.c
+++ b/src/chat/crypto.c
@@ -16,4 +16,31 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-#include
\ No newline at end of file
+#include
+
+#include
+#include
+
+#include
+
+//LOCAL
+void generate_prime(mpz_t x)
+{
+ //RANDOM
+ gmp_randstate_t state;
+ gmp_randinit_default(state);
+ unsigned long random_buffer; //SEED
+
+ do
+ {
+ if (getrandom(&random_buffer, sizeof(unsigned long), GRND_NONBLOCK) == -1) why2_die("getrandom fn failed!");
+
+ //GENERATE RANDOM PRIME USING random_buffer SEED
+ gmp_randseed_ui(state, random_buffer);
+ mpz_urandomb(x, state, WHY2_CHAT_KEY_BITS);
+ mpz_nextprime(x, x);
+ } while (mpz_probab_prime_p(x, WHY2_CHAT_PRIME_ITERS) == 0); //CHECK FOR PRIME PROBABILITY
+
+ //DEALLOCATION
+ gmp_randclear(state);
+}
\ No newline at end of file