8#include "QXmppGlobal.h"
12struct evp_cipher_ctx_st;
14namespace QXmpp::Private::Crypto {
22class QXMPP_EXPORT SecureByteArray
25 SecureByteArray() =
default;
26 explicit SecureByteArray(
int size);
27 explicit SecureByteArray(
const QByteArray &data);
28 SecureByteArray(
const char *data,
int size);
31 SecureByteArray(
const SecureByteArray &other);
32 SecureByteArray &operator=(
const SecureByteArray &other);
33 SecureByteArray(SecureByteArray &&other)
noexcept;
34 SecureByteArray &operator=(SecureByteArray &&other)
noexcept;
36 char *data() {
return m_data.data(); }
37 const char *data()
const {
return m_data.data(); }
38 const char *constData()
const {
return m_data.constData(); }
39 int size()
const {
return m_data.size(); }
40 bool isEmpty()
const {
return m_data.isEmpty(); }
43 void resize(
int size);
45 SecureByteArray &append(
const SecureByteArray &other);
46 QByteArray toByteArray()
const {
return m_data; }
48 bool operator==(
const SecureByteArray &other)
const {
return m_data == other.m_data; }
49 bool operator!=(
const SecureByteArray &other)
const {
return m_data != other.m_data; }
57QXMPP_EXPORT QByteArray aesGcmEncrypt(
const QByteArray &data,
const QByteArray &key,
const QByteArray &iv);
58QXMPP_EXPORT QByteArray aesGcmDecrypt(
const QByteArray &data,
const QByteArray &key,
const QByteArray &iv);
59QXMPP_EXPORT QByteArray aesCbcEncrypt(
const QByteArray &data,
const QByteArray &key,
const QByteArray &iv);
60QXMPP_EXPORT QByteArray aesCbcDecrypt(
const QByteArray &data,
const QByteArray &key,
const QByteArray &iv);
61QXMPP_EXPORT QByteArray aesCtrProcess(
const QByteArray &data,
const QByteArray &key,
const QByteArray &iv);
64QXMPP_EXPORT SecureByteArray hkdfSha256(
const QByteArray &key,
const QByteArray &salt,
const QByteArray &info,
int outputLen);
67QXMPP_EXPORT QByteArray hmacSha256(
const QByteArray &key,
const QByteArray &data);
70QXMPP_EXPORT QByteArray randomBytes(
int count);
73QXMPP_EXPORT
bool constTimeEqual(
const QByteArray &a,
const QByteArray &b);
76class QXMPP_EXPORT CipherContext
79 CipherContext(Cipher cipher, Direction direction,
const QByteArray &key,
const QByteArray &iv);
82 CipherContext(
const CipherContext &) =
delete;
83 CipherContext &operator=(
const CipherContext &) =
delete;
85 QByteArray update(
const QByteArray &data);
86 QByteArray finalize();
87 bool validKeyLength(
int length)
const;
90 evp_cipher_ctx_st *m_ctx =
nullptr;
Cipher
Definition QXmppGlobal.h:172