diff options
author | Pavol Žáčik <[email protected]> | 2019-10-21 14:01:44 +0200 |
---|---|---|
committer | Pavol Žáčik <[email protected]> | 2019-10-22 19:15:29 +0200 |
commit | ec0fe8ee448b5f76f9d40c56fcbbce26c8869ccc (patch) | |
tree | cc0c52a85215d369892dc5f132b0a868a105d1d6 /src/python/botan2.py | |
parent | 430e6c7c1236dfed90821e75b3909264b55bb00e (diff) |
Improve Python allowed_usage and add tests
Add tests for Python verify function
Diffstat (limited to 'src/python/botan2.py')
-rwxr-xr-x | src/python/botan2.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/python/botan2.py b/src/python/botan2.py index 3f7e54ae5..f7617b8c4 100755 --- a/src/python/botan2.py +++ b/src/python/botan2.py @@ -1352,8 +1352,24 @@ class X509Cert(object): # pylint: disable=invalid-name def not_after(self): return _call_fn_returning_sz(lambda l: _DLL.botan_x509_cert_not_after(self.__obj, l)) - def allowed_usage(self, usage): - rc = _DLL.botan_x509_cert_allowed_usage(self.__obj, usage) + def allowed_usage(self, usage_list): + usage_values = {"NO_CONSTRAINTS": 0, + "DIGITAL_SIGNATURE": 32768, + "NON_REPUDIATION": 16384, + "KEY_ENCIPHERMENT": 8192, + "DATA_ENCIPHERMENT": 4096, + "KEY_AGREEMENT": 2048, + "KEY_CERT_SIGN": 1024, + "CRL_SIGN": 512, + "ENCIPHER_ONLY": 256, + "DECIPHER_ONLY": 128} + usage = 0 + for u in usage_list: + if u not in usage_values: + return False + usage += usage_values[u] + + rc = _DLL.botan_x509_cert_allowed_usage(self.__obj, c_uint(usage)) return rc == 0 def get_obj(self): @@ -1362,7 +1378,7 @@ class X509Cert(object): # pylint: disable=invalid-name def verify(self, intermediates, trusted, - trusted_path, + trusted_path="", required_strength=0, hostname="", reference_time=0): |