Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
cryptoutil.cpp File Reference
#include "cryptoutil.h"
#include <QStringList>
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <qlogging.h>
Include dependency graph for cryptoutil.cpp:

Namespaces

namespace  CryptoUtil

Functions

QByteArray CryptoUtil::randomBytes (int count)
quint64 CryptoUtil::randomUInt64 ()
QString CryptoUtil::encryptSecret (const QByteArray &plaintext, const QByteArray &key, const QByteArray &aad={})
 Seal a secret with AES-256-GCM as "enc1:<b64 nonce>:<b64 ciphertext+tag>". Returns an empty string unless key is a valid 32-byte key and the cipher completes. aad is authenticated but not stored (bind the ciphertext to its context, e.g. the user name it belongs to).
QByteArray CryptoUtil::decryptSecret (const QString &sealed, const QByteArray &key, const QByteArray &aad={})
 Open a string produced by encryptSecret(). Returns an empty array on any failure: unknown format, malformed base64, wrong key, wrong aad, or tampering.

Variables

static constexpr int SECRET_KEY_LENGTH = 32
static constexpr int SECRET_NONCE_LENGTH = 12
static constexpr int SECRET_TAG_LENGTH = 16
static const char * SECRET_FORMAT_PREFIX = "enc1"

Variable Documentation

◆ SECRET_FORMAT_PREFIX

const char* SECRET_FORMAT_PREFIX = "enc1"
static

◆ SECRET_KEY_LENGTH

int SECRET_KEY_LENGTH = 32
staticconstexpr

◆ SECRET_NONCE_LENGTH

int SECRET_NONCE_LENGTH = 12
staticconstexpr

◆ SECRET_TAG_LENGTH

int SECRET_TAG_LENGTH = 16
staticconstexpr