Skip to content

Commit 1eed98f

Browse files
Tom St Denissjaeckel
authored andcommitted
added libtomcrypt-1.13
1 parent 2945dea commit 1eed98f

87 files changed

Lines changed: 2389 additions & 1732 deletions

File tree

Some content is hidden

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

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PROJECT_NAME = LibTomCrypt
2323
# This could be handy for archiving the generated documentation or
2424
# if some version control system is used.
2525

26-
PROJECT_NUMBER = 1.12
26+
PROJECT_NUMBER = 1.13
2727

2828
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
2929
# base path where the generated documentation will be put.

TODO

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
- document new math function count_lsb_bits
2-
- add BOOLEAN type to the ASN world
3-
4-
- ECC fixed point accelerator
5-
- look into X9.63 support [in addition to the LTC style ecc_encrypt_key() not replacing]
1+
- long term, start moving macros like CTR over to LTC_CTR to make LTC a bit more "drop-in-able".
62

changes

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
June 17th, 2005
2+
v1.13 -- Fixed to fortuna_start() to clean up state if an error occurs. Not really useful at this stage (sha256 can't fail) but useful
3+
if I ever make fortuna pluggable
4+
-- Mike Marin submitted a whole bunch of patches for fixing up the libs on traditional UNIX platforms. Go AIX! Thanks!
5+
-- One of bugs found in the multi demo highlights that at least with gcc you need to pass integers with a UL prefix to ensure
6+
they're unsigned long
7+
-- Updated the FP ECC code to use affine points. It's teh fast.
8+
-- Made it so many functions which return CRYPT_BUFFER_OVERFLOW now also indicate the required buffer size, note that not all functions
9+
do this (most do though).
10+
-- Added F8 chaining mode. It's super neato.
11+
112
May 29th, 2006
213
v1.12 -- Fixed OID encoder/decoder/length to properly handle the first two parts of an OID, matches 2002 X.690 now.
314
-- [Wesley Shields] Allows both GMP/LTM and TFM to be defined now.
@@ -1453,6 +1464,6 @@ v0.02 -- Changed RC5 to only allow 12 to 24 rounds
14531464
v0.01 -- We will call this the first version.
14541465

14551466
/* $Source: /cvs/libtom/libtomcrypt/changes,v $ */
1456-
/* $Revision: 1.206 $ */
1457-
/* $Date: 2006/05/29 11:21:25 $ */
1467+
/* $Revision: 1.213 $ */
1468+
/* $Date: 2006/06/18 01:42:59 $ */
14581469

crypt.tex

Lines changed: 15 additions & 5 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{LibTomCrypt \\ Version 1.12}
50+
\title{LibTomCrypt \\ Version 1.13}
5151
\author{Tom St Denis \\
5252
\\
5353
tomstdenis@gmail.com \\
@@ -280,8 +280,7 @@ \section{Macros}
280280

281281
\section{Functions with Variable Length Output}
282282
Certain functions such as (for example) ``rsa\_export()'' give an output that is variable length. To prevent buffer overflows you
283-
must pass it the length of the buffer\footnote{Extensive error checking is not in place but it will be in future releases so it is a good idea to follow through with these guidelines.} where
284-
the output will be stored. For example:
283+
must pass it the length of the buffer where the output will be stored. For example:
285284
\begin{small}
286285
\begin{verbatim}
287286
#include <tomcrypt.h>
@@ -313,6 +312,9 @@ \section{Functions with Variable Length Output}
313312
indicating a buffer overflow would have occurred. If the function succeeds it stores the length of the output
314313
back into ``x'' so that the calling application will know how many bytes were used.
315314

315+
As of v1.13, most functions will update your length on failure to indicate the size required by the function. Not all functions
316+
support this so please check the source before you rely on it doing that.
317+
316318
\section{Functions that need a PRNG}
317319
\index{Pseudo Random Number Generator} \index{PRNG}
318320
Certain functions such as ``rsa\_make\_key()'' require a Pseudo Random Number Generator (PRNG). These functions do not setup
@@ -5018,6 +5020,14 @@ \section{BigNum Math Descriptors}
50185020
*/
50195021
int (*mulmod)(void *a, void *b, void *c, void *d);
50205022
5023+
/** Modular squaring
5024+
@param a The first source
5025+
@param b The modulus
5026+
@param c The destination (a*a mod b)
5027+
@return CRYPT_OK on success
5028+
*/
5029+
int (*sqrmod)(void *a, void *b, void *c);
5030+
50215031
/** Modular inversion
50225032
@param a The value to invert
50235033
@param b The modulus
@@ -5231,5 +5241,5 @@ \subsection{RSA Functions}
52315241
\end{document}
52325242
52335243
% $Source: /cvs/libtom/libtomcrypt/crypt.tex,v $
5234-
% $Revision: 1.71 $
5235-
% $Date: 2006/05/29 11:19:08 $
5244+
% $Revision: 1.74 $
5245+
% $Date: 2006/06/18 01:35:41 $

demos/multi.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,87 +13,87 @@ int main(void)
1313

1414
/* HASH testing */
1515
len = sizeof(buf[0]);
16-
hash_memory(find_hash("sha256"), "hello", 5, buf[0], &len);
16+
hash_memory(find_hash("sha256"), (unsigned char*)"hello", 5, buf[0], &len);
1717
len2 = sizeof(buf[0]);
18-
hash_memory_multi(find_hash("sha256"), buf[1], &len2, "hello", 5, NULL);
18+
hash_memory_multi(find_hash("sha256"), buf[1], &len2, (unsigned char*)"hello", 5, NULL);
1919
if (len != len2 || memcmp(buf[0], buf[1], len)) {
2020
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
2121
return EXIT_FAILURE;
2222
}
2323
len2 = sizeof(buf[0]);
24-
hash_memory_multi(find_hash("sha256"), buf[1], &len2, "he", 2, "llo", 3, NULL);
24+
hash_memory_multi(find_hash("sha256"), buf[1], &len2, (unsigned char*)"he", 2UL, "llo", 3UL, NULL, 0);
2525
if (len != len2 || memcmp(buf[0], buf[1], len)) {
2626
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
2727
return EXIT_FAILURE;
2828
}
2929
len2 = sizeof(buf[0]);
30-
hash_memory_multi(find_hash("sha256"), buf[1], &len2, "h", 1, "e", 1, "l", 1, "l", 1, "o", 1, NULL);
30+
hash_memory_multi(find_hash("sha256"), buf[1], &len2, (unsigned char*)"h", 1UL, "e", 1UL, "l", 1UL, "l", 1UL, "o", 1UL, NULL);
3131
if (len != len2 || memcmp(buf[0], buf[1], len)) {
3232
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
3333
return EXIT_FAILURE;
3434
}
3535

3636
/* HMAC */
3737
len = sizeof(buf[0]);
38-
hmac_memory(find_hash("sha256"), key, 16, "hello", 5, buf[0], &len);
38+
hmac_memory(find_hash("sha256"), key, 16, (unsigned char*)"hello", 5, buf[0], &len);
3939
len2 = sizeof(buf[0]);
40-
hmac_memory_multi(find_hash("sha256"), key, 16, buf[1], &len2, "hello", 5, NULL);
40+
hmac_memory_multi(find_hash("sha256"), key, 16, buf[1], &len2, (unsigned char*)"hello", 5UL, NULL);
4141
if (len != len2 || memcmp(buf[0], buf[1], len)) {
4242
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
4343
return EXIT_FAILURE;
4444
}
4545
len2 = sizeof(buf[0]);
46-
hmac_memory_multi(find_hash("sha256"), key, 16, buf[1], &len2, "he", 2, "llo", 3, NULL);
46+
hmac_memory_multi(find_hash("sha256"), key, 16, buf[1], &len2, (unsigned char*)"he", 2UL, "llo", 3UL, NULL);
4747
if (len != len2 || memcmp(buf[0], buf[1], len)) {
4848
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
4949
return EXIT_FAILURE;
5050
}
5151
len2 = sizeof(buf[0]);
52-
hmac_memory_multi(find_hash("sha256"), key, 16, buf[1], &len2, "h", 1, "e", 1, "l", 1, "l", 1, "o", 1, NULL);
52+
hmac_memory_multi(find_hash("sha256"), key, 16, buf[1], &len2, (unsigned char*)"h", 1UL, "e", 1UL, "l", 1UL, "l", 1UL, "o", 1UL, NULL);
5353
if (len != len2 || memcmp(buf[0], buf[1], len)) {
5454
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
5555
return EXIT_FAILURE;
5656
}
5757

5858
/* OMAC */
5959
len = sizeof(buf[0]);
60-
omac_memory(find_cipher("aes"), key, 16, "hello", 5, buf[0], &len);
60+
omac_memory(find_cipher("aes"), key, 16, (unsigned char*)"hello", 5, buf[0], &len);
6161
len2 = sizeof(buf[0]);
62-
omac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, "hello", 5, NULL);
62+
omac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"hello", 5UL, NULL);
6363
if (len != len2 || memcmp(buf[0], buf[1], len)) {
6464
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
6565
return EXIT_FAILURE;
6666
}
6767
len2 = sizeof(buf[0]);
68-
omac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, "he", 2, "llo", 3, NULL);
68+
omac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"he", 2UL, "llo", 3UL, NULL);
6969
if (len != len2 || memcmp(buf[0], buf[1], len)) {
7070
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
7171
return EXIT_FAILURE;
7272
}
7373
len2 = sizeof(buf[0]);
74-
omac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, "h", 1, "e", 1, "l", 1, "l", 1, "o", 1, NULL);
74+
omac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"h", 1UL, "e", 1UL, "l", 1UL, "l", 1UL, "o", 1UL, NULL);
7575
if (len != len2 || memcmp(buf[0], buf[1], len)) {
7676
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
7777
return EXIT_FAILURE;
7878
}
7979

8080
/* PMAC */
8181
len = sizeof(buf[0]);
82-
pmac_memory(find_cipher("aes"), key, 16, "hello", 5, buf[0], &len);
82+
pmac_memory(find_cipher("aes"), key, 16, (unsigned char*)"hello", 5, buf[0], &len);
8383
len2 = sizeof(buf[0]);
84-
pmac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, "hello", 5, NULL);
84+
pmac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"hello", 5, NULL);
8585
if (len != len2 || memcmp(buf[0], buf[1], len)) {
8686
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
8787
return EXIT_FAILURE;
8888
}
8989
len2 = sizeof(buf[0]);
90-
pmac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, "he", 2, "llo", 3, NULL);
90+
pmac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"he", 2UL, "llo", 3UL, NULL);
9191
if (len != len2 || memcmp(buf[0], buf[1], len)) {
9292
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
9393
return EXIT_FAILURE;
9494
}
9595
len2 = sizeof(buf[0]);
96-
pmac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, "h", 1, "e", 1, "l", 1, "l", 1, "o", 1, NULL);
96+
pmac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"h", 1UL, "e", 1UL, "l", 1UL, "l", 1UL, "o", 1UL, NULL);
9797
if (len != len2 || memcmp(buf[0], buf[1], len)) {
9898
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
9999
return EXIT_FAILURE;

demos/small.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// small demo app that just includes a cipher/hash/prng
1+
/* small demo app that just includes a cipher/hash/prng */
22
#include <tomcrypt.h>
33

44
int main(void)

demos/timing.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ reg_algs();
1616
extern ltc_math_descriptor EXT_MATH_LIB;
1717
ltc_mp = EXT_MATH_LIB;
1818
#endif
19+
time_cipher();
20+
time_hash();
21+
time_encmacs();
22+
time_rsa();
23+
time_ecc();
24+
time_ecc();
25+
return 0;
1926
time_keysched();
2027
time_cipher();
2128
time_cipher2();

demos/tv_gen.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,9 +685,9 @@ void ecc_gen(void)
685685

686686
while (mp_cmp(k, order) == LTC_MP_LT) {
687687
ltc_mp.ecc_ptmul(k, G, R, modulus, 1);
688-
mp_tohex(k, str); fprintf(out, "%s, ", str);
689-
mp_tohex(R->x, str); fprintf(out, "%s, ", str);
690-
mp_tohex(R->y, str); fprintf(out, "%s\n", str);
688+
mp_tohex(k, (char*)str); fprintf(out, "%s, ", (char*)str);
689+
mp_tohex(R->x, (char*)str); fprintf(out, "%s, ", (char*)str);
690+
mp_tohex(R->y, (char*)str); fprintf(out, "%s\n", (char*)str);
691691
mp_mul_d(k, 3, k);
692692
}
693693
}

doc/crypt.pdf

708 Bytes
Binary file not shown.

makefile

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Modified by Clay Culver
55

66
# The version
7-
VERSION=1.12
7+
VERSION=1.13
88

99
# Compiler and Linker Names
1010
#CC=gcc
@@ -150,18 +150,19 @@ src/modes/cfb/cfb_getiv.o src/modes/cfb/cfb_setiv.o src/modes/cfb/cfb_start.o \
150150
src/modes/ctr/ctr_decrypt.o src/modes/ctr/ctr_done.o src/modes/ctr/ctr_encrypt.o \
151151
src/modes/ctr/ctr_getiv.o src/modes/ctr/ctr_setiv.o src/modes/ctr/ctr_start.o \
152152
src/modes/ecb/ecb_decrypt.o src/modes/ecb/ecb_done.o src/modes/ecb/ecb_encrypt.o \
153-
src/modes/ecb/ecb_start.o src/modes/lrw/lrw_decrypt.o src/modes/lrw/lrw_done.o \
154-
src/modes/lrw/lrw_encrypt.o src/modes/lrw/lrw_getiv.o src/modes/lrw/lrw_process.o \
155-
src/modes/lrw/lrw_setiv.o src/modes/lrw/lrw_start.o src/modes/lrw/lrw_test.o \
156-
src/modes/ofb/ofb_decrypt.o src/modes/ofb/ofb_done.o src/modes/ofb/ofb_encrypt.o \
157-
src/modes/ofb/ofb_getiv.o src/modes/ofb/ofb_setiv.o src/modes/ofb/ofb_start.o \
158-
src/pk/asn1/der/bit/der_decode_bit_string.o src/pk/asn1/der/bit/der_encode_bit_string.o \
159-
src/pk/asn1/der/bit/der_length_bit_string.o src/pk/asn1/der/boolean/der_decode_boolean.o \
160-
src/pk/asn1/der/boolean/der_encode_boolean.o src/pk/asn1/der/boolean/der_length_boolean.o \
161-
src/pk/asn1/der/choice/der_decode_choice.o src/pk/asn1/der/ia5/der_decode_ia5_string.o \
162-
src/pk/asn1/der/ia5/der_encode_ia5_string.o src/pk/asn1/der/ia5/der_length_ia5_string.o \
163-
src/pk/asn1/der/integer/der_decode_integer.o src/pk/asn1/der/integer/der_encode_integer.o \
164-
src/pk/asn1/der/integer/der_length_integer.o \
153+
src/modes/ecb/ecb_start.o src/modes/f8/f8_decrypt.o src/modes/f8/f8_done.o src/modes/f8/f8_encrypt.o \
154+
src/modes/f8/f8_getiv.o src/modes/f8/f8_setiv.o src/modes/f8/f8_start.o src/modes/f8/f8_test_mode.o \
155+
src/modes/lrw/lrw_decrypt.o src/modes/lrw/lrw_done.o src/modes/lrw/lrw_encrypt.o \
156+
src/modes/lrw/lrw_getiv.o src/modes/lrw/lrw_process.o src/modes/lrw/lrw_setiv.o \
157+
src/modes/lrw/lrw_start.o src/modes/lrw/lrw_test.o src/modes/ofb/ofb_decrypt.o src/modes/ofb/ofb_done.o \
158+
src/modes/ofb/ofb_encrypt.o src/modes/ofb/ofb_getiv.o src/modes/ofb/ofb_setiv.o \
159+
src/modes/ofb/ofb_start.o src/pk/asn1/der/bit/der_decode_bit_string.o \
160+
src/pk/asn1/der/bit/der_encode_bit_string.o src/pk/asn1/der/bit/der_length_bit_string.o \
161+
src/pk/asn1/der/boolean/der_decode_boolean.o src/pk/asn1/der/boolean/der_encode_boolean.o \
162+
src/pk/asn1/der/boolean/der_length_boolean.o src/pk/asn1/der/choice/der_decode_choice.o \
163+
src/pk/asn1/der/ia5/der_decode_ia5_string.o src/pk/asn1/der/ia5/der_encode_ia5_string.o \
164+
src/pk/asn1/der/ia5/der_length_ia5_string.o src/pk/asn1/der/integer/der_decode_integer.o \
165+
src/pk/asn1/der/integer/der_encode_integer.o src/pk/asn1/der/integer/der_length_integer.o \
165166
src/pk/asn1/der/object_identifier/der_decode_object_identifier.o \
166167
src/pk/asn1/der/object_identifier/der_encode_object_identifier.o \
167168
src/pk/asn1/der/object_identifier/der_length_object_identifier.o \
@@ -366,5 +367,5 @@ zipup: no_oops docs
366367

367368

368369
# $Source: /cvs/libtom/libtomcrypt/makefile,v $
369-
# $Revision: 1.123 $
370-
# $Date: 2006/05/25 10:33:01 $
370+
# $Revision: 1.126 $
371+
# $Date: 2006/06/16 23:52:08 $

0 commit comments

Comments
 (0)