Skip to content

Commit 16100c3

Browse files
Tom St Denissjaeckel
authored andcommitted
added libtomcrypt-0.90
1 parent 710106c commit 16100c3

24 files changed

Lines changed: 1687 additions & 591 deletions

changes

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
Sept 7th, 2003
2+
v0.90 -- new ROL/ROR for x86 GCC
3+
-- Jochen Katz submitted a patch to the makefile to prevent "make" from making the .a library
4+
when not required.
5+
== By default the KR code is not enabled [it's only a demo anyways!]
6+
-- changed the "buf" in ecc_make_key from 4KB to 128 bytes [since the largest key is 65 bytes]
7+
-- hmac_done() now requires you pass it the size of the destination buffer to prevent
8+
buffer overflows. (API CHANGE)
9+
-- hmac/hash filebased routines now return CRYPT_NOP if NO_FILE is defined.
10+
-- I've removed the primes from dh.c and replaced them with DR safe primes suitable for the default
11+
configuration of LibTomMath. Check out these comparisons on a 1.3Ghz Athlon XP, optimized for size,
12+
13+
768-bit, 4 vs. 10
14+
1024-bit, 8 vs. 18
15+
1280-bit, 12 vs. 34
16+
1536-bit, 20 vs. 56
17+
1792-bit 28 vs. 88
18+
2048-bit, 40 vs. 124
19+
2560-bit, 71 vs. 234
20+
3072-bit, 113 vs. 386
21+
4096-bit, 283 vs. 916
22+
23+
Times are all in milliseconds for key generation. New primes times on the left. This makes the code binary
24+
incompatible with previous releases. However, this addition is long overdue as LibTomMath has supported DR
25+
reductions for quite some time.
26+
-- Added RIPE-MD 128 and 160 to the list of supported hashes [10 in total].
27+
-- The project has been released as public domain. TDCAL no longer applies.
28+
129
July 15th, 2003
230
v0.89 -- Fix a bug in bits.c which would prevent it from building with msvc
331
-- Merged in LibTomMath v0.24 [and I used the alloc/free macros this time!]

config.pl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
);
2222

2323
@opts = (
24-
"SMALL_CODE,Use small code where possible (slower code),n",
24+
"SMALL_CODE,Use small code where possible (slower code),y",
2525
"NO_FILE,Avoid file I/O calls,n",
2626
"CLEAN_STACK,Clean the stack within functions,n",
2727
"LTC_TEST,Include Test Vector Routines,y",
@@ -55,6 +55,8 @@
5555
"MD5,Include MD5 one-way hash,y",
5656
"MD4,Include MD4 one-way hash,y",
5757
"MD2,Include MD2 one-way hash,y",
58+
"RIPEMD128,Include RIPEMD-128 one-way hash,y",
59+
"RIPEMD160,Include RIPEMD-160 one-way hash,y",
5860
"HMAC,Include Hash based Message Authentication Support,y",
5961

6062
"BASE64,Include Base64 encoding support,y",
@@ -68,7 +70,7 @@
6870
"MRSA,Include RSA public key support,y",
6971
"MDH,Include Diffie-Hellman (over Z/pZ) public key support,y",
7072
"MECC,Include Eliptic Curve public key crypto support,y",
71-
"KR,Include Keyring support (groups all three PK systems),y",
73+
"KR,Include Keyring support (groups all three PK systems),n",
7274

7375
"DH768,768-bit DH key support,y",
7476
"DH1024,1024-bit DH key support,y",

crypt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,9 @@ const char *crypt_build_settings =
443443
#if defined(MD2)
444444
" MD2\n"
445445
#endif
446+
#if defined(RIPEMD128)
447+
" RIPEMD128\n"
448+
#endif
446449

447450
"\nBlock Chaining Modes:\n"
448451
#if defined(CFB)

crypt.pdf

-510 Bytes
Binary file not shown.

crypt.tex

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
\def\gap{\vspace{0.5ex}}
4848
\makeindex
4949
\begin{document}
50-
\title{A Tiny Crypto Library, \\ LibTomCrypt \\ Version 0.89}
50+
\title{A Tiny Crypto Library, \\ LibTomCrypt \\ Version 0.90}
5151
\author{Tom St Denis \\
5252
Algonquin College \\
5353
\\
@@ -158,25 +158,20 @@ \subsection{Modular}
158158
\section{License}
159159

160160
All of the source code except for the following files have been written by the author or donated to the project
161-
under the TDCAL license:
161+
under a public domain license:
162162

163163
\begin{enumerate}
164164
\item rc2.c
165165
\item safer.c
166166
\end{enumerate}
167167

168-
`mpi.c'' was originally written
169-
by Michael Fromberger (sting@linguist.dartmouth.edu) but has since been replaced with my LibTomMath library.
170-
``rc2.c'' is based on publicly available code that is not attributed to a person from the given source. ``safer.c''
168+
`mpi.c'' was originally written by Michael Fromberger (sting@linguist.dartmouth.edu) but has since been replaced with my LibTomMath
169+
library.
170+
171+
``rc2.c'' is based on publicly available code that is not attributed to a person from the given source. ``safer.c''
171172
was written by Richard De Moliner (demoliner@isi.ee.ethz.ch) and is public domain.
172173

173-
The rest of the code was written either by Tom St Denis or contributed to the project under the ``Tom Doesn't Care
174-
About Licenses'' (TDCAL) license. Essentially this license grants the user unlimited distribution and usage (including
175-
commercial usage). This means that you can use the package, you can re-distribute the package and even branch it. I
176-
still retain ownership over the name of the package. If you want to branch the project you can use the code as a base
177-
but you must change the name. The package is also royalty free which means you can use it in commercial products
178-
without compensation towards the author. I assume no risk from usage of the code nor do I guarantee it works as
179-
desired or stated.
174+
The project is hereby released as public domain.
180175

181176
\section{Patent Disclosure}
182177

@@ -364,7 +359,7 @@ \section{Core Functions}
364359
are (given that XXX is the name of the cipher):
365360
\index{Cipher Setup}
366361
\begin{verbatim}
367-
int XXX_setup(const unsigned char *key, int keylen, int rounds,
362+
int XXX_setup(const unsigned char *key, int keylen, int rounds,
368363
symmetric_key *skey);
369364
\end{verbatim}
370365

@@ -973,6 +968,8 @@ \section{Hash Descriptors}
973968
\hline SHA-256 & sha256\_desc & 32 \\
974969
\hline TIGER-192 & tiger\_desc & 24 \\
975970
\hline SHA-1 & sha1\_desc & 20 \\
971+
\hline RIPEMD-160 & rmd160\_desc & 20 \\
972+
\hline RIPEMD-128 & rmd128\_desc & 16 \\
976973
\hline MD5 & md5\_desc & 16 \\
977974
\hline MD4 & md4\_desc & 16 \\
978975
\hline MD2 & md2\_desc & 16 \\
@@ -1019,10 +1016,12 @@ \section{Hash based Message Authenication Codes}
10191016
number of octets to process. Like the hash process routines you can send the data in arbitrarly sized chunks. When you
10201017
are finished with the HMAC process you must call the following function to get the HMAC code:
10211018
\begin{verbatim}
1022-
int hmac_done(hmac_state *hmac, unsigned char *hash);
1019+
int hmac_done(hmac_state *hmac, unsigned char *hashOut,
1020+
unsigned long *outlen);
10231021
\end{verbatim}
1024-
``hmac'' is the HMAC state you are working with. ``hash'' is the array of octets where the HMAC code should be stored. You
1025-
must ensure that your destination array is the right size (or just make it of size MAXBLOCKSIZE to be sure).
1022+
``hmac'' is the HMAC state you are working with. ``hashOut'' is the array of octets where the HMAC code should be stored. You must
1023+
set ``outlen'' to the size of the destination buffer before calling this function. It is updated with the length of the HMAC code
1024+
produced (depending on which hash was picked)
10261025

10271026
There are two utility functions provided to make using HMACs easier todo. They accept the key and information about the
10281027
message (file pointer, address in memory) and produce the HMAC result in one shot. These are useful if you want to avoid
@@ -1061,6 +1060,7 @@ \section{Hash based Message Authenication Codes}
10611060
int idx, errno;
10621061
hmac_state hmac;
10631062
unsigned char key[16], dst[MAXBLOCKSIZE];
1063+
unsigned long dstlen;
10641064
10651065
/* register SHA-1 */
10661066
if (register_hash(&sha1_desc) == -1) {
@@ -1086,10 +1086,12 @@ \section{Hash based Message Authenication Codes}
10861086
}
10871087
10881088
/* get result (presumably to use it somehow...) */
1089-
if ((errno = hmac_done(&hmac, dst)) != CRYPT_OK) {
1089+
dstlen = sizeof(dst);
1090+
if ((errno = hmac_done(&hmac, dst, &dstlen)) != CRYPT_OK) {
10901091
printf("Error finishing hmac: %s\n", error_to_string(errno));
10911092
return -1;
10921093
}
1094+
printf("The hmac is %lu bytes long\n", dstlen);
10931095
10941096
/* return */
10951097
return 0;

demos/test.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ store_tests (void)
8989
L = 0;
9090
LOAD32H (L, &buf[0]);
9191
if (L != 0x12345678UL) {
92-
printf ("LOAD/STORE32 High don't work\n");
92+
printf ("LOAD/STORE32 High don't work, %08lx\n", L);
9393
exit (-1);
9494
}
9595
LL = CONST64 (0x01020304050607);
@@ -839,7 +839,12 @@ dh_tests (void)
839839
dh_key usera, userb;
840840
clock_t t1;
841841

842-
/* if ((errnum = dh_test()) != CRYPT_OK) printf("DH Error: %s\n", error_to_string(errnum)); */
842+
printf("Testing builting DH parameters...."); fflush(stdout);
843+
if ((errnum = dh_test()) != CRYPT_OK) {
844+
printf("DH Error: %s\n", error_to_string(errnum));
845+
exit(-1);
846+
}
847+
printf("Passed.\n");
843848

844849
dh_sizes (&low, &high);
845850
printf ("DH Keys from %d to %d supported.\n", low * 8, high * 8);
@@ -916,13 +921,13 @@ dh_tests (void)
916921

917922
for (ii = 0; ii < (int) (sizeof (sizes) / sizeof (sizes[0])); ii++) {
918923
t1 = XCLOCK ();
919-
for (tt = 0; tt < 5; tt++) {
924+
for (tt = 0; tt < 25; tt++) {
920925
dh_make_key (&prng, find_prng ("yarrow"), sizes[ii], &usera);
921926
dh_free (&usera);
922927
}
923928
t1 = XCLOCK () - t1;
924929
printf ("Make dh-%d key took %f msec\n", sizes[ii] * 8,
925-
1000.0 * (((double) t1 / 5.0) / (double) XCLOCKS_PER_SEC));
930+
1000.0 * (((double) t1 / 25.0) / (double) XCLOCKS_PER_SEC));
926931
}
927932
}
928933

@@ -1359,6 +1364,12 @@ register_all_algs (void)
13591364
#ifdef SHA512
13601365
register_hash (&sha512_desc);
13611366
#endif
1367+
#ifdef RIPEMD128
1368+
register_hash (&rmd128_desc);
1369+
#endif
1370+
#ifdef RIPEMD160
1371+
register_hash (&rmd160_desc);
1372+
#endif
13621373

13631374
#ifdef YARROW
13641375
register_prng (&yarrow_desc);
@@ -1713,7 +1724,7 @@ main (void)
17131724
if ((errnum = yarrow_start (&prng)) != CRYPT_OK) {
17141725
printf ("yarrow_start: %s\n", error_to_string (errnum));
17151726
}
1716-
if ((errnum = yarrow_add_entropy ("hello", 5, &prng)) != CRYPT_OK) {
1727+
if ((errnum = yarrow_add_entropy ((unsigned char *)"hello", 5, &prng)) != CRYPT_OK) {
17171728
printf ("yarrow_add_entropy: %s\n", error_to_string (errnum));
17181729
}
17191730
if ((errnum = yarrow_ready (&prng)) != CRYPT_OK) {
@@ -1742,7 +1753,7 @@ main (void)
17421753

17431754
#ifdef KR
17441755
kr_test ();
1745-
#endif
1756+
#endif
17461757
rsa_test ();
17471758
pad_test ();
17481759
ecc_tests ();

demos/x86_prof.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ void reg_algs(void)
132132
#ifdef SHA512
133133
register_hash (&sha512_desc);
134134
#endif
135+
#ifdef RIPEMD128
136+
register_hash (&rmd128_desc);
137+
#endif
135138

136139
}
137140

0 commit comments

Comments
 (0)