Skip to content

Commit 5c395e0

Browse files
committed
Merge branch 'release/0.13.0'
2 parents da88c2d + a170b64 commit 5c395e0

File tree

124 files changed

+16683
-2786
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+16683
-2786
lines changed

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
*.[ao]
2+
*.aux
3+
*.dvi
4+
*.idx
5+
*.ilg
6+
*.ind
7+
*.lof
8+
*.log
9+
*.toc
10+
*.out
11+
*.l[ao]
12+
*.orig
13+
.project
14+
.cproject
15+
/.libs
16+
test_*.txt
17+
18+
test
19+
test.exe
20+
mtest
21+
mtest.exe
22+
stest
23+
stest.exe
24+
rsatest
25+
rsatest.exe
26+
timing
27+
timing.exe

.travis.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
language: c
2+
compiler:
3+
- gcc
4+
script: CC="${MYCC}" make ${SHARED} test_standalone >test_gcc_1.txt 2>test_gcc_2.txt && ./test >test_std.txt 2>test_err.txt
5+
env:
6+
- MYCC="gcc" SHARED=""
7+
- MYCC="gcc -m32" SHARED=""
8+
- MYCC="gcc-4.8" SHARED=""
9+
- MYCC="gcc-4.8 -m32" SHARED=""
10+
- MYCC="gcc-4.9" SHARED=""
11+
- MYCC="gcc-4.9 -m32" SHARED=""
12+
- MYCC="gcc" SHARED="-f makefile.shared"
13+
- MYCC="gcc -m32" SHARED="-f makefile.shared"
14+
- MYCC="gcc-4.8" SHARED="-f makefile.shared"
15+
- MYCC="gcc-4.8 -m32" SHARED="-f makefile.shared"
16+
- MYCC="gcc-4.9" SHARED="-f makefile.shared"
17+
- MYCC="gcc-4.9 -m32" SHARED="-f makefile.shared"
18+
matrix:
19+
fast_finish: true
20+
before_script:
21+
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
22+
- sudo apt-get -qq update
23+
- sudo apt-get install gcc-4.9-multilib gcc-4.8-multilib gcc-multilib build-essential
24+
after_failure:
25+
- cat test_gcc_1.txt
26+
- cat test_std.txt
27+
- cat test_err.txt
28+
after_script:
29+
- cat test_gcc_2.txt
30+
notifications:
31+
irc: "chat.freenode.net#libtom"
32+

LICENSE

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,36 @@
1-
TomsFastMath is public domain.
1+
TomsFastMath is licensed under DUAL licensing terms.
2+
3+
Choose and use the license of your needs.
4+
5+
[LICENSE #1]
6+
7+
TomsFastMath is public domain. As should all quality software be.
8+
9+
Tom St Denis
10+
11+
[/LICENSE #1]
12+
13+
[LICENSE #2]
14+
15+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
16+
Version 2, December 2004
17+
18+
Copyright (C) 2004 Sam Hocevar <[email protected]>
19+
20+
Everyone is permitted to copy and distribute verbatim or modified
21+
copies of this license document, and changing it is allowed as long
22+
as the name is changed.
23+
24+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
25+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
26+
27+
0. You just DO WHAT THE FUCK YOU WANT TO.
28+
29+
[/LICENSE #2]
30+
31+
-- Mark Karpel�s & Steffen Jaeckel
232

333
Note some ideas were borrowed from LibTomMath and OpenSSL. All of the code is original or ported
4-
from LibTomMath [no code was ported from OpenSSL]. As such the origins and status of this code
5-
are both public domain.
34+
from LibTomMath [no code was ported from OpenSSL].
635

736
-- Tom St Denis

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
tomsfastmath
2+
============
3+
4+
See doc/tfm.pdf for a detailed documentation
5+
6+
7+
Project Status
8+
==============
9+
10+
master: [![Build Status](https://travis-ci.org/libtom/tomsfastmath.svg?branch=master)](https://travis-ci.org/libtom/tomsfastmath)
11+

changes.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
October 24th, 2015
2+
v0.13.0
3+
-- Add fp_rand()
4+
-- Fix bug in fp_sub() reported by Martins Mozeiko
5+
-- Fix bugs/apply patches in fp_mul() and fp_sqr() reported by rasky
6+
-- Fix bugs in fp_read_radix()
7+
-- Fix build issues for Linux x32 ABI
8+
-- Sebastian Siewior provided fp_toradix_n(),
9+
reported multiple issues on behalf of ClamAV
10+
and did most of the testing work to be able to push this release out.
11+
-- Fix a load of compiler warnings.
12+
113
March 14th, 2007
214
0.12 -- Christophe Devine contributed MIPS asm w00t
315
++ quick release to get the MIPS code out there

demo/stest.c

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,32 @@
88

99
#ifndef DISPLAY
1010
#define DISPLAY(x) printf(x)
11+
#define DISPLAY_P(...) printf(__VA_ARGS__)
12+
#else
13+
#define DISPLAY_P(...) (void)0
14+
#define fp_dump(n,p) do{}while(0)
1115
#endif
1216

17+
#ifndef fp_dump
18+
void fp_dump(const char* n, fp_int* p)
19+
{
20+
int sz;
21+
if (fp_radix_size(p, 2, &sz) != FP_OKAY)
22+
return;
23+
char* str = malloc(sz);
24+
if (!str)
25+
return;
26+
#ifdef STEST_VERBOSE
27+
fp_toradix(p, str, 2);
28+
DISPLAY_P("%s = 0b%s\n", n, str);
29+
fp_toradix(p, str, 16);
30+
DISPLAY_P("%s = 0x%s\n", n, str);
31+
#endif
32+
fp_toradix(p, str, 10);
33+
DISPLAY_P("%s = %s\n", n, str);
34+
free(str);
35+
}
36+
#endif
1337

1438
#ifdef GBA_MODE
1539
int c_main(void)
@@ -33,14 +57,16 @@ int main(void)
3357
modetxt_gotoxy(0,0);
3458
#endif
3559

60+
DISPLAY_P("TFM Ident string:\n%s\n\n", fp_ident());
61+
3662
/* test multiplication */
3763
fp_read_radix(&a, "3453534534535345345341230891273", 10);
3864
fp_read_radix(&b, "2394873294871238934718923" , 10);
3965
fp_read_radix(&c, "8270777629674273015508507050766235312931312159028658979", 10);
4066
fp_mul(&a, &b, &d);
4167
if (fp_cmp(&c, &d)) {
4268
DISPLAY("mul failed\n");
43-
return 0;
69+
return -1;
4470
} else {
4571
DISPLAY("mul passed\n");
4672
}
@@ -52,7 +78,7 @@ int main(void)
5278
fp_mul(&a, &b, &d);
5379
if (fp_cmp(&c, &d)) {
5480
DISPLAY("mul failed\n");
55-
return 0;
81+
return -1;
5682
} else {
5783
DISPLAY("mul passed\n");
5884
}
@@ -64,7 +90,7 @@ int main(void)
6490
fp_mul(&a, &b, &d);
6591
if (fp_cmp(&c, &d)) {
6692
DISPLAY("mul failed\n");
67-
return 0;
93+
return -1;
6894
} else {
6995
DISPLAY("mul passed\n");
7096
}
@@ -75,7 +101,7 @@ int main(void)
75101
fp_sqr(&a, &c);
76102
if (fp_cmp(&c, &b)) {
77103
DISPLAY("sqr failed\n");
78-
return 0;
104+
return -1;
79105
} else {
80106
DISPLAY("sqr passed\n");
81107
}
@@ -85,7 +111,7 @@ int main(void)
85111
fp_sqr(&a, &c);
86112
if (fp_cmp(&c, &b)) {
87113
DISPLAY("sqr failed\n");
88-
return 0;
114+
return -1;
89115
} else {
90116
DISPLAY("sqr passed\n");
91117
}
@@ -95,7 +121,7 @@ int main(void)
95121
fp_sqr(&a, &c);
96122
if (fp_cmp(&c, &b)) {
97123
DISPLAY("sqr failed\n");
98-
return 0;
124+
return -1;
99125
} else {
100126
DISPLAY("sqr passed\n");
101127
}
@@ -104,43 +130,56 @@ int main(void)
104130
/* montgomery reductions */
105131
fp_read_radix(&a, "234892374892374893489123428937892781237863278637826327367637836278362783627836783678363", 10);
106132
fp_read_radix(&b, "4447823492749823749234123489273987393983289319382762756425425425642727352327452374521", 10);
133+
#ifdef FP_64BIT
134+
fp_read_radix(&c, "942974496560863503657226741422301598807235487941674147660989764036913926327577165648", 10);
135+
#else
107136
fp_read_radix(&c, "2396271882990732698083317035605836523697277786556053771759862552557086442129695099100", 10);
108-
fp_montgomery_setup(&b, &dp);
137+
#endif
138+
if (fp_montgomery_setup(&b, &dp) != FP_OKAY)
139+
DISPLAY("mont setup failed\n");
109140
fp_montgomery_reduce(&a, &b, dp);
110141
if (fp_cmp(&a, &c)) {
111142
DISPLAY("mont failed\n");
112-
return 0;
143+
fp_dump("a (is )", &a);
144+
fp_dump("c (should)", &c);
145+
return -1;
113146
} else {
114147
DISPLAY("mont passed\n");
115148
}
116149

117150
fp_read_radix(&a, "2348923748923748934891234456645654645645684576353428937892781237863278637826327367637836278362783627836783678363", 10);
118151
fp_read_radix(&b, "444782349274982374923412348927398739398328931938276275642542542564272735232745237452123424324324444121111119", 10);
119152
fp_read_radix(&c, "45642613844554582908652603086180267403823312390990082328515008314514368668691233331246183943400359349283420", 10);
120-
fp_montgomery_setup(&b, &dp);
153+
if (fp_montgomery_setup(&b, &dp) != FP_OKAY)
154+
DISPLAY("mont setup failed\n");
121155
fp_montgomery_reduce(&a, &b, dp);
122156
if (fp_cmp(&a, &c)) {
123157
DISPLAY("mont failed\n");
124-
return 0;
158+
fp_dump("a (is )", &a);
159+
fp_dump("c (should)", &c);
160+
return -1;
125161
} else {
126162
DISPLAY("mont passed\n");
127163
}
128164

129165
fp_read_radix(&a, "234823424242342923748923748934891234456645654645645684576353424972378234762378623891236834132352375235378462378489378927812378632786378263273676378362783627555555555539568389052478124618461834763837685723645827529034853490580134568947341278498542893481762349723907847892983627836783678363", 10);
130166
fp_read_radix(&b, "44478234927456563455982374923412348927398739398328931938276275642485623481638279025465891276312903262837562349056234783648712314678120389173890128905425242424239784256427", 10);
131167
fp_read_radix(&c, "33160865265453361650564031464519042126185632333462754084489985719613480783282357410514898819797738034600484519472656152351777186694609218202276509271061460265488348645081", 10);
132-
fp_montgomery_setup(&b, &dp);
168+
if (fp_montgomery_setup(&b, &dp) != FP_OKAY)
169+
DISPLAY("mont setup failed\n");
133170
fp_montgomery_reduce(&a, &b, dp);
134171
if (fp_cmp(&a, &c)) {
135172
DISPLAY("mont failed\n");
136-
return 0;
173+
fp_dump("a (is )", &a);
174+
fp_dump("c (should)", &c);
175+
return -1;
137176
} else {
138177
DISPLAY("mont passed\n");
139178
}
140179

141180

142181
return 0;
143-
}
182+
}
144183

145184

146185
/* $Source$ */

0 commit comments

Comments
 (0)