95 lines
3.6 KiB
C++
95 lines
3.6 KiB
C++
/*! \file piethutilbase.h
|
||
* \ingroup IO-Utils
|
||
* \~\brief
|
||
* \~english Base class for ethernet utils
|
||
* \~russian Базовый класс для утилит ethernet
|
||
*/
|
||
/*
|
||
PIP - Platform Independent Primitives
|
||
Base class for ethernet utils
|
||
Ivan Pelipenko peri4ko@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 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/>.
|
||
*/
|
||
|
||
#ifndef PIETHUTILBASE_H
|
||
#define PIETHUTILBASE_H
|
||
|
||
#include "pibytearray.h"
|
||
#include "pip_io_utils_export.h"
|
||
|
||
|
||
//! \~english Base class for ethernet utils
|
||
//! \~russian Базовый класс для утилит ethernet
|
||
class PIP_IO_UTILS_EXPORT PIEthUtilBase {
|
||
public:
|
||
//! \~english Constructs PIEthUtilBase
|
||
//! \~russian Создает PIEthUtilBase
|
||
PIEthUtilBase();
|
||
|
||
//! \~english Destructor
|
||
//! \~russian Деструктор
|
||
~PIEthUtilBase();
|
||
|
||
//! \~english Set crypt layer enabled
|
||
//! \~russian Включить слой шифрования
|
||
void setCryptEnabled(bool on);
|
||
|
||
//! \~english Enable crypt layer
|
||
//! \~russian Включить слой шифрования
|
||
void cryptEnable();
|
||
|
||
//! \~english Disable crypt layer
|
||
//! \~russian Выключить слой шифрования
|
||
void cryptDisable();
|
||
|
||
//! \~english Returns if crypt layer enabled
|
||
//! \~russian Возвращает, включен ли слой шифрования
|
||
bool isCryptEnabled() const;
|
||
|
||
|
||
//! \~english Set crypt layer key to "k"
|
||
//! \~russian Установить ключ шифрования в "k"
|
||
void setCryptKey(const PIByteArray & k);
|
||
|
||
//! \~english Generate crypt layer key by \a PICrypt::hash and set crypt layer enabled
|
||
//! \~russian Сгенерировать ключ шифрования с помощью \a PICrypt::hash и включить шифрование
|
||
void createCryptKey(const PIString & k);
|
||
|
||
//! \~english Returns crypt layer key
|
||
//! \~russian Возвращает ключ шифрования
|
||
PIByteArray cryptKey() const;
|
||
|
||
//! \~english Returns addition size for crypted data
|
||
//! \~russian Возвращает дополнительный размер для зашифрованных данных
|
||
static size_t cryptSizeAddition();
|
||
|
||
protected:
|
||
//! \~english Returns encrypted data if layer enabled, otherwise returns unchanged "data"
|
||
//! \~russian Возвращает зашифрованные данные, если слой включен, иначе возвращает неизмененные "data"
|
||
PIByteArray cryptData(const PIByteArray & data);
|
||
|
||
//! \~english Returns decrypted data if layer enabled, otherwise returns unchanged "data". If decryption was unsuccessful returns empty
|
||
//! %PIByteArray
|
||
//! \~russian Возвращает расшифрованные данные, если слой включен, иначе возвращает неизмененные "data". Если расшифровка неуспешна,
|
||
//! возвращает пустой %PIByteArray
|
||
PIByteArray decryptData(const PIByteArray & data);
|
||
|
||
private:
|
||
PIByteArray _key;
|
||
bool _crypt;
|
||
};
|
||
|
||
#endif // PIETHUTILBASE_H
|