/** This program verifies that primes generated by ssh-keygen are actually prime. The arguments are the filenames to process (e.g. /etc/ssh/moduli ) Thanks to The Dark Tangent for the inspiration. */ for file = ARGS for line = lines["file:" + file] { if line =~ %r/^\s*#/ // Skip comments next [timestamp, type, tests, trials, size, generator, modulus] = split[%r/\s+/, line] num = parseInt[modulus, 16] // Test for primality "safe prime" "Sophie Germain" prime = isPrime[num] // and isPrime[(num-1)/2] and isPrime[2 num + 1] if ! prime println["Failure! " + line] else println["Success: " + size] }