Error with my square and multiply algorithm
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
So basically I have to implement a 32-bit version of RSA. However there's a problem with the SaM algorithm, which is the following:
function result = SquareAndMultiply(exponent,basis,modulus)
result = 1;
while exponent>0
if mod(exponent,2)==1
result = mod(result.*basis, modulus);
end
basis = mod(basis.*basis, modulus);
exponent = fix(exponent/2);
end
end
It shows that the encrypted message I decrypted is not equal to the original message, which began when the primes are 14 bits in size (before if it's 13 bits or less it works fine), which makes the modulus be 28 bits in size.
Anyone knows what happened here?
EDIT: It seems the value of n plays a role here.
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!