diff options
author | Jack Lloyd <[email protected]> | 2019-12-03 05:46:29 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-12-03 05:46:29 -0500 |
commit | a5d18d9ce19e3d5e2229c592de62955e183b5448 (patch) | |
tree | 9fd7d5df04ab88231dc2c25b6cd64a520fda24d0 /src/python | |
parent | 4aa90eb8e530ae611fba712b54c7a73720c2ad60 (diff) | |
parent | 805880b45096ed8b8ff4644eb908951b5d43a45d (diff) |
Merge GH #2208 Add a few more Python functions
Diffstat (limited to 'src/python')
-rwxr-xr-x | src/python/botan2.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/python/botan2.py b/src/python/botan2.py index 2018cae20..dcff583a9 100755 --- a/src/python/botan2.py +++ b/src/python/botan2.py @@ -1415,9 +1415,9 @@ class X509Cert(object): # pylint: disable=invalid-name def validation_status(cls, error_code): return _ctype_to_str(_DLL.botan_x509_cert_validation_status(c_int(error_code))) -class MPI(object): +class MPI(object): # pylint: disable=too-many-public-methods - def __init__(self, initial_value=None): + def __init__(self, initial_value=None, radix=None): self.__obj = c_void_p(0) _DLL.botan_mp_init(byref(self.__obj)) @@ -1426,6 +1426,8 @@ class MPI(object): pass # left as zero elif isinstance(initial_value, MPI): _DLL.botan_mp_set_from_mp(self.__obj, initial_value.handle_()) + elif radix is not None: + _DLL.botan_mp_set_from_radix_str(self.__obj, _ctype_str(initial_value), c_size_t(radix)) elif isinstance(initial_value, str): _DLL.botan_mp_set_from_str(self.__obj, _ctype_str(initial_value)) else: @@ -1591,6 +1593,16 @@ class MPI(object): _DLL.botan_mp_rshift(self.__obj, self.__obj, shift) return self + def mod_mul(self, other, modulus): + r = MPI() + _DLL.botan_mp_mod_mul(r.handle_(), self.__obj, other.handle_(), modulus.handle_()) + return r + + def gcd(self, other): + r = MPI() + _DLL.botan_mp_gcd(r.handle_(), self.__obj, other.handle_()) + return r + def pow_mod(self, exponent, modulus): r = MPI() _DLL.botan_mp_powmod(r.handle_(), self.__obj, exponent.handle_(), modulus.handle_()) |