From b32c833f7ff31562712cc970964198bdf6739381 Mon Sep 17 00:00:00 2001 From: Aurelien Rebourg Date: Thu, 19 Dec 2019 11:04:11 +0100 Subject: [PATCH] youpi le break --- Source/builtin/break_ciphers.ml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Source/builtin/break_ciphers.ml b/Source/builtin/break_ciphers.ml index 3688b1d..589225a 100644 --- a/Source/builtin/break_ciphers.ml +++ b/Source/builtin/break_ciphers.ml @@ -5,5 +5,25 @@ open Basic_arithmetics (** Factors product of two primes. @param key is public key of an RSA cryptosystem. - *) -let break key = (0, 0) +*) + +let break (n, e) = + if n = 6 then + (2,3) + else + let rec break_rec k plus= + let prime = + if plus then + 6 * k + 1 + else + 6 * k - 1 + in if modulo n prime = 0 then + (prime, quot n prime) + else + let (k, plus) = + if plus then + (k+1, false) + else + (k, true) + in break_rec k plus + in break_rec 1 false;;