usnistgov/SP800-90B_EntropyAssessment

Check for invalid results for all tests that flag error

Closed this issue · 0 comments

Some (though not all) of the estimators can return values less than 0 to indicate an error. This indicates that the estimator was unable to run, and such results should be ignored.

The line

h_bitstring = min(bin_lrs_res, h_bitstring);

Should instead be

if(bin_lrs_res >= 0.0) h_bitstring = min(bin_lrs_res, h_bitstring);

Similarly the lines in

// Section 6.3.6 - Estimate entropy with LRS Test
if (((data.alph_size > 2) || !initial_entropy)) {
if (verbose == 1) printf("\tLRS Test Estimate (bit string) = %f / 1 bit(s)\n", bin_lrs_res);
H_bitstring = min(bin_lrs_res, H_bitstring);
}
if (initial_entropy) {
if (verbose == 1) printf("\tLRS Test Estimate = %f / %d bit(s)\n", lrs_res, data.word_size);
H_original = min(lrs_res, H_original);
}

should instead be

    // Section 6.3.6 - Estimate entropy with LRS Test
    if ((((data.alph_size > 2) || !initial_entropy)) && (bin_lrs_res >= 0.0)) {
        if (verbose == 1) printf("\tLRS Test Estimate (bit string) = %f / 1 bit(s)\n", bin_lrs_res);
        H_bitstring = min(bin_lrs_res, H_bitstring);
    }

    if (initial_entropy && (lrs_res >= 0.0)) {
        if (verbose == 1) printf("\tLRS Test Estimate = %f / %d bit(s)\n", lrs_res, data.word_size);
        H_original = min(lrs_res, H_original);
    }