diff options
| author | weidai <weidai11@users.noreply.github.com> | 2003-04-15 00:38:48 +0000 |
|---|---|---|
| committer | weidai <weidai11@users.noreply.github.com> | 2003-04-15 00:38:48 +0000 |
| commit | d52b49c51f5c87180cb561b666dd6085556f6c3b (patch) | |
| tree | 2be608b49b99003d7d6f49ac33abd7bbe763d7d9 /rng.cpp | |
| parent | b4f6ef8e16db0be6ebc3e8aa01bf51ee52082aeb (diff) | |
| download | cryptopp-git-d52b49c51f5c87180cb561b666dd6085556f6c3b.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)
Diffstat (limited to 'rng.cpp')
| -rw-r--r-- | rng.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -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 |
