7#include "../expected.h"
9#include "../quotient_export.h"
11#include <QtCore/QByteArray>
12#include <QtCore/QString>
41using SslErrorCode =
unsigned long;
43template <size_t Size = DefaultPbkdf2KeyLength>
44using key_material_t = std::array<byte_t, Size>;
45using key_view_t = byte_view_t<DefaultPbkdf2KeyLength>;
55using SslExpected = Expected<T, SslErrorCode>;
62template <size_t N,
typename T = uint8_t> consteval std::array<T, N>
zeroes() {
return {}; }
65 QUOTIENT_API SslErrorCode pbkdf2HmacSha512(
const QByteArray& passphrase,
const QByteArray& salt,
66 int iterations, byte_span_t<> output);
70template <size_t Size = DefaultPbkdf2KeyLength>
71QUOTIENT_API inline SslExpected<key_material_t<Size>> pbkdf2HmacSha512(
const QByteArray& passphrase,
72 const QByteArray& salt,
75 key_material_t<Size> result;
76 if (
auto code = _impl::pbkdf2HmacSha512(passphrase, salt, iterations, result); code != 0)
84QUOTIENT_API SslExpected<HkdfKeys> hkdfSha256(key_view_t key, byte_view_t<32> salt,
89 byte_view_t<HmacKeySize> hmacKey,
90 const QByteArray& data);
95 QByteArray ciphertext,
const QByteArray& privateKey,
96 const QByteArray& ephemeral,
const QByteArray& mac);
100QUOTIENT_API QOlmExpected<Curve25519Encrypted> curve25519AesSha2Encrypt(
101 const QByteArray& plaintext,
const QByteArray& publicKey);
107 const QByteArray& plaintext, byte_view_t<Aes256KeySize> key,
108 byte_view_t<AesBlockSize> iv);
114 const QByteArray& ciphertext, byte_view_t<Aes256KeySize> key,
115 byte_view_t<AesBlockSize> iv);
117QUOTIENT_API std::vector<byte_t> base58Decode(
const QByteArray& encoded);
119QUOTIENT_API QByteArray sign(
const QByteArray &key,
const QByteArray &data);
consteval std::array< T, N > zeroes()
constexpr auto DefaultPbkdf2KeyLength
constexpr auto AesBlockSize
constexpr auto HmacKeySize
QByteArray zeroedByteArray(QByteArray::size_type n=32)
constexpr auto Aes256KeySize