⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fnaentropysource.cpp

📁 手机加密通话软件
💻 CPP
字号:
/* Copyright 2001,2002,2003 NAH6 BV
 * All Rights Reserved
 *
 *  $Header: /var/lib/cvs/secphone/ui/rng/fortuna/fnaEntropySource.cpp,v 1.4 2003/11/21 16:12:58 itsme Exp $
 *
 *
 * Design of the PRNG is literally taken from 'Practical Cryptography', by Niels Ferguson, and Bruce Schneier.
 *
 * This class is subclassed for all the implemented entropy sources:
 *   - audioinput
 *   - cryptoapi
 *
 */


#include <windows.h>

#include "fnaEntropySource.h"
#include "debug.h"

EntropySource::EntropySource()
{
    m_event= CreateEvent(NULL, TRUE, FALSE, NULL);
    m_poolnr= 0;
}

EntropySource::~EntropySource()
{
    CloseHandle(m_event);
}
void EntropySource::SetParams(Accumulator::sourcenumber_t nr, Accumulator& prng)
{
    m_sourcenr= nr;
    m_accu= &prng;
}
HANDLE EntropySource::GetEvent() const
{
    return m_event;
}
void EntropySource::AddRandom(const ByteVector& data)
{
    m_accu->AddRandomEvent(m_sourcenr, NextPoolNr(), data);
}
Accumulator::poolnumber_t EntropySource::NextPoolNr()
{
    int pool= m_poolnr++;
    if (m_poolnr>=Accumulator::NROFPOOLS)
        m_poolnr= 0;

    return pool;
}

void EntropySource::SignalNewData()
{
    SetEvent(m_event);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -