diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-keyprotect.spec | 340 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 342 insertions, 0 deletions
@@ -0,0 +1 @@ +/keyprotect-2.2.0.tar.gz diff --git a/python-keyprotect.spec b/python-keyprotect.spec new file mode 100644 index 0000000..d1ef73e --- /dev/null +++ b/python-keyprotect.spec @@ -0,0 +1,340 @@ +%global _empty_manifest_terminate_build 0 +Name: python-keyprotect +Version: 2.2.0 +Release: 1 +Summary: A Pythonic client for IBM Key Protect +License: Apache 2.0 +URL: https://github.com/IBM/keyprotect-python-client +Source0: https://mirrors.aliyun.com/pypi/web/packages/82/56/52c517efda818cd40340c54c42bdb14a8f30d8b6a9a1bd75485a11516890/keyprotect-2.2.0.tar.gz +BuildArch: noarch + +Requires: python3-redstone + +%description +# keyprotect-python-client + +[](https://pypi.org/project/keyprotect) +[](https://pepy.tech/project/keyprotect) +[](https://opensource.org/licenses/Apache-2.0) +[](https://travis-ci.com/IBM/keyprotect-python-client) + +A Pythonic client for IBM Key Protect + +This is a thin wrapper around the KeyProtect client in the [redstone](https://github.com/IBM/redstone) Python package. For detailed documentation and API references, please see the [redstone docs](https://redstone-py.readthedocs.org) + +The client works with Python 3.5 or higher + +# Installation + +The client is available on PyPI as the `keyprotect` package and is installable via `pip`: + +```sh +pip install -U keyprotect +``` + +# Usage + +The following python is a quick example of how to use the keyprotect module. + +The example expects `IBMCLOUD_API_KEY` to be set to a valid IAM API key, +and `KP_INSTANCE_ID` to be set to the UUID identifying your KeyProtect instance. + +```python +import os + +import keyprotect +from keyprotect import bxauth + + +tm = bxauth.TokenManager(api_key=os.getenv("IBMCLOUD_API_KEY")) + +kp = keyprotect.Client( + credentials=tm, + region="us-south", + service_instance_id=os.getenv("KP_INSTANCE_ID") +) + +for key in kp.keys(): + print("%s\t%s" % (key["id"], key["name"])) + +key = kp.create(name="MyTestKey") +print("Created key '%s'" % key['id']) + +kp.delete(key_id=key.get('id')) +print("Deleted key '%s'" % key['id']) + + +# wrap and unwrap require a non-exportable key, +# these are also referred to as root keys +key = kp.create(name="MyRootKey", root=True) + +# wrap/unwrap, payload should be a bytestring if python3 +message = b'This is a really important message.' +wrapped = kp.wrap(key_id=key.get('id'), plaintext=message) +ciphertext = wrapped.get("ciphertext") + +unwrapped = kp.unwrap(key_id=key.get('id'), ciphertext=ciphertext) +assert message == unwrapped + +# wrap/unwrap with AAD +message = b'This is a really important message too.' +wrapped = kp.wrap(key_id=key.get('id'), plaintext=message, aad=['python-keyprotect']) +ciphertext = wrapped.get("ciphertext") + +unwrapped = kp.unwrap(key_id=key.get('id'), ciphertext=ciphertext, aad=['python-keyprotect']) +assert message == unwrapped +``` + +## Using custom endpoint + +The following example shows how to use custom service endpoint + +```python +kp = keyprotect.Client( + credentials=tm, + region="<region>", + service_instance_id=os.getenv("KP_INSTANCE_ID"), + # Set custom service endpoint + endpoint_url="https://private.us-south.kms.cloud.ibm.com" +) +``` + + + + +%package -n python3-keyprotect +Summary: A Pythonic client for IBM Key Protect +Provides: python-keyprotect +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-keyprotect +# keyprotect-python-client + +[](https://pypi.org/project/keyprotect) +[](https://pepy.tech/project/keyprotect) +[](https://opensource.org/licenses/Apache-2.0) +[](https://travis-ci.com/IBM/keyprotect-python-client) + +A Pythonic client for IBM Key Protect + +This is a thin wrapper around the KeyProtect client in the [redstone](https://github.com/IBM/redstone) Python package. For detailed documentation and API references, please see the [redstone docs](https://redstone-py.readthedocs.org) + +The client works with Python 3.5 or higher + +# Installation + +The client is available on PyPI as the `keyprotect` package and is installable via `pip`: + +```sh +pip install -U keyprotect +``` + +# Usage + +The following python is a quick example of how to use the keyprotect module. + +The example expects `IBMCLOUD_API_KEY` to be set to a valid IAM API key, +and `KP_INSTANCE_ID` to be set to the UUID identifying your KeyProtect instance. + +```python +import os + +import keyprotect +from keyprotect import bxauth + + +tm = bxauth.TokenManager(api_key=os.getenv("IBMCLOUD_API_KEY")) + +kp = keyprotect.Client( + credentials=tm, + region="us-south", + service_instance_id=os.getenv("KP_INSTANCE_ID") +) + +for key in kp.keys(): + print("%s\t%s" % (key["id"], key["name"])) + +key = kp.create(name="MyTestKey") +print("Created key '%s'" % key['id']) + +kp.delete(key_id=key.get('id')) +print("Deleted key '%s'" % key['id']) + + +# wrap and unwrap require a non-exportable key, +# these are also referred to as root keys +key = kp.create(name="MyRootKey", root=True) + +# wrap/unwrap, payload should be a bytestring if python3 +message = b'This is a really important message.' +wrapped = kp.wrap(key_id=key.get('id'), plaintext=message) +ciphertext = wrapped.get("ciphertext") + +unwrapped = kp.unwrap(key_id=key.get('id'), ciphertext=ciphertext) +assert message == unwrapped + +# wrap/unwrap with AAD +message = b'This is a really important message too.' +wrapped = kp.wrap(key_id=key.get('id'), plaintext=message, aad=['python-keyprotect']) +ciphertext = wrapped.get("ciphertext") + +unwrapped = kp.unwrap(key_id=key.get('id'), ciphertext=ciphertext, aad=['python-keyprotect']) +assert message == unwrapped +``` + +## Using custom endpoint + +The following example shows how to use custom service endpoint + +```python +kp = keyprotect.Client( + credentials=tm, + region="<region>", + service_instance_id=os.getenv("KP_INSTANCE_ID"), + # Set custom service endpoint + endpoint_url="https://private.us-south.kms.cloud.ibm.com" +) +``` + + + + +%package help +Summary: Development documents and examples for keyprotect +Provides: python3-keyprotect-doc +%description help +# keyprotect-python-client + +[](https://pypi.org/project/keyprotect) +[](https://pepy.tech/project/keyprotect) +[](https://opensource.org/licenses/Apache-2.0) +[](https://travis-ci.com/IBM/keyprotect-python-client) + +A Pythonic client for IBM Key Protect + +This is a thin wrapper around the KeyProtect client in the [redstone](https://github.com/IBM/redstone) Python package. For detailed documentation and API references, please see the [redstone docs](https://redstone-py.readthedocs.org) + +The client works with Python 3.5 or higher + +# Installation + +The client is available on PyPI as the `keyprotect` package and is installable via `pip`: + +```sh +pip install -U keyprotect +``` + +# Usage + +The following python is a quick example of how to use the keyprotect module. + +The example expects `IBMCLOUD_API_KEY` to be set to a valid IAM API key, +and `KP_INSTANCE_ID` to be set to the UUID identifying your KeyProtect instance. + +```python +import os + +import keyprotect +from keyprotect import bxauth + + +tm = bxauth.TokenManager(api_key=os.getenv("IBMCLOUD_API_KEY")) + +kp = keyprotect.Client( + credentials=tm, + region="us-south", + service_instance_id=os.getenv("KP_INSTANCE_ID") +) + +for key in kp.keys(): + print("%s\t%s" % (key["id"], key["name"])) + +key = kp.create(name="MyTestKey") +print("Created key '%s'" % key['id']) + +kp.delete(key_id=key.get('id')) +print("Deleted key '%s'" % key['id']) + + +# wrap and unwrap require a non-exportable key, +# these are also referred to as root keys +key = kp.create(name="MyRootKey", root=True) + +# wrap/unwrap, payload should be a bytestring if python3 +message = b'This is a really important message.' +wrapped = kp.wrap(key_id=key.get('id'), plaintext=message) +ciphertext = wrapped.get("ciphertext") + +unwrapped = kp.unwrap(key_id=key.get('id'), ciphertext=ciphertext) +assert message == unwrapped + +# wrap/unwrap with AAD +message = b'This is a really important message too.' +wrapped = kp.wrap(key_id=key.get('id'), plaintext=message, aad=['python-keyprotect']) +ciphertext = wrapped.get("ciphertext") + +unwrapped = kp.unwrap(key_id=key.get('id'), ciphertext=ciphertext, aad=['python-keyprotect']) +assert message == unwrapped +``` + +## Using custom endpoint + +The following example shows how to use custom service endpoint + +```python +kp = keyprotect.Client( + credentials=tm, + region="<region>", + service_instance_id=os.getenv("KP_INSTANCE_ID"), + # Set custom service endpoint + endpoint_url="https://private.us-south.kms.cloud.ibm.com" +) +``` + + + + +%prep +%autosetup -n keyprotect-2.2.0 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-keyprotect -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Jun 20 2023 Python_Bot <Python_Bot@openeuler.org> - 2.2.0-1 +- Package Spec generated @@ -0,0 +1 @@ +bba35f2fe973428462e2029f8ff789b0 keyprotect-2.2.0.tar.gz |