verifySSH.frink

Download or view verifySSH.frink in plain text format


/** 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]
   }


Download or view verifySSH.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 20217 days, 23 hours, 35 minutes ago.