RSA Algorithm (private key calculation) in bash -
looking on how calculate rsa secret key in bash script 'd' when p, q & e given.
although know query has come before, seem find theoretical advice on calculation of rsa private key when p, q & e given.
i trying put calculation in bash script , explanation on calculations possible in bash (with expr or bc)
i found site advised following; (with 't' being totient of p*q, or rather totient of 'n')
d=$(echo "((2 * $t) + 1) / $e" | bc)
but seems work on specific case , did not provide correct output when trying on different cases.
any on how write bash formula calculation ?
from defition of rsa
|e*d| = 1 (mod fi(p*q))
where fi(n) euler function
so need calculate inversion of e in modulo. don't forget check if gcd(e,fi(p*q))=1 or may not find inversion of e in given modulo.
you can achieve using extended euclidean algorithm. there lot of pseudocodes on web. need more help?
Comments
Post a Comment