From 7189c931e5db356ca29fb34d0ccd376357f54446 Mon Sep 17 00:00:00 2001 From: Harvie Date: Mon, 8 Nov 2010 00:01:39 +0100 Subject: [PATCH] TODO: Reimplement RSA.pl using chinese remainder theorem (too slow right now) --- perl/rsa.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/perl/rsa.pl b/perl/rsa.pl index 522be22..7c8b316 100755 --- a/perl/rsa.pl +++ b/perl/rsa.pl @@ -5,7 +5,7 @@ use bignum; #We'll need bignum for real messages sub rsa { #RSA (de)crypt function (message,modulus,exponent) my ($msg,$m,$e) = @_; - ($msg**$e)%($m); + ($msg**$e)%($m); #TODO: reimplement using chinese remainder theorem (this is too slow!!!) } sub isprime { #Tell if number is prime or not (suboptimal) @@ -40,6 +40,7 @@ print "\t[[[ Harvie's simple RSA demo ]]]\nfor study & testing purposes only (IN print "=== KEYS ===\nPUB: ($n,$e)\nPRV: ($n,$d)\n"; my $msg=1337; +$msg=$n-1; print "=== TEST ===\nMSG: $msg\n"; my $enc=rsa($msg,$n,$e); #encrypt print "ENC: $enc\n"; -- 2.30.2