QByteArray Cipher::randomIv(int length)
{
    if (length == 0) {//directly return empty byte array if no need to genenrate iv
        return QByteArray();
    }

    Botan::AutoSeeded_RNG rng;
    QByteArray out;
    out.resize(length);
    rng.randomize(reinterpret_cast<Botan::byte *>(out.data()), length);
    return out;
}
    void BuildResponseRecord::compile()
    {
        Botan::AutoSeeded_RNG rng;

        rng.randomize(m_data.data() + 16, 495);
        m_data[511] = (unsigned char)m_reply;

        Botan::Pipe hashPipe(new Botan::Hash_Filter("SHA-256"));
        hashPipe.start_msg();
        hashPipe.write(m_data.data() + 16, 496);
        hashPipe.end_msg();

        hashPipe.read(m_header.data(), 16);
        hashPipe.read(m_data.data(), 16);
    }
QByteArray Encryptor::createRandomString()
{
    QByteArray randomString;

    Botan::AutoSeeded_RNG rng;
    const uint RANDOM_DATA_SIZE = 256;
    Botan::byte randomData[RANDOM_DATA_SIZE];

    rng.randomize(randomData, RANDOM_DATA_SIZE);

    for (int index = 0; index < RANDOM_DATA_SIZE; ++index) {
        randomString.append(randomData[index]);
    }

    return randomString;
}
Exemple #4
0
        Message::Message()
        {
            Botan::AutoSeeded_RNG rng;

            rng.randomize((unsigned char *)&m_msgId, sizeof(m_msgId));
        }