Error with my square and multiply algorithm
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!