summaryrefslogtreecommitdiff
path: root/src/mesa_sts.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa_sts.c')
-rw-r--r--src/mesa_sts.c94
1 files changed, 78 insertions, 16 deletions
diff --git a/src/mesa_sts.c b/src/mesa_sts.c
index 5a13d2b..f95ac89 100644
--- a/src/mesa_sts.c
+++ b/src/mesa_sts.c
@@ -3,7 +3,7 @@
#include "include/stat_fncs.h"
#include "mesa_sts.h"
-int mesa_statistical_test_suite(void* data,unsigned int datalen, struct sts_result* result)
+int mesa_statistical_test_suite(void* data,unsigned int datalen, struct sts_result* result, unsigned int random_judge_switch_flag)
{
TP tp;
tp.n = datalen;
@@ -25,25 +25,87 @@ int mesa_statistical_test_suite(void* data,unsigned int datalen, struct sts_resu
bitsRead = 0;
done = 0;
done = convertToBits((BYTE*)data,datalen,tp.n,&num_0s,&num_1s,&bitsRead,epsilon);
- result->frequency = Frequency(tp.n,epsilon);
- result->block_frequency = BlockFrequency(tp.blockFrequencyBlockLength, tp.n,epsilon);
- result->cumulative_sums = CumulativeSums(tp.n,epsilon);
- result->runs = Runs(tp.n,epsilon);
- result->longest_run = LongestRunOfOnes(tp.n,epsilon);
- result->rank = Rank(tp.n,epsilon);
+ if (STS_TEST_FLAG(random_judge_switch_flag, STS_FREQUENCY))
+ {
+ result->frequency = Frequency(tp.n,epsilon);
+ }
+
+ if (STS_TEST_FLAG(random_judge_switch_flag, STS_BLOCK_FREQUENCY))
+ {
+ result->block_frequency = BlockFrequency(tp.blockFrequencyBlockLength, tp.n,epsilon);
+ }
+
+ if (STS_TEST_FLAG(random_judge_switch_flag, STS_CUMULATIVE_SUMS))
+ {
+ result->cumulative_sums = CumulativeSums(tp.n,epsilon);
+ }
+
+ if (STS_TEST_FLAG(random_judge_switch_flag, STS_RUNS))
+ {
+ result->runs = Runs(tp.n,epsilon);
+ }
+
+ if (STS_TEST_FLAG(random_judge_switch_flag, STS_LONGEST_RUN))
+ {
+ result->longest_run = LongestRunOfOnes(tp.n,epsilon);
+ }
+
+ if (STS_TEST_FLAG(random_judge_switch_flag, STS_RANK))
+ {
+ result->rank = Rank(tp.n,epsilon);
+ }
+
//result->discrete_fourier_transform = DiscreteFourierTransform(tp.n,epsilon);//cost too much time
- result->non_overlapping_template_matching = NonOverlappingTemplateMatchings(tp.nonOverlappingTemplateBlockLength, tp.n,epsilon);
- result->overlapping_template_matching = OverlappingTemplateMatchings(tp.overlappingTemplateBlockLength, tp.n,epsilon);
- result->universal = Universal(tp.n,epsilon);
+
+ if (STS_TEST_FLAG(random_judge_switch_flag, STS_NON_OVERLAPPING_TEMPLATE_MATCHING))
+ {
+ result->non_overlapping_template_matching = NonOverlappingTemplateMatchings(tp.nonOverlappingTemplateBlockLength, tp.n,epsilon);
+ }
+
+ if (STS_TEST_FLAG(random_judge_switch_flag, STS_OVERLAPPING_TEMPLATE_MATCHING))
+ {
+ result->overlapping_template_matching = OverlappingTemplateMatchings(tp.overlappingTemplateBlockLength, tp.n,epsilon);
+ }
+
+ if (STS_TEST_FLAG(random_judge_switch_flag, STS_UNIVERSAL))
+ {
+ result->universal = Universal(tp.n,epsilon);
+ }
+
//result->approximate_entropy = ApproximateEntropy(tp.approximateEntropyBlockLength, tp.n,epsilon);//cost too much time
- result->random_excursions = RandomExcursions(tp.n,epsilon);
- result->random_excursions_variant = RandomExcursionsVariant(tp.n,epsilon);
+
+ if (STS_TEST_FLAG(random_judge_switch_flag, STS_RANDOM_EXCURSIONS))
+ {
+ result->random_excursions = RandomExcursions(tp.n,epsilon);
+ }
+
+ if (STS_TEST_FLAG(random_judge_switch_flag, STS_RANDOM_EXCURSIONS_VARIANT))
+ {
+ result->random_excursions_variant = RandomExcursionsVariant(tp.n,epsilon);
+ }
+
//result->serial = Serial(tp.serialBlockLength,tp.n,epsilon);//cost too much time
//sresult->linear_complexity = LinearComplexity(tp.linearComplexitySequenceLength, tp.n,epsilon);//cost too much time
- result->poker_detect = PokerDetect(tp.PokerDetectMLength,tp.n,epsilon);
- result->runs_distribution = RunsDistribution(tp.n,epsilon);
- result->self_correlation = SelfCorrelation(tp.SelfCorrelationDLength,tp.n,epsilon);
- result->binary_derivative = BinaryDerivate(tp.BinaryDerivateKLength,tp.n,epsilon,tp.n);//this function will change the value of epsilon, must be the last one
+
+ if (STS_TEST_FLAG(random_judge_switch_flag, STS_POKER_DETECT))
+ {
+ result->poker_detect = PokerDetect(tp.PokerDetectMLength,tp.n,epsilon);
+ }
+
+ if (STS_TEST_FLAG(random_judge_switch_flag, STS_RUNS_DISTRIBUTION))
+ {
+ result->runs_distribution = RunsDistribution(tp.n,epsilon);
+ }
+
+ if (STS_TEST_FLAG(random_judge_switch_flag, STS_SELF_CORRELATION))
+ {
+ result->self_correlation = SelfCorrelation(tp.SelfCorrelationDLength,tp.n,epsilon);
+ }
+
+ if (STS_TEST_FLAG(random_judge_switch_flag, STS_BINARY_DERIVATE))
+ {
+ result->binary_derivative = BinaryDerivate(tp.BinaryDerivateKLength,tp.n,epsilon,tp.n);//this function will change the value of epsilon, must be the last one
+ }
free(epsilon);
epsilon = NULL;