For cryptographic algorithms, secret keys should be generated randomly as the security of the system depends on the key and therefore generation of random sequences is vital. Randomness testing is done by means of statistical randomness tests. In this work, we show that the probabilities for the overlapping template matching test in the NIST test suite are only valid for a specific template and need to be recalculated for the other templates. | Turk J Math (2017) 41: 80 – 95 ¨ ITAK ˙ c TUB ⃝ Turkish Journal of Mathematics doi: Research Article New statistical randomness tests: 4-bit template matching tests Fatih SULAK∗ Department of Mathematics, Atılım University, Ankara, Turkey Received: • Accepted/Published Online: • Final Version: Abstract: For cryptographic algorithms, secret keys should be generated randomly as the security of the system depends on the key and therefore generation of random sequences is vital. Randomness testing is done by means of statistical randomness tests. In this work, we show that the probabilities for the overlapping template matching test in the NIST test suite are only valid for a specific template and need to be recalculated for the other templates. We calculate the exact distribution for all 4-bit templates and propose new randomness tests, namely template matching tests. The new tests can be applied to any sequence of minimum length 5504 whereas the overlapping template matching test in the NIST test suite can only be applied to sequences of minimum length 106 . Moreover, we apply the proposed tests to biased nonrandom data and observe that the new tests detect the nonrandom behavior of the generator even for a bias of , whereas the template matching tests in NIST cannot detect that bias. Key words: Cryptography, overlapping template matching test, statistical randomness testing, NIST test suite 1. Introduction Random sequences and random numbers are used in many fields, such as statistics, computer simulations, and cryptography. In cryptography, random sequences are needed for several applications, such as the generation of primes in RSA encryption, secret keys in symmetric encryption, challenges in challenge-response protocols, initialization vectors, or salts in hash functions, but the most common application is the generation of secret keys. Secret keys should be