diff options
Diffstat (limited to 'test/tpm_test/nist_entropy.sh')
-rwxr-xr-x | test/tpm_test/nist_entropy.sh | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/test/tpm_test/nist_entropy.sh b/test/tpm_test/nist_entropy.sh index f69c5652cd..5344a49890 100755 --- a/test/tpm_test/nist_entropy.sh +++ b/test/tpm_test/nist_entropy.sh @@ -3,19 +3,29 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# NIST toolset needs sudo emerge dev-libs/libdivsufsort -rm -rf /tmp/ea -git clone --depth 1 https://github.com/usnistgov/SP800-90B_EntropyAssessment.git /tmp/ea/ -make -C /tmp/ea/cpp/ non_iid -make -C /tmp/ea/cpp/ restart -TRNG_OUT=/tmp/trng_output -rm -f $TRNG_OUT -./tpmtest.py -t -if [ ! -f "$TRNG_OUT" ]; then - echo "$TRNG_OUT does not exist" +# NIST toolset needs sudo emerge dev-libs/libdivsufsort and bz2 +set -e +TMP_PATH="/tmp/ea" +NIST_URL="https://github.com/usnistgov/SP800-90B_EntropyAssessment.git" +TRNG_OUT="${TMP_PATH}/trng_output" +EA_LOG="ea_non_iid.log" +rm -rf "${TMP_PATH}" +git clone --depth 1 "${NIST_URL}" "${TMP_PATH}" +# build entropy assessment tool using mode for non independent and identically +# distributed data, as for H1 TRNG we can't justify the oppposite +make -j -C "${TMP_PATH}/cpp/" non_iid restart +rm -f "${TRNG_OUT}" +# -t0 requests raw random samples from TRNG +./tpmtest.py -t0 -o "${TRNG_OUT}" +if [[ ! -f "${TRNG_OUT}" ]]; then + echo "${TRNG_OUT} does not exist" exit 1 fi -/tmp/ea/cpp/ea_non_iid -a $TRNG_OUT | tee ea_non_iid.log -entropy=`grep min ea_non_iid.log | awk '{ print $5 }'` -echo "Minimal entropy" $entropy -/tmp/ea/cpp/ea_restart $TRNG_OUT $entropy | tee -a ea_non_iid.log +rm -f "${EA_LOG}" +"${TMP_PATH}/cpp/ea_non_iid" -a "${TRNG_OUT}" | tee "${EA_LOG}" +entropy="$(awk '/min/ {print $5}' "${EA_LOG}")" +if [[ -z "${entropy}" ]]; then + entropy="$(awk '/H_original/ {print $2}' "${EA_LOG}")" +fi +echo "Minimal entropy ${entropy}" +"${TMP_PATH}/cpp/ea_restart" "${TRNG_OUT}" "${entropy}" | tee -a "${EA_LOG}" |