diff options
author | Barry Mead <barrymead@cox.net> | 2010-02-16 12:37:28 -0700 |
---|---|---|
committer | Barry Mead <barrymead@cox.net> | 2010-02-16 12:37:28 -0700 |
commit | 350827e5dcee8b9662950269825440ea7750f55f (patch) | |
tree | 428092a44a340eb4a3d768fa1f52a87837dc681f | |
parent | df0c33f5870de646ad482ab0347f56fd8bbf3787 (diff) | |
download | rsa-git-350827e5dcee8b9662950269825440ea7750f55f.tar.gz |
Made extended_gcd not return any negative values for either i or j
-rw-r--r-- | rsa/__init__.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/rsa/__init__.py b/rsa/__init__.py index 2469136..f6f1e74 100644 --- a/rsa/__init__.py +++ b/rsa/__init__.py @@ -328,6 +328,7 @@ def extended_gcd(a, b): y = 1 lx = 1 ly = 0 + la = a lb = b #Remember modulus (to remove negs) while b != 0: q = long(a/b) @@ -335,6 +336,7 @@ def extended_gcd(a, b): (x, lx) = ((lx - (q * x)),x) (y, ly) = ((ly - (q * y)),y) if (lx < 0): lx += lb #No Negative return values + if (ly < 0): ly += la return (a, lx, ly) # Main function: calculate encryption and decryption keys |