summaryrefslogtreecommitdiff
path: root/rng.cpp
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2003-04-15 00:38:48 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2003-04-15 00:38:48 +0000
commit78cbd84a0068db09b6d08ff14a316800ad9be89a (patch)
tree2be608b49b99003d7d6f49ac33abd7bbe763d7d9 /rng.cpp
parent0a0244dacface689335de6e0edf978b29ddb66e1 (diff)
downloadcryptopp-78cbd84a0068db09b6d08ff14a316800ad9be89a.tar.gz
fix bug in Grouper
add RIPEMD-???, Whirlpool, Shacal2, Camellia, Two-Track MAC (Kevin Springle) change ChannelSwitch to allow non-blocking input (denis bider) change Redirector to allow more options (denis bider) fix MaurerRandomnessTest optimize MD2 (Kevin Springle) git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@55 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'rng.cpp')
-rw-r--r--rng.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/rng.cpp b/rng.cpp
index 0119d30..dfcd262 100644
--- a/rng.cpp
+++ b/rng.cpp
@@ -116,22 +116,24 @@ MaurerRandomnessTest::MaurerRandomnessTest()
tab[i] = 0;
}
-inline void MaurerRandomnessTest::Put(byte inByte)
-{
- if (n >= Q)
- sum += log(double(n - tab[inByte]));
- tab[inByte] = n;
- n++;
-}
-
-void MaurerRandomnessTest::Put(const byte *inString, unsigned int length)
+unsigned int MaurerRandomnessTest::Put2(const byte *inString, unsigned int length, int messageEnd, bool blocking)
{
while (length--)
- Put(*inString++);
+ {
+ byte inByte = *inString++;
+ if (n >= Q)
+ sum += log(double(n - tab[inByte]));
+ tab[inByte] = n;
+ n++;
+ }
+ return 0;
}
double MaurerRandomnessTest::GetTestValue() const
{
+ if (BytesNeeded() > 0)
+ throw Exception(Exception::OTHER_ERROR, "MaurerRandomnessTest: " + IntToString(BytesNeeded()) + " more bytes of input needed");
+
double fTu = (sum/(n-Q))/log(2.0); // this is the test value defined by Maurer
double value = fTu * 0.1392; // arbitrarily normalize it to