Skip to content

Get rid of BN prefix #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
232 changes: 116 additions & 116 deletions demo/test.c

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions doc/bn.tex
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ \subsubsection{OpenBSD}
cc -I./ -Wall -Wsign-compare -Wextra -Wshadow -Wsystem-headers -Wdeclaration-afo...
cc -I./ -Wall -Wsign-compare -Wextra -Wshadow -Wsystem-headers -Wdeclaration-afo...
cc -I./ -Wall -Wsign-compare -Wextra -Wshadow -Wsystem-headers -Wdeclaration-afo...
libtool --mode=link --tag=CC cc bn_error.lo bn_s_mp_invmod_fast.lo bn_fast_mp_mo
libtool: link: cc bn_error.lo bn_s_mp_invmod_fast.lo bn_s_mp_montgomery_reduce_fast0
bn_error.lo: file not recognized: File format not recognized
libtool --mode=link --tag=CC cc error.lo s_mp_invmod_fast.lo fast_mp_mo
libtool: link: cc error.lo s_mp_invmod_fast.lo s_mp_montgomery_reduce_fast0
error.lo: file not recognized: File format not recognized
cc: error: linker command failed with exit code 1 (use -v to see invocation)
Error while executing cc bn_error.lo bn_s_mp_invmod_fast.lo bn_fast_mp_montgomery0
Error while executing cc error.lo s_mp_invmod_fast.lo fast_mp_montgomery0
gmake: *** [makefile.shared:64: libtommath.la] Error 1
\end{alltt}

Expand Down Expand Up @@ -259,7 +259,7 @@ \section{Build Configuration}
\subsection{Build Depends}
In the file tommath\_class.h you will see a large list of C ``defines'' followed by a series of ``ifdefs''
which further define symbols. All of the symbols (technically they're macros $\ldots$) represent a given C source
file. For instance, BN\_MP\_ADD\_C represents the file ``bn\_mp\_add.c''. When a define has been enabled the
file. For instance, MP\_ADD\_C represents the file ``bn\_mp\_add.c''. When a define has been enabled the
function in the respective file will be compiled and linked into the library. Accordingly when the define
is absent the file will not be compiled and not contribute any size to the library.

Expand All @@ -275,7 +275,7 @@ \subsection{Build Tweaks}
\begin{center}
\begin{tabular}{|l|l|}
\hline \textbf{Define} & \textbf{Purpose} \\
\hline BN\_MP\_DIV\_SMALL & Enables a slower, smaller and equally \\
\hline MP\_DIV\_SMALL & Enables a slower, smaller and equally \\
& functional mp\_div() function \\
\hline
\end{tabular}
Expand All @@ -293,20 +293,20 @@ \subsubsection{Moduli Related}
\begin{center}
\begin{tabular}{|l|l|}
\hline \textbf{Restriction} & \textbf{Undefine} \\
\hline Exponentiation with odd moduli only & BN\_S\_MP\_EXPTMOD\_C \\
& BN\_MP\_REDUCE\_C \\
& BN\_MP\_REDUCE\_SETUP\_C \\
& BN\_S\_MP\_MUL\_HIGH\_DIGS\_C \\
& BN\_FAST\_S\_MP\_MUL\_HIGH\_DIGS\_C \\
\hline Exponentiation with odd moduli only & S\_MP\_EXPTMOD\_C \\
& MP\_REDUCE\_C \\
& MP\_REDUCE\_SETUP\_C \\
& S\_MP\_MUL\_HIGH\_DIGS\_C \\
& FAST\_S\_MP\_MUL\_HIGH\_DIGS\_C \\
\hline Exponentiation with random odd moduli & (The above plus the following) \\
& BN\_MP\_REDUCE\_2K\_C \\
& BN\_MP\_REDUCE\_2K\_SETUP\_C \\
& BN\_MP\_REDUCE\_IS\_2K\_C \\
& BN\_MP\_DR\_IS\_MODULUS\_C \\
& BN\_MP\_DR\_REDUCE\_C \\
& BN\_MP\_DR\_SETUP\_C \\
\hline Modular inverse odd moduli only & BN\_MP\_INVMOD\_SLOW\_C \\
\hline Modular inverse (both, smaller/slower) & BN\_FAST\_MP\_INVMOD\_C \\
& MP\_REDUCE\_2K\_C \\
& MP\_REDUCE\_2K\_SETUP\_C \\
& MP\_REDUCE\_IS\_2K\_C \\
& MP\_DR\_IS\_MODULUS\_C \\
& MP\_DR\_REDUCE\_C \\
& MP\_DR\_SETUP\_C \\
\hline Modular inverse odd moduli only & MP\_INVMOD\_SLOW\_C \\
\hline Modular inverse (both, smaller/slower) & FAST\_MP\_INVMOD\_C \\
\hline
\end{tabular}
\end{center}
Expand All @@ -317,14 +317,14 @@ \subsubsection{Operand Size Related}
\begin{center}
\begin{tabular}{|l|l|}
\hline \textbf{Restriction} & \textbf{Undefine} \\
\hline Moduli $\le 2560$ bits & BN\_MP\_MONTGOMERY\_REDUCE\_C \\
& BN\_S\_MP\_MUL\_DIGS\_C \\
& BN\_S\_MP\_MUL\_HIGH\_DIGS\_C \\
& BN\_S\_MP\_SQR\_C \\
\hline Polynomial Schmolynomial & BN\_MP\_KARATSUBA\_MUL\_C \\
& BN\_MP\_KARATSUBA\_SQR\_C \\
& BN\_MP\_TOOM\_MUL\_C \\
& BN\_MP\_TOOM\_SQR\_C \\
\hline Moduli $\le 2560$ bits & MP\_MONTGOMERY\_REDUCE\_C \\
& S\_MP\_MUL\_DIGS\_C \\
& S\_MP\_MUL\_HIGH\_DIGS\_C \\
& S\_MP\_SQR\_C \\
\hline Polynomial Schmolynomial & MP\_KARATSUBA\_MUL\_C \\
& MP\_KARATSUBA\_SQR\_C \\
& MP\_TOOM\_MUL\_C \\
& MP\_TOOM\_SQR\_C \\

\hline
\end{tabular}
Expand Down
26 changes: 13 additions & 13 deletions etc/tune.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,39 +67,39 @@ static uint64_t s_time_mul(int size)

if ((e = mp_init_multi(&a, &b, &c, &d, NULL)) != MP_OKAY) {
t1 = UINT64_MAX;
goto LTM_ERR;
goto LBL_ERR;
}

if ((e = mp_rand(&a, size * s_offset)) != MP_OKAY) {
t1 = UINT64_MAX;
goto LTM_ERR;
goto LBL_ERR;
}
if ((e = mp_rand(&b, size)) != MP_OKAY) {
t1 = UINT64_MAX;
goto LTM_ERR;
goto LBL_ERR;
}

s_timer_start();
for (x = 0; x < s_number_of_test_loops; x++) {
if ((e = mp_mul(&a,&b,&c)) != MP_OKAY) {
t1 = UINT64_MAX;
goto LTM_ERR;
goto LBL_ERR;
}
if (s_check_result == 1) {
if ((e = s_mp_mul(&a,&b,&d)) != MP_OKAY) {
t1 = UINT64_MAX;
goto LTM_ERR;
goto LBL_ERR;
}
if (mp_cmp(&c, &d) != MP_EQ) {
/* Time of 0 cannot happen (famous last words?) */
t1 = 0uLL;
goto LTM_ERR;
goto LBL_ERR;
}
}
}

t1 = s_timer_stop();
LTM_ERR:
LBL_ERR:
mp_clear_multi(&a, &b, &c, &d, NULL);
return t1;
}
Expand All @@ -112,34 +112,34 @@ static uint64_t s_time_sqr(int size)

if ((e = mp_init_multi(&a, &b, &c, NULL)) != MP_OKAY) {
t1 = UINT64_MAX;
goto LTM_ERR;
goto LBL_ERR;
}

if ((e = mp_rand(&a, size)) != MP_OKAY) {
t1 = UINT64_MAX;
goto LTM_ERR;
goto LBL_ERR;
}

s_timer_start();
for (x = 0; x < s_number_of_test_loops; x++) {
if ((e = mp_sqr(&a,&b)) != MP_OKAY) {
t1 = UINT64_MAX;
goto LTM_ERR;
goto LBL_ERR;
}
if (s_check_result == 1) {
if ((e = s_mp_sqr(&a,&c)) != MP_OKAY) {
t1 = UINT64_MAX;
goto LTM_ERR;
goto LBL_ERR;
}
if (mp_cmp(&c, &b) != MP_EQ) {
t1 = 0uLL;
goto LTM_ERR;
goto LBL_ERR;
}
}
}

t1 = s_timer_stop();
LTM_ERR:
LBL_ERR:
mp_clear_multi(&a, &b, &c, NULL);
return t1;
}
Expand Down
2 changes: 1 addition & 1 deletion gen.pl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use warnings;

open(my $out, '>', 'mpi.c') or die "Couldn't open mpi.c for writing: $!";
foreach my $filename (glob 'bn*.c') {
foreach my $filename (glob '*mp_*.c') {
open(my $src, '<', $filename) or die "Couldn't open $filename for reading: $!";
print {$out} "/* Start: $filename */\n";
print {$out} $_ while <$src>;
Expand Down
8 changes: 4 additions & 4 deletions helper.pl
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ sub draw_func
my ($deplist, $depmap, $out, $indent, $funcslist) = @_;
my @funcs = split ',', $funcslist;
# try this if you want to have a look at a minimized version of the callgraph without all the trivial functions
#if ($deplist =~ /$funcs[0]/ || $funcs[0] =~ /BN_MP_(ADD|SUB|CLEAR|CLEAR_\S+|DIV|MUL|COPY|ZERO|GROW|CLAMP|INIT|INIT_\S+|SET|ABS|CMP|CMP_D|EXCH)_C/) {
#if ($deplist =~ /$funcs[0]/ || $funcs[0] =~ /MP_(ADD|SUB|CLEAR|CLEAR_\S+|DIV|MUL|COPY|ZERO|GROW|CLAMP|INIT|INIT_\S+|SET|ABS|CMP|CMP_D|EXCH)_C/) {
if ($deplist =~ /$funcs[0]/) {
return $deplist;
} else {
Expand Down Expand Up @@ -309,7 +309,7 @@ sub update_dep
#if defined(LTM_ALL)
EOS

foreach my $filename (glob 'bn*.c') {
foreach my $filename (glob '*mp_*.c') {
my $define = $filename;

print "Processing $filename\n";
Expand Down Expand Up @@ -356,7 +356,7 @@ sub update_dep

# now do classes
my %depmap;
foreach my $filename (glob 'bn*.c') {
foreach my $filename (glob '*mp_*.c') {
my $content;
my $cc = $ENV{'CC'} || 'gcc';
$content = `$cc -E -x c -DLTM_ALL $filename`;
Expand All @@ -379,7 +379,7 @@ sub update_dep
my $a = $&;
next if $a eq "mp_err";
$a =~ tr/[a-z]/[A-Z]/;
$a = 'BN_' . $a . '_C';
$a = $a . '_C';
push @deps, $a;
}
}
Expand Down
Loading