Vidalia  0.3.1
Macros | Functions
crypto.cpp File Reference
#include "crypto.h"
#include <QFile>
#include <QStringList>
#include <QCryptographicHash>
#include <QtDebug>

Go to the source code of this file.

Macros

#define EXPBIAS   6
 

Functions

QByteArray crypto_rand_bytes (int len)
 
quint32 crypto_rand_quint32 (quint32 max)
 
QString crypto_rand_string (int len)
 
QByteArray crypto_secret_to_key (const QString &secret, const QByteArray &salt, quint8 c)
 

Macro Definition Documentation

§ EXPBIAS

#define EXPBIAS   6

Referenced by crypto_secret_to_key().

Function Documentation

§ crypto_rand_bytes()

QByteArray crypto_rand_bytes ( int  len)

Returns up to len bytes of pseudorandom data on success, or an empty QByteArray on failure. The caller should verify that the returned QByteArray contains the requested number of bytes. This function is based on crypto_seed_rng() from Tor's crypto.c. See LICENSE for details on Tor's license.

Definition at line 71 of file crypto.cpp.

References quint32.

Referenced by crypto_rand_quint32(), and TorSettings::hashPassword().

§ crypto_rand_quint32()

quint32 crypto_rand_quint32 ( quint32  max)

Returns a pseudorandom integer, chosen uniformly from the the values in the range [0, max). This function is based on crypto_rand_int() from Tor's crypto.c. See LICENSE for details on Tor's license.

Definition at line 128 of file crypto.cpp.

References crypto_rand_bytes(), and quint32.

Referenced by crypto_rand_string().

§ crypto_rand_string()

QString crypto_rand_string ( int  len)

Generates a pseudorandom string of length len containing printable ASCII characters from the range '!' (0x21) to '~' (0x7e).

Definition at line 150 of file crypto.cpp.

References crypto_rand_quint32(), and i().

Referenced by TorSettings::randomPassword().

§ crypto_secret_to_key()

QByteArray crypto_secret_to_key ( const QString &  secret,
const QByteArray &  salt,
quint8  c 
)

Generates a salted hash of secret using the random salt according to the iterated and salted S2K algorithm in RFC 2440. c is the one-octet coded count value that specifies how much data to hash. salt must contain at least 8 bytes, otherwise this method will return a default-constructed QByteArray.

Definition at line 166 of file crypto.cpp.

References EXPBIAS, and quint32.

Referenced by TorSettings::hashPassword().