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.4.3.tar.gz (16.7 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.4.3-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ovtp-1.0.4.3.tar.gz
  • Upload date:
  • Size: 16.7 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.4.3.tar.gz
Algorithm Hash digest
SHA256 1ba592ca4f1c5a1e507dbcb08e828664bb029d47f60ccaf4c90fde4c24057672
MD5 99233454b9c35da867af86865f136aae
BLAKE2b-256 773903fd356a532d134988fce341a8c37730cc11615bc00d43ff6dd5c6471f79

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ovtp-1.0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 17.3 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.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f7166dea56b363bd519ce9b0c797cd7c2fb08ca4170f59d5054c1e2ebeeec691
MD5 87bc620d2f12151806d33f27c8864c3c
BLAKE2b-256 803a86dc2b5261ef45326969d7a6594135860028b901cb65f91825184541695e

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