1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-23 02:32:10 +02:00
falkonOfficial/src/lib/tools/aesinterface.h
Jose Rios efc4725e91 Fixed compilation for Openssl 1.1.0
Most of libcrypto and libssl internal structures were made
opaque in this version not allowing to instatiate them in
the stack.

More info:
    * https://www.openssl.org/news/openssl-1.1.0-notes.html
    * https://github.com/openssl/openssl/issues/962#issuecomment-208792020
2017-05-01 11:03:40 +02:00

60 lines
1.8 KiB
C++

/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2013-2014 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
* Copyright (C) 2013-2014 David Rosca <nowrep@gmail.com>
*
* This is based on a work by Saju Pillai <saju.pillai@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#ifndef AESINTERFACE_H
#define AESINTERFACE_H
#include "qzcommon.h"
#include <openssl/evp.h>
#include <QObject>
#include <QHash>
#include <QList>
class QUPZILLA_EXPORT AesInterface : public QObject
{
Q_OBJECT
public:
static const int VERSION;
explicit AesInterface(QObject* parent = 0);
~AesInterface();
bool isOk();
QByteArray encrypt(const QByteArray &plainData, const QByteArray &password);
QByteArray decrypt(const QByteArray &cipherData, const QByteArray &password);
static QByteArray passwordToHash(const QString &masterPassword);
static QByteArray createRandomData(int length);
private:
bool init(int evpMode, const QByteArray &password, const QByteArray &iVector = QByteArray());
EVP_CIPHER_CTX* m_encodeCTX;
EVP_CIPHER_CTX* m_decodeCTX;
bool m_ok;
QByteArray m_iVector;
};
#endif //AESINTERFACE_H