Skip to main content

Over Transfer Protocol

Project description

OVTP

Description

This module is designed to communicate between servers, transfer messages and files.

The protocol has end-to-end data encryption and client authorization on the server using a key. Passwords are not used. Initially, you need to upload the client key to the server and add it to authorized_keys (can be used --add-keys argument when starting the server).

During transmission, a random key is generated, encrypted using AES encryption, the key is encrypted using the server's public RSA key, and signed with the client's private key. Then, data is transferred, the AES key is decrypted using the server's private key, the data is decrypted using this key, and then the signature is verified using the client's public key. Same thing in reverse.

Public keys are transferred between the client and the server automatically without encryption.

Requirements

  • Python3.7 or higher

Usage

Client

An example usage is given in the main.py files in the client and server folders. You can use this module in your script/module that will import ovtp.server. You will need to write your own callback function, which, for example, in server/main.py simply displays the received data on the screen. In your own function, you can do what you need, for example, call some other module and then you need to return 2 values (status and response) that can be obtained from the module you call (for example, that the request is successful and some data).

import asyncio
from ovtp.server import OvtpServer

def callback(status, response):
    print(f'Status: {status}, Response: {response}')
oes = OvtpServer(callback)
asyncio.run(oes.run_server())

Server

On the client side, you need to import ovtp.client, create an OvtpClient instance, and use asyncio.run to call the send_message(your_message) method. You can also send data directly, as well as files.

import asyncio
from ovtp.client import OvtpClient

oec = OvtpClient('127.0.0.1')
asyncio.run(oec.send_message('my_cool_message'))

Описание

Данный модуль создан для связи между серверами, передачи сообщений и файлов.

Протокол обладает сквозным шифрованием данных, а так же авторизацией клиента на сервере с помощью ключа. Пароли не используются. Изначально нужно загрузить ключ клиента на сервер и добавить его в authorized_keys (для этого используется аргумент --add-keys при запуске сервера).

При передаче генерируется случайный ключ, шифруется с использованием AES шифрования, ключ шифруется с помощью открытого RSA ключа сервера и подписывается закрытым ключом клиента. Затем данные передаются, AES ключ расшифровывается с помощью закрытого ключа сервера, расшифровываются данные с помощью этого ключа и затем проверяется подпись с помощью открытого ключа клиента. В обратную сторону то же самое

Открытые ключи передаются между клиентом и сервером в автоматическом режиме в открытом виде.

Требования

  • Python3.7 или выше

Использование

Сервер

Использование в качестве примера приведено в файлах main.py в папках client и server. Вы можете использовать данный модуль в своем скрипте/модуле, который будет импортировать ovtp.server. Необходимо будет написать свою callback функцию, которая для примера в server/main.py просто выводит полученные данные на экран. В своей же функции вы можете делать то, что вам необходимо, например вызывать какой-то другой модуль и затем необходимо вернуть 2 значения (status и response), которые могут быть получены из вызываемого вами модуля (например, что запрос успешен и какие-то данные).

import asyncio
from ovtp.server import OvtpServer

def callback(status, response):
    print(f'Status: {status}, Response: {response}')
oes = OvtpServer(callback)
asyncio.run(oes.run_server())

Клиент

Со стороны клиента необходимо импортировать ovtp.client, создать экземпляр OvtpClient и с помощью asyncio.run вызвать метод send_message(ваше_сообщение). Так же можно отправлять данные напрямую, а так же файлы.

import asyncio
from ovtp.client import OvtpClient

oec = OvtpClient('127.0.0.1')
asyncio.run(oec.send_message('my_cool_message'))

MIT License

Copyright (c) 2022 Dmitry Yakovlev

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ovtp-1.0.3.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ovtp-1.0.3-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file ovtp-1.0.3.tar.gz.

File metadata

  • Download URL: ovtp-1.0.3.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for ovtp-1.0.3.tar.gz
Algorithm Hash digest
SHA256 931580718c73cfb4e0bcc1557fd782038922f0b007bc9214d859f8ea199a5d18
MD5 b7988c8b48b3e7dd555042cfaf546219
BLAKE2b-256 581115355d7c5aa0976fbf63042eb8990327da064f3d1c88c8364a4323659f30

See more details on using hashes here.

File details

Details for the file ovtp-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: ovtp-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for ovtp-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 47e61803477b156a582a210b88048f446ea4600d2921279521a16b87689fde68
MD5 9abbf4fd5ae8fd9d0e67b880cf14760a
BLAKE2b-256 6d3cf947ddd8c26531426fc405ed2df95dde7d855eaa5c391191bd2c44cb56f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page