2 # Copyright 1998-2019 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the Apache License 2.0 (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
9 # Output year depends on the year of the script.
10 my $YEAR = [localtime([stat($0)]->[9])]->[5] + 1900;
13 * WARNING: do not edit!
14 * Generated by crypto/bn/bn_prime.pl
16 * Copyright 1998-$YEAR The OpenSSL Project Authors. All Rights Reserved.
18 * Licensed under the Apache License 2.0 (the "License"). You may not use
19 * this file except in compliance with the License. You can obtain a copy
20 * in the file LICENSE in the source distribution or at
21 * https://www.openssl.org/source/license.html
27 my $num = shift || 2048;
30 loop: while ($#primes < $num-1) {
32 my $s = int(sqrt($p));
34 for (my $i = 0; defined($primes[$i]) && $primes[$i] <= $s; $i++) {
35 next loop if ($p % $primes[$i]) == 0;
40 print "typedef unsigned short prime_t;\n";
41 printf "# define NUMPRIMES %d\n\n", $num;
43 printf "static const prime_t primes[%d] = {", $num;
44 for (my $i = 0; $i <= $#primes; $i++) {
45 printf "\n " if ($i % 8) == 0;
46 printf " %5d,", $primes[$i];