Skip to content

Commit 1a11416

Browse files
Tom St Denissjaeckel
authored andcommitted
added libtomcrypt-0.97
1 parent 3fe312c commit 1a11416

89 files changed

Lines changed: 2022 additions & 2634 deletions

Some content is hidden

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

cast5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ int cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_
418418

419419
/* extend the key as required */
420420
zeromem(buf, sizeof(buf));
421-
memcpy(buf, key, (size_t)keylen);
421+
XMEMCPY(buf, key, (size_t)keylen);
422422

423423
/* load and start the awful looking network */
424424
for (y = 0; y < 4; y++) {

cbc_getiv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ int cbc_getiv(unsigned char *IV, unsigned long *len, symmetric_CBC *cbc)
2121
if ((unsigned long)cbc->blocklen > *len) {
2222
return CRYPT_BUFFER_OVERFLOW;
2323
}
24-
memcpy(IV, cbc->IV, cbc->blocklen);
24+
XMEMCPY(IV, cbc->IV, cbc->blocklen);
2525
*len = cbc->blocklen;
2626

2727
return CRYPT_OK;

cbc_setiv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int cbc_setiv(const unsigned char *IV, unsigned long len, symmetric_CBC *cbc)
2020
if (len != (unsigned long)cbc->blocklen) {
2121
return CRYPT_INVALID_ARG;
2222
}
23-
memcpy(cbc->IV, IV, len);
23+
XMEMCPY(cbc->IV, IV, len);
2424
return CRYPT_OK;
2525
}
2626

cfb_getiv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ int cfb_getiv(unsigned char *IV, unsigned long *len, symmetric_CFB *cfb)
2121
if ((unsigned long)cfb->blocklen > *len) {
2222
return CRYPT_BUFFER_OVERFLOW;
2323
}
24-
memcpy(IV, cfb->IV, cfb->blocklen);
24+
XMEMCPY(IV, cfb->IV, cfb->blocklen);
2525
*len = cfb->blocklen;
2626

2727
return CRYPT_OK;

changes

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
June 19th, 2004
2+
v0.97 -- Removed spurious unused files [arrg!]
3+
-- Patched buffer overflow in tim_exptmod()
4+
-- Fixed buffer overrun bug in pkcs_1_v15_es_decode()
5+
-- Reduced stack usage in PKCS #1 v2.0 padding functions (by several KBs)
6+
-- Removed useless extern's that were an artifact from the project start... ;-)
7+
-- Replaced memcpy/memset with XMEMCPY and XMEMSET for greater flexibility
8+
-- fixed bugs in hmac_done()/hmac_init()/[various others()] where I didn't trap errors
9+
-- Reduced stack usage in OMAC/PMAC/HMAC/EAX/OCB/PKCS#5 by mallocing any significant sized
10+
arrays (e.g. > 100 bytes or so). Only in non-critical functions (e.g. eax_init())
11+
-- "Zhi Chen" <zhi@massiveincorporated.com> pointed out that rsa_decrypt_key() requires
12+
an incorrect output size (too large). Fixed.
13+
-- Added a "pretty" target to the GCC makefile. Requires PERL. It is NEAT!
14+
-- Minor updates to ch1 of the manual.
15+
-- Cleaned up the indentation and added comments to rsa_make_key(), rsa_exptmod() and
16+
rsa_verify_hash()
17+
-- Updated makefile.icc so the "install" target would work ;-)
18+
-- Removed demos/test.c [deprecated from demos/test/test.c]
19+
-- Changed MAXBLOCKSIZE from 128 to 64 to reflect the true size...
20+
121
May 30th, 2004
222
v0.96 -- Removed GF and Keyring code
323
-- Extended OAEP decoder to distinguish better [and use a more uniform API]

crypt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
%PDF-1.3
2+
%�쏢
3+
3 0 obj
4+
<< /Type /Pages /Kids [
5+
] /Count 0
6+
>>
7+
endobj
8+
1 0 obj
9+
<</Type /Catalog /Pages 3 0 R
10+
>>
11+
endobj
12+
2 0 obj
13+
<</Producer(ESP Ghostscript 7.07)>>endobj
14+
xref
15+
0 4
16+
0000000000 65535 f
17+
0000000068 00000 n
18+
0000000116 00000 n
19+
0000000015 00000 n
20+
trailer
21+
<< /Size 4 /Root 1 0 R /Info 2 0 R
22+
>>
23+
startxref
24+
166
25+
%%EOF

crypt.tex

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
\documentclass[b5paper]{book}
1+
\documentclass[a4paper]{book}
22
\usepackage{hyperref}
33
\usepackage{makeidx}
44
\usepackage{amssymb}
@@ -47,20 +47,15 @@
4747
\def\gap{\vspace{0.5ex}}
4848
\makeindex
4949
\begin{document}
50-
\title{A Tiny Crypto Library, \\ LibTomCrypt \\ Version 0.96}
50+
\title{LibTomCrypt \\ Version 0.97}
5151
\author{Tom St Denis \\
5252
\\
5353
tomstdenis@iahu.ca \\
54-
http://libtomcrypt.org \\ \\
55-
Phone: 1-613-836-3160\\
56-
111 Banning Rd \\
57-
Kanata, Ontario \\
58-
K2L 1C3 \\
59-
Canada
54+
http://libtomcrypt.org
6055
}
6156
\maketitle
6257
This text and source code library are both hereby placed in the public domain. This book has been
63-
formatted for B5 [176x250] paper using the \LaTeX{} {\em book} macro package.
58+
formatted for A4 paper using the \LaTeX{} {\em book} macro package.
6459

6560
\vspace{10cm}
6661

@@ -70,7 +65,15 @@
7065

7166
Tom St Denis,
7267

73-
Ontario, Canada
68+
Phone: 1-613-836-3160
69+
70+
111 Banning Rd
71+
72+
Kanata, Ontario
73+
74+
K2L 1C3
75+
76+
Canada
7477
\end{flushright}
7578
\newpage
7679
\tableofcontents
@@ -182,15 +185,15 @@ \section{License}
182185
library.
183186

184187
``rc2.c'' is based on publicly available code that is not attributed to a person from the given source. ``safer.c''
185-
was written by Richard De Moliner (demoliner@isi.ee.ethz.ch) and is public domain.
188+
was written by Richard De Moliner (demoliner@isi.ee.ethz.ch) and seems to be free for use.
186189

187190
The project is hereby released as public domain.
188191

189192
\section{Patent Disclosure}
190193

191194
The author (Tom St Denis) is not a patent lawyer so this section is not to be treated as legal advice. To the best
192195
of the authors knowledge the only patent related issues within the library are the RC5 and RC6 symmetric block ciphers.
193-
They can be removed from a build by simply commenting out the two appropriate lines in the makefile script. The rest
196+
They can be removed from a build by simply commenting out the two appropriate lines in ``mycrypt\_custom.h''. The rest
194197
of the ciphers and hashes are patent free or under patents that have since expired.
195198

196199
The RC2 and RC4 symmetric ciphers are not under patents but are under trademark regulations. This means you can use
@@ -212,11 +215,11 @@ \section{Building against the library}
212215

213216
In the recent versions the build steps have changed. The build options are now stored in ``mycrypt\_custom.h'' and
214217
no longer in the makefile. If you change a build option in that file you must re-build the library from clean to
215-
ensure the build is intact. The perl script ``config.pl'' will help setup the custom header and a custom makefile
216-
if you want one (the provided ``makefile'' will work with custom configs).
218+
ensure the build is intact.
217219

218220
\section{Thanks}
219-
I would like to give thanks to the following people (in no particular order) for helping me develop this project:
221+
I would like to give thanks to the following people (in no particular order) for helping me develop this project from
222+
early on:
220223
\begin{enumerate}
221224
\item Richard van de Laarschot
222225
\item Richard Heathfield
@@ -233,6 +236,10 @@ \section{Thanks}
233236
\item Christopher Imes
234237
\end{enumerate}
235238

239+
There have been quite a few other people as well. Please check the change log to see who else has contributed from
240+
time to time.
241+
242+
236243
\chapter{The Application Programming Interface (API)}
237244
\section{Introduction}
238245
\index{CRYPT\_ERROR} \index{CRYPT\_OK}
@@ -581,9 +588,9 @@ \subsection{Notes}
581588
\begin{tabular}{|l|l|l|}
582589
\hline TWOFISH\_SMALL & TWOFISH\_TABLES & Speed and Memory (per key) \\
583590
\hline undefined & undefined & Very fast, 4.2KB of ram. \\
584-
\hline undefined & defined & As above, faster keysetup, larger code (1KB more). \\
591+
\hline undefined & defined & Faster keysetup, larger code. \\
585592
\hline defined & undefined & Very slow, 0.2KB of ram. \\
586-
\hline defined & defined & Somewhat faster, 0.2KB of ram, larger code. \\
593+
\hline defined & defined & Faster, 0.2KB of ram, larger code. \\
587594
\hline
588595
\end{tabular}
589596
\end{center}
@@ -615,7 +622,8 @@ \subsection{Notes}
615622
}
616623
617624
/* generic call to function (assuming the key in key[] was already setup) */
618-
if ((err = cipher_descriptor[find_cipher("blowfish")].setup(key, 8, 0, &skey)) != CRYPT_OK) {
625+
if ((err = cipher_descriptor[find_cipher("blowfish")].setup(key, 8, 0, &skey)) !=
626+
CRYPT_OK) {
619627
printf("Error setting up Blowfish: %s\n", error_to_string(err));
620628
return -1;
621629
}
@@ -820,12 +828,13 @@ \subsection{Implementation}
820828
/* somehow fill out key and IV */
821829
822830
/* start up CTR mode */
823-
if ((err = ctr_start(find_cipher("twofish"), /* index of desired cipher */
824-
IV, /* the initial vector */
825-
key, /* the secret key */
826-
16, /* length of secret key (16 bytes, 128 bits) */
827-
0, /* 0 == default # of rounds */
828-
&ctr) /* where to store initialized CTR state */
831+
if ((err = ctr_start(
832+
find_cipher("twofish"), /* index of desired cipher */
833+
IV, /* the initial vector */
834+
key, /* the secret key */
835+
16, /* length of secret key (16 bytes, 128 bits) */
836+
0, /* 0 == default # of rounds */
837+
&ctr) /* where to store initialized CTR state */
829838
) != CRYPT_OK) {
830839
printf("ctr_start error: %s\n", error_to_string(err));
831840
return -1;

crypt_register_cipher.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int register_cipher(const struct _cipher_descriptor *cipher)
2626
/* find a blank spot */
2727
for (x = 0; x < TAB_SIZE; x++) {
2828
if (cipher_descriptor[x].name == NULL) {
29-
memcpy(&cipher_descriptor[x], cipher, sizeof(struct _cipher_descriptor));
29+
XMEMCPY(&cipher_descriptor[x], cipher, sizeof(struct _cipher_descriptor));
3030
return x;
3131
}
3232
}

crypt_register_hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int register_hash(const struct _hash_descriptor *hash)
2626
/* find a blank spot */
2727
for (x = 0; x < TAB_SIZE; x++) {
2828
if (hash_descriptor[x].name == NULL) {
29-
memcpy(&hash_descriptor[x], hash, sizeof(struct _hash_descriptor));
29+
XMEMCPY(&hash_descriptor[x], hash, sizeof(struct _hash_descriptor));
3030
return x;
3131
}
3232
}

crypt_register_prng.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int register_prng(const struct _prng_descriptor *prng)
2626
/* find a blank spot */
2727
for (x = 0; x < TAB_SIZE; x++) {
2828
if (prng_descriptor[x].name == NULL) {
29-
memcpy(&prng_descriptor[x], prng, sizeof(struct _prng_descriptor));
29+
XMEMCPY(&prng_descriptor[x], prng, sizeof(struct _prng_descriptor));
3030
return x;
3131
}
3232
}

0 commit comments

Comments
 (0)