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.6.2.tar.gz (17.5 kB view hashes)

Uploaded Source

Built Distribution

ovtp-1.0.6.2-py3-none-any.whl (18.7 kB view hashes)

Uploaded Python 3

Supported by

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