# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['sslpsk3', 'sslpsk3.test']

package_data = \
{'': ['*']}

setup_kwargs = {
    'name': 'sslpsk3',
    'version': '1.1.1',
    'description': 'Adds TLS-PSK support to the Python ssl package',
    'long_description': '# sslpsk3\n\n[![PyPI version](https://badge.fury.io/py/sslpsk3.svg)](https://badge.fury.io/py/sslpsk3)\n\nThis module adds TLS-PSK support to the Python 2.7 and 3.x `ssl`\npackage. Simply use\n\n    sslpsk3.wrap_socket(sock, psk=b\'...\', ...)\n\ninstead of\n\n    ssl.wrap_socket(sock, ...)\n\n## Backstory\n\nThere were two published versions on PyPI, both without Python 3.11 support.\n\nAdditionally, for whatever reason, the Windows build of `sslpsk2` for Python 3.10 has been linked against OpenSSL 3,\nwhile Python 3.10 on Windows uses OpenSSL 1.1.1, which causes run-time crashes (Python started using OpenSSL 3 in 3.11.5).\n\nThis fork aims to fix the incompatibility between OpenSSL versions.\n\nAvailability of binary wheels for Windows:\n\n&nbsp;      | `sslpsk` | `sslpsk2` | `sslpsk3`\n------------|----------|-----------|----------\nPython 2.7  | 1.0.0    | -         | -\nPython 3.3  | 1.0.0    | -         | -\nPython 3.4  | 1.0.0    | -         | -\nPython 3.5  | 1.0.0    | -         | -\nPython 3.6  | 1.0.0    | -         | -\nPython 3.7  | -        | 1.0.1     | -\nPython 3.8  | -        | 1.0.1     | 1.1.0+\nPython 3.9  | -        | 1.0.1     | 1.1.0+\nPython 3.10 | -        | 1.0.2     | 1.1.0+\nPython 3.11 | -        | -         | 1.1.0+\nPython 3.12 | -        | -         | 1.1.1+\n\n## Installation\n\n```pip install sslpsk3```\n\n`pip` builds from source for Linux and Mac OSX, so a C compiler, the Python\ndevelopment headers, and the openSSL development headers are required.  For\nMicrosoft Windows, pre-built binaries are available so there are no such\nprerequisites.\n\n## Usage\n\n`sslpsk3.wrap_socket(...)` is a drop-in replacement for `ssl.wrap_socket(...)` that\nsupports two additional arguments, `psk` and `hint`.\n\n`psk` sets the preshared key and, optionally, the identity for a client\nconnection. `hint` sets the identity hint for a server connection and is\noptional.\n\nFor client connections, `psk` can be one of four things:\n\n1. Just the preshared key.\n\n```python\nsslpsk3.wrap_socket(sock, psk=b\'mypsk\')\n```\n\n2. A tuple of the preshared key and client identity.\n\n```python\nsslpsk3.wrap_socket(sock, psk=(b\'mypsk\', b\'myidentity\'))\n```\n\n3. A function mapping the server identity hint to the preshared key.\n\n```python\nPSK_FOR = {b\'server1\' : b\'abcdef\',\n           b\'server2\' : b\'123456\'}\n\nsslpsk3.wrap_socket(sock, psk=lambda hint: PSK_FOR[hint])\n```\n\n4. A function mapping the server identity hint to a tuple of the preshared key\nand client identity.\n\n```python\nPSK_FOR = {b\'server1\' : b\'abcdef\',\n           b\'server2\' : b\'123456\'}\n\nID_FOR  = {b\'server1\' : b\'clientA\',\n           b\'server2\' : b\'clientB\'}\n\nsslpsk3.wrap_socket(sock, psk=lambda hint: (PSK_FOR[hint], ID_FOR[hint]))\n```\n\nFor server connections, `psk` can be one of two things:\n\n1. Just the preshared key.\n\n```python\nsslpsk3.wrap_socket(sock, server_side=True, psk=b\'mypsk\')\n```\n\n2. A function mapping the client identity to the preshared key.\n\n```python\nPSK_FOR = {b\'clientA\' : b\'abcdef\',\n           b\'clientB\' : b\'123456\'}\n\nsslpsk3.wrap_socket(sock, server_side=True, psk=lambda identity: PSK_FOR[identity])\n```\n\nAdditionally for server connections, the optional server identity hint is\nspecified using the  `hint` argument.\n\n```python\nsslpsk3.wrap_socket(sock, server_side=True, hint=b\'myidentity\', psk=b\'mypsk\')\n```\n\nIf `hint` is not specified, `None`, or the empty string, the identity hint\nwill not be sent to the client.\n\n### Example Server\n\n```python\nfrom __future__ import print_function\nimport socket\nimport ssl\nimport sslpsk3\n\nPSKS = {\'client1\' : \'abcdef\',\n        \'client2\' : \'123456\'}\n\ndef server(host, port):\n    tcp_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n    tcp_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n    tcp_sock.bind((host, port))\n    tcp_sock.listen(1)\n\n    sock, _ = tcp_sock.accept()\n    ssl_sock = sslpsk3.wrap_socket(sock,\n                                  server_side = True,\n                                  ssl_version=ssl.PROTOCOL_TLSv1,\n                                  ciphers=\'ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH\',\n                                  psk=lambda identity: PSKS[identity],\n                                  hint=b\'server1\')\n\n    msg = ssl_sock.recv(4).decode()\n    print(\'Server received: %s\'%(msg))\n    msg = "pong"\n    ssl_sock.sendall(msg.encode())\n\n    ssl_sock.shutdown(socket.SHUT_RDWR)\n    ssl_sock.close()\n\ndef main():\n    host = \'127.0.0.1\'\n    port = 6000\n    server(host, port)\n\nif __name__ == \'__main__\':\n    main()\n```\n\n### Example Client\n\n```python\nfrom __future__ import print_function\nimport socket\nimport ssl\nimport sslpsk3\n\nPSKS = {b\'server1\' : b\'abcdef\',\n        b\'server2\' : b\'uvwxyz\'}\n\ndef client(host, port, psk):\n    tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n    tcp_socket.connect((host, port))\n\n    ssl_sock = sslpsk3.wrap_socket(tcp_socket,\n                                  ssl_version=ssl.PROTOCOL_TLSv1,\n                                  ciphers=\'ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH\',\n                                  psk=lambda hint: (PSKS[hint], b\'client1\'))\n\n    msg = "ping"\n    ssl_sock.sendall(msg.encode())\n    msg = ssl_sock.recv(4).decode()\n    print(\'Client received: %s\'%(msg))\n\n    ssl_sock.shutdown(socket.SHUT_RDWR)\n    ssl_sock.close()\n\ndef main():\n    host = \'127.0.0.1\'\n    port = 6000\n    client(host, port, PSKS)\n\nif __name__ == \'__main__\':\n    main()\n```\n\n## Changelog\n\n+ 0.1.0 (July 31, 2017)\n  + initial release\n+ 1.0.0 (August 2, 2017)\n  + include tests in pip distribution\n  + add support for Windows\n+ 1.0.1 (August 11, 2020)\n  + OpenSSL 1.1.1\n  + Fix with _sslobj\n  + Build from source in Windows with error description, when OpenSSL files are not present\n+ 1.1.0 (September 13, 2023)\n  + Migrate to GitHub actions\n  + Reformat code\n  + Support OpenSSL v1 and v3\n\n## Acknowledgments\n\nFork of [drbild/sslpsk](https://github.com/drbild/sslpsk).\n\nThe main approach was borrowed from\n[webgravel/common-ssl](https://github.com/webgravel/common-ssl).\n\nVersion from [autinerd/sslpsk2](https://github.com/autinerd/sslpsk2) updated to work with OpenSSL v1 and v3.\n\n## Contributing\n\nPlease submit bugs, questions, suggestions, or (ideally) contributions as\nissues and pull requests on GitHub.\n\n## License\nCopyright 2017 David R. Bild, 2020 Sidney Kuyateh, 2023 Kuba Szczodrzyński\n\nLicensed under the Apache License, Version 2.0 (the "License"); you may not\nuse this work except in compliance with the License. You may obtain a copy of\nthe License from the LICENSE.txt file or at\n\n[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an "AS IS" BASIS, WITHOUT\nWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\nLicense for the specific language governing permissions and limitations under\nthe License.\n',
    'author': 'Kuba Szczodrzyński',
    'author_email': 'kuba@szczodrzynski.pl',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'None',
    'packages': packages,
    'package_data': package_data,
    'python_requires': '>=3.8,<4.0',
}
from build import *
build(setup_kwargs)

setup(**setup_kwargs)
