コード例 #1
0
PublicBlumBlumShub::PublicBlumBlumShub(const Integer &n, const Integer &seed)
	: modn(n),
	  maxBits(BitPrecision(n.BitCount())-1)
{
	current = modn.Square(modn.Square(seed));
	bitsLeft = maxBits;
}
コード例 #2
0
ファイル: gf2n.cpp プロジェクト: prakhs123/cryptopp
unsigned int PolynomialMod2::BitCount() const
{
	unsigned wordCount = WordCount();
	if (wordCount)
		return (wordCount-1)*WORD_BITS + BitPrecision(reg[wordCount-1]);
	else
		return 0;
}
コード例 #3
0
ファイル: bigint.cpp プロジェクト: cdaffara/symbiandump-os2
/** 
* Get the number of bits required to represent this RInteger.
* 
* @return	The size of the integer in bits.
* 
*/
EXPORT_C TUint TInteger::BitCount() const
	{
	TUint wordCount = WordCount();
	if(wordCount)
		{
		return (wordCount-1)*WORD_BITS + BitPrecision(Ptr()[wordCount-1]);
		}
	else 
		{
		return 0;
		}
	}
コード例 #4
0
ファイル: cryptlib.cpp プロジェクト: 13971643458/qtum
word32 RandomNumberGenerator::GenerateWord32(word32 min, word32 max)
{
	const word32 range = max-min;
	const unsigned int maxBits = BitPrecision(range);

	word32 value;

	do
	{
		GenerateBlock((byte *)&value, sizeof(value));
		value = Crop(value, maxBits);
	} while (value > range);

	return value+min;
}
コード例 #5
0
ファイル: cryptlib.cpp プロジェクト: LjApps/eMule-VeryCD
word32 RandomNumberGenerator::GenerateWord32(word32 min, word32 max)
{
	word32 range = max-min;
	const int maxBytes = BytePrecision(range);
	const int maxBits = BitPrecision(range);

	word32 value;

	do
	{
		value = 0;
		for (int i=0; i<maxBytes; i++)
			value = (value << 8) | GenerateByte();

		value = Crop(value, maxBits);
	} while (value > range);

	return value+min;
}