diff options
author | Determinant <[email protected]> | 2024-08-23 03:14:03 +0000 |
---|---|---|
committer | Determinant <[email protected]> | 2024-08-22 20:34:57 -0700 |
commit | 8d1c76ec7caf247d5675e14260d20fc508977ffb (patch) | |
tree | 8fa7c8ce3b7e3f4ece150a6da5922b5eb2dc7772 /frozen_deps/Cryptodome/Math/_IntegerGMP.py | |
parent | 258780284151d49cba1d9c0d2ce33f9a19bb058b (diff) |
release v0.1.8
Diffstat (limited to 'frozen_deps/Cryptodome/Math/_IntegerGMP.py')
-rw-r--r-- | frozen_deps/Cryptodome/Math/_IntegerGMP.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/frozen_deps/Cryptodome/Math/_IntegerGMP.py b/frozen_deps/Cryptodome/Math/_IntegerGMP.py index 3ab7c59..f58f044 100644 --- a/frozen_deps/Cryptodome/Math/_IntegerGMP.py +++ b/frozen_deps/Cryptodome/Math/_IntegerGMP.py @@ -749,6 +749,26 @@ class IntegerGMP(IntegerBase): raise ValueError("n must be positive odd for the Jacobi symbol") return _gmp.mpz_jacobi(a._mpz_p, n._mpz_p) + @staticmethod + def _mult_modulo_bytes(term1, term2, modulus): + if not isinstance(term1, IntegerGMP): + term1 = IntegerGMP(term1) + if not isinstance(term2, IntegerGMP): + term2 = IntegerGMP(term2) + if not isinstance(modulus, IntegerGMP): + modulus = IntegerGMP(modulus) + + if modulus < 0: + raise ValueError("Modulus must be positive") + if modulus == 0: + raise ZeroDivisionError("Modulus cannot be zero") + if (modulus & 1) == 0: + raise ValueError("Odd modulus is required") + + numbers_len = len(modulus.to_bytes()) + result = ((term1 * term2) % modulus).to_bytes(numbers_len) + return result + # Clean-up def __del__(self): |