refactoring PICrypt, add PIStreamPackerConfig, delete piclientserver_config

This commit is contained in:
2024-10-18 18:59:20 +03:00
parent 28f3471036
commit 92a0a9356c
16 changed files with 220 additions and 387 deletions

View File

@@ -5,22 +5,22 @@
* \~russian Шифрование с помощью libsodium
*/
/*
PIP - Platform Independent Primitives
Cryptographic class using lib Sodium
Andrey Bychkov work.a.b@yandex.ru
PIP - Platform Independent Primitives
Cryptographic class using lib Sodium
Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PICRYPT_H
@@ -40,6 +40,8 @@ public:
//! \~russian Конструктор, генерирующий случайный ключ
PICrypt();
~PICrypt();
//! \~\brief
//! \~english Set key to "key", key size must be a \a sizeKey()
//! \~russian Установить ключ "key", размер ключа должен быть равен \a sizeKey()
@@ -48,7 +50,7 @@ public:
//! \~\brief
//! \~english Generate and set key from keyphrase "secret"
//! \~russian Генерировать и установить ключ из ключевой фразы "secret"
PIByteArray setKey(const PIString & secret);
bool setKey(const PIString & secret);
//! \~\brief
//! \~english Returns current key
@@ -123,12 +125,12 @@ public:
//! \~\brief
//! \~english Function randomly generates a secret key and a corresponding public key for digital signature
//! \~russian Функция случайным образом генерирует секретный ключ и соответствующий ему открытый ключ для цифровой подписи
static void generateSignKeys(PIByteArray & public_key, PIByteArray & secret_key);
static bool generateSignKeys(PIByteArray & public_key, PIByteArray & secret_key);
//! \~\brief
//! \~english Function generates a secret key from input data and a corresponding public key for digital signature
//! \~russian Функция генерирует секретный ключ из входных данных и соответствующий ему открытый ключ для цифровой подписи
static void generateSignKeys(PIByteArray & public_key, PIByteArray & secret_key, const PIByteArray & seed);
static bool generateSignKeys(PIByteArray & public_key, PIByteArray & secret_key, const PIByteArray & seed);
//! \~\brief
//! \~english Function extract sign public key from sing secret key
@@ -138,24 +140,24 @@ public:
//! \~\brief
//! \~english Calculate digital signature for data
//! \~russian Вычислить цифровую подпись для данных
PIByteArray signMessage(const PIByteArray & data, PIByteArray secret_key);
PIByteArray signMessage(const PIByteArray & data, const PIByteArray & secret_key);
//! \~\brief
//! \~english Verify digital signature of signed message
//! \~russian Проверить цифровую подпись подписанного сообщения
bool verifySign(const PIByteArray & data, const PIByteArray & signature, PIByteArray public_key);
bool verifySign(const PIByteArray & data, const PIByteArray & signature, const PIByteArray & public_key);
//! \~\brief
//! \~english Function randomly generates a secret key and a corresponding public key for authenticated encryption
//! \~russian Функция случайным образом генерирует секретный ключ и соответствующий ему открытый ключ для аутентифицированного
//! шифрования
static void generateKeypair(PIByteArray & public_key, PIByteArray & secret_key);
static bool generateKeypair(PIByteArray & public_key, PIByteArray & secret_key);
//! \~\brief
//! \~english Function generates a secret key from input data and a corresponding public key for authenticated encryption
//! \~russian Функция генерирует секретный ключ из входных данных и соответствующий ему открытый ключ для аутентифицированного
//! шифрования
static void generateKeypair(PIByteArray & public_key, PIByteArray & secret_key, const PIByteArray & seed);
static bool generateKeypair(PIByteArray & public_key, PIByteArray & secret_key, const PIByteArray & seed);
//! \~\brief
//! \~english Encrypt given data "data"