Friday, 24 November 2017
arrow DiceChecker 6.0.0.1 arrow randomTestSuite.cpp (3)
randomTestSuite.cpp (3) (Random number test suite C++ source code third part file) Print E-mail
Get C++ DiceLock cipher architecture source code packages of DiceLock for Microsoft Visual Studio 2013 and DiceLock-x for Linux with Test Driver Programs and Response Test Vector files to verify that both them work as expected.
DiceLock for Windows and Linux
DiceLock Security governing software licenses are Free/Libre Source Code License and Educational and Research License
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
 
    // GETTING SUITE RESULTS
 
    // Gets the RandomTestSuite random state of the last executed BaseCryptoRandomStream
    bool RandomTestSuite::IsRandom(void) {
 
      return this->random;
    }
 
    // Gets the number of Random Tests that contains the suite
    unsigned short int RandomTestSuite::GetInstantiatedTests(void) {
 
      return this->instantiatedTests;
    }
 
    // Gets the minimum random stream length in bits corresponding
    // to random number test with higher random stream length
    unsigned long int RandomTestSuite::GetMinimumLength(void) {
      unsigned long int minimumMax;
      unsigned short int i;
 
      minimumMax = 0;
      for ( i = this->GetFirstTest(); i < this->GetMaximumNumberOfTests(); i++ ) {
        if ( this->Exist((RandomTests)i) ) {
          if ( this->GetRandomTest((RandomTests)i)->GetMinimumLength() > minimumMax ) {
            minimumMax = this->GetRandomTest((RandomTests)i)->GetMinimumLength();
          }
        }
      }
      return minimumMax;
    }
 
    // Gets the corresponding random number test 
    // with higher minimum random stream length in bits 
    RandomTests RandomTestSuite::GetMinimumLengthRandomTest(void) {
      unsigned long int minimumMax;
      unsigned short int i;
      RandomTests randomTest;
 
      minimumMax = 0;
      randomTest = NotDefined;
      for ( i = this->GetFirstTest(); i < this->GetMaximumNumberOfTests(); i++ ) {
        if ( this->Exist((RandomTests)i) ) {
          if ( this->GetRandomTest((RandomTests)i)->GetMinimumLength() > minimumMax ) {
            minimumMax = this->GetRandomTest((RandomTests)i)->GetMinimumLength();
            randomTest = (RandomTests)i;
          }
        }
      }
      return randomTest;
    }
 
    // Gets the failed random test in the RandomTestSuite
    RandomTests RandomTestSuite::GetNonRandomTest(void) {
 
      return this->nonRandomTest;
    }
 
    // Gets the RandomTestError error of the last executed BaseCryptoRandomStream
    RandomTestErrors RandomTestSuite::GetError(void) {
 
      return this->error;
    }
 
    // Gets the RandomTest that produced the error of the last executed BaseCryptoRandomStream
    RandomTests RandomTestSuite::GetErrorTest(void) {
 
      return this->errorTest;
    }
 
    // Indicates if a random test object exists in the suite
    bool RandomTestSuite::Exist(RandomTests test) {
 
      return (this->suite[test] != NULL);
    }
 
    // Gets the first random test in the RandomTestSuite
    RandomTests RandomTestSuite::GetFirstTest(void) {
 
      return this->firstTest;
    }
 
    // Gets the number of random tests that can be used in the RandomTestSuite
    RandomTests RandomTestSuite::GetMaximumNumberOfTests(void) {
 
      return NumberOfTests;
    }
 
    /// STRICT RANDOMNESS METHODS
 
    /// Sets strict randomness checking, if all random tests instantiated in the suite will be verified
    /// true: all random tests instantiated in the suite will be verified
    /// false: just random tests that can be checked (stream length larger than random test minimum length) will be verified 
    void RandomTestSuite::SetStrictRandomnessCheck(bool strictness) {
 
      this->strictRandomnessCheck = strictness;
    }
 
    /// Gets strict randomness checking, if all random tests instantiated in the suite will be verified
    bool RandomTestSuite::SetStrictRandomnessCheck(void) {
 
      return this->strictRandomnessCheck;
    }
 
    /// USED TEST METHODS WHEN STRICT RANDOMNESS CHECKING IS DISABLED
 
    /// Gets number of random test that has been used in last random test checking
    unsigned short int RandomTestSuite::GetUsedTestsNumber(void) {
      unsigned short int i, number;
 
      number = 0;
      for (i = this->GetFirstTest(); i < this->GetMaximumNumberOfTests(); i++) {
        if ( this->usedTests[i] ) {
          number++;
        }
      }
      return number;
    }
 
    /// Gets if enumerated random test has been used in last random test checking
    bool RandomTestSuite::GetUsedTest(RandomTests randomTest) {
 
      return this->usedTests[randomTest];
    }
 
    /// Gets if frequency random test has been used in last random test checking
    bool RandomTestSuite::GetUsedFrequencyTest(void) {
 
      return this->usedTests[Frequency];
    }
 
    /// Gets if block frequency random test has been used in last random test checking
    bool RandomTestSuite::GetUsedBlockFrequencyTest(void) {
 
      return this->usedTests[BlockFrequency];
    }
 
    /// Gets if cumulative sum forward random test has been used in last random test checking
    bool RandomTestSuite::GetUsedCumulativeSumForwardTest(void) {
 
      return this->usedTests[CumulativeSumForward];
    }
 
    /// Gets if cumulative sum reverse random test has been used in last random test checking
    bool RandomTestSuite::GetUsedCumulativeSumReverseTest(void) {
 
      return this->usedTests[CumulativeSumReverse];
    }
 
    /// Gets if runs random test has been used in last random test checking
    bool RandomTestSuite::GetUsedRunsTest(void) {
 
      return this->usedTests[Runs];
    }
 
    /// Gets if longest run of ones random test has been used in last random test checking
    bool RandomTestSuite::GetUsedLongestRunOfOnesTest(void) {
 
      return this->usedTests[LongestRunOfOnes];
    }
 
    /// Gets if rank random test has been used in last random test checking
    bool RandomTestSuite::GetUsedRankTest(void) {
 
      return this->usedTests[Rank];
    }
 
    /// Gets if universal random test has been used in last random test checking
    bool RandomTestSuite::GetUsedUniversalTest(void) {
 
      return this->usedTests[Universal];
    }
 
    /// Gets if approximate entropy random test has been used in last random test checking
    bool RandomTestSuite::GetUsedApproximateEntropyTest(void) {
 
      return this->usedTests[ApproximateEntropy];
    }
 
    /// Gets if serial random test has been used in last random test checking
    bool RandomTestSuite::GetUsedSerialTest(void) {
 
      return this->usedTests[Serial];
    }
 
    /// Gets if discrete fourier transform random test has been used in last random test checking
    bool RandomTestSuite::GetUsedDiscreteFourierTransformTest(void) {
 
      return this->usedTests[DiscreteFourierTransform];
    }
 
    /// Resets all random test "used" signal to false 
    void RandomTestSuite::ResetUsedTests(void) {
      unsigned short int i;
 
      for (i = this->GetFirstTest(); i < this->GetMaximumNumberOfTests(); i++) {
        this->usedTests[i] = false;
      }
    }
 
  }
}