]>
Commit | Line | Data |
---|---|---|
b4f35e5e | 1 | #! /usr/bin/env perl |
e0a65194 RS |
2 | # Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. |
3 | # | |
4 | # Licensed under the OpenSSL license (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 | |
d02b48c6 | 8 | |
e0a65194 RS |
9 | print <<"EOF"; |
10 | /* | |
11 | * WARNING: do not edit! | |
12 | * Generated by crypto/bn/bn_prime.pl | |
e4b76456 | 13 | * |
e0a65194 | 14 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. |
b0700d2c | 15 | * |
e0a65194 RS |
16 | * Licensed under the OpenSSL license (the "License"). You may not use |
17 | * this file except in compliance with the License. You can obtain a copy | |
18 | * in the file LICENSE in the source distribution or at | |
19 | * https://www.openssl.org/source/license.html | |
d02b48c6 RE |
20 | */ |
21 | ||
22 | EOF | |
23 | ||
d02b48c6 | 24 | |
b4f35e5e RS |
25 | my $num = shift || 2048; |
26 | my @primes = ( 2 ); | |
27 | my $p = 1; | |
28 | loop: while ($#primes < $num-1) { | |
29 | $p += 2; | |
30 | my $s = int(sqrt($p)); | |
31 | ||
32 | for (my $i = 0; defined($primes[$i]) && $primes[$i] <= $s; $i++) { | |
33 | next loop if ($p % $primes[$i]) == 0; | |
34 | } | |
35 | push(@primes, $p); | |
36 | } | |
37 | ||
38 | print "typedef unsigned short prime_t;\n"; | |
7eba4e62 | 39 | printf "# define NUMPRIMES %d\n\n", $num; |
b4f35e5e | 40 | |
7eba4e62 | 41 | printf "static const prime_t primes[%d] = {\n", $num; |
b4f35e5e RS |
42 | for (my $i = 0; $i <= $#primes; $i++) { |
43 | printf "\n " if ($i % 8) == 0; | |
44 | printf "%4d, ", $primes[$i]; | |
45 | } | |
46 | print "\n};\n"; |