diff options
author | Jack Lloyd <[email protected]> | 2016-12-11 15:52:45 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-12-11 15:52:45 -0500 |
commit | e8009766ca21ad4fc22a9c07ee33673dc5f7bd44 (patch) | |
tree | ddfc5a4be1a39a02e4dd0854a57a085d1a29b0c8 /src/lib/math | |
parent | 47553063c58f7b34aa477f2820d8ff1e2414e997 (diff) |
In ressol, prohibit a >= p
Technically defined, but should never be seen in practical crypto context.
Diffstat (limited to 'src/lib/math')
-rw-r--r-- | src/lib/math/numbertheory/ressol.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/math/numbertheory/ressol.cpp b/src/lib/math/numbertheory/ressol.cpp index 2c83cb0e0..9d11ebbc4 100644 --- a/src/lib/math/numbertheory/ressol.cpp +++ b/src/lib/math/numbertheory/ressol.cpp @@ -19,14 +19,16 @@ BigInt ressol(const BigInt& a, const BigInt& p) if(a == 0) return 0; else if(a < 0) - throw Invalid_Argument("ressol(): a to solve for must be positive"); + throw Invalid_Argument("ressol: value to solve for must be positive"); + else if(a >= p) + throw Invalid_Argument("ressol: value to solve for must be less than p"); if(p == 2) return a; else if(p <= 1) - throw Invalid_Argument("ressol(): prime must be > 1 a"); + throw Invalid_Argument("ressol: prime must be > 1 a"); else if(p.is_even()) - throw Invalid_Argument("ressol(): invalid prime"); + throw Invalid_Argument("ressol: invalid prime"); if(jacobi(a, p) != 1) // not a quadratic residue return -BigInt(1); |