Skip to content

Commit a3ce807

Browse files
Tom St Denissjaeckel
authored andcommitted
added libtomcrypt-1.09
1 parent 1eeff0b commit a3ce807

55 files changed

Lines changed: 2480 additions & 126 deletions

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.08
26+
PROJECT_NUMBER = 1.09
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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

changes

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
January 26th, 2006
2+
v1.09 -- Added missing doxygen comments to some of the ASN.1 routines
3+
-- Added "easy button" define LTC_EASY and LTC will build with a subset of all the algos. Reduces build times for typical
4+
configurations. Tunable [see tomcrypt_custom.h]
5+
-- Added some error detection to reg_algs() of the testprof.a library to detect when the PRNG is not setup correctly (took me 10 mins to figure out, PITA!)
6+
-- Similar fixes to timing demo (MD5 not defined when EASY is defined)
7+
-- Added the NLS enc+mac stream cipher from QUALCOMM, disabled for this release, waiting on test vectors
8+
-- Finally added an auto-update script for the makefiles. So when I add new files/dirs it can automatically fix up the makefiles [all four of them...]
9+
-- Added LRW to the list of cipher modes supported
10+
-- cleaned up ciphers definitions to remove cbc/cfb/ofb/ctr/etc from the namespace when not used.
11+
112
November 24th, 2005
213
v1.08 -- Added SET and SET OF support to the ASN.1 side
314
-- Fixed up X macros, added QSORT to the mix [thanks SET/SETOF]
@@ -1394,6 +1405,6 @@ v0.02 -- Changed RC5 to only allow 12 to 24 rounds
13941405
v0.01 -- We will call this the first version.
13951406

13961407
/* $Source: /cvs/libtom/libtomcrypt/changes,v $ */
1397-
/* $Revision: 1.161 $ */
1398-
/* $Date: 2005/11/24 03:30:18 $ */
1408+
/* $Revision: 1.168 $ */
1409+
/* $Date: 2006/01/26 18:15:51 $ */
13991410

crypt.tex

Lines changed: 108 additions & 3 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.08}
50+
\title{LibTomCrypt \\ Version 1.09}
5151
\author{Tom St Denis \\
5252
\\
5353
tomstdenis@gmail.com \\
@@ -520,6 +520,18 @@ \section{The Cipher Descriptors}
520520
unsigned char *ct,
521521
unsigned long blocks, unsigned char *IV,
522522
int mode, symmetric_key *skey);
523+
int (*accel_lrw_encrypt)(const unsigned char *pt,
524+
unsigned char *ct,
525+
unsigned long blocks,
526+
unsigned char *IV,
527+
const unsigned char *tweak,
528+
symmetric_key *skey);
529+
int (*accel_lrw_decrypt)(const unsigned char *ct,
530+
unsigned char *pt,
531+
unsigned long blocks,
532+
unsigned char *IV,
533+
const unsigned char *tweak,
534+
symmetric_key *skey);
523535
int (*accel_ccm_memory)(
524536
const unsigned char *key, unsigned long keylen,
525537
symmetric_key *uskey,
@@ -938,6 +950,61 @@ \subsection{Examples}
938950
\end{verbatim}
939951
\end{small}
940952

953+
\subsection{LRW Mode}
954+
955+
LRW mode is a cipher mode which is meant for indexed encryption like used to handle storage media. It is meant to have efficient seeking and overcome the
956+
security problems of ECB mode while not increasing the storage requirements. It is used much like any other chaining mode except with two key differences.
957+
958+
The key is specified as two strings the first key $K_1$ is the (normally AES) key and can be any length (typically 16, 24 or 32 octets long). The second key
959+
$K_2$ is the ``tweak'' key and is always 16 octets long. The tweak value is \textbf{NOT} a nonce or IV value it must be random and secret.
960+
961+
To initialize LRW mode use:
962+
963+
\index{lrw\_start()}
964+
\begin{verbatim}
965+
int lrw_start( int cipher,
966+
const unsigned char *IV,
967+
const unsigned char *key, int keylen,
968+
const unsigned char *tweak,
969+
int num_rounds,
970+
symmetric_LRW *lrw);
971+
\end{verbatim}
972+
973+
This will initialize the LRW context with the given (16 octet) ``IV'', cipher $K_1$ ``key'' of length ``keylen'' octets and the (16 octet) $K_2$ ``tweak''.
974+
While LRW was specified to be used only with AES, LibTomCrypt will allow any 128--bit block cipher to be specified as indexed by ``cipher''. The
975+
number of rounds for the block cipher ``num\_rounds'' can be 0 to use the default number of rounds for the given cipher.
976+
977+
To process data use the following functions:
978+
979+
\index{lrw\_encrypt()} \index{lrw\_decrypt()}
980+
\begin{verbatim}
981+
int lrw_encrypt(const unsigned char *pt, unsigned char *ct,
982+
unsigned long len, symmetric_LRW *lrw);
983+
int lrw_decrypt(const unsigned char *ct, unsigned char *pt,
984+
unsigned long len, symmetric_LRW *lrw);
985+
\end{verbatim}
986+
987+
These will encrypt (or decrypt) the plaintext to the ciphertext buffer (or vice versa). The length is specified by ``len'' in octets but must be a multiple
988+
of 16.
989+
990+
To manipulate the IV use the following functions:
991+
992+
\index{lrw\_getiv()} \index{lrw\_setiv()}
993+
\begin{verbatim}
994+
int lrw_getiv(unsigned char *IV, unsigned long *len, symmetric_LRW *lrw);
995+
int lrw_setiv(const unsigned char *IV, unsigned long len, symmetric_LRW *lrw);
996+
\end{verbatim}
997+
998+
These will get or set the 16--octet IV. Note that setting the IV is the same as ``seeking'' and unlike other modes is not a free operation. It requires
999+
updating the entire tweak which is slower than sequential use. Avoid seeking excessively in performance constrained code.
1000+
1001+
To terminate the LRW state use the following:
1002+
1003+
\index{lrw\_done()}
1004+
\begin{verbatim}
1005+
int lrw_done(symmetric_LRW *lrw);
1006+
\end{verbatim}
1007+
9411008
\section{Encrypt and Authenticate Modes}
9421009

9431010
\subsection{EAX Mode}
@@ -4306,6 +4373,32 @@ \section{Ciphers}
43064373
unsigned long blocks, unsigned char *IV,
43074374
int mode, symmetric_key *skey);
43084375
4376+
/** Accelerated LRW
4377+
@param pt Plaintext
4378+
@param ct Ciphertext
4379+
@param blocks The number of complete blocks to process
4380+
@param IV The initial value (input/output)
4381+
@param tweak The LRW tweak
4382+
@param skey The scheduled key context
4383+
@return CRYPT_OK if successful
4384+
*/
4385+
int (*accel_lrw_encrypt)(const unsigned char *pt, unsigned char *ct,
4386+
unsigned long blocks, unsigned char *IV,
4387+
const unsigned char *tweak, symmetric_key *skey);
4388+
4389+
/** Accelerated LRW
4390+
@param ct Ciphertext
4391+
@param pt Plaintext
4392+
@param blocks The number of complete blocks to process
4393+
@param IV The initial value (input/output)
4394+
@param tweak The LRW tweak
4395+
@param skey The scheduled key context
4396+
@return CRYPT_OK if successful
4397+
*/
4398+
int (*accel_lrw_decrypt)(const unsigned char *ct, unsigned char *pt,
4399+
unsigned long blocks, unsigned char *IV,
4400+
const unsigned char *tweak, symmetric_key *skey);
4401+
43094402
/** Accelerated CCM packet (one-shot)
43104403
@param key The secret key to use
43114404
@param keylen The length of the secret key (octets)
@@ -4432,6 +4525,18 @@ \subsubsection{Accelerated CTR}
44324525
44334526
The accelerator will only be used to encrypt whole blocks. Partial blocks are always handled in software.
44344527
4528+
\subsubsection{Accelerated LRW}
4529+
These functions are meant for accelerated LRW. They process blocks of input in lengths of multiples of 16 octets. They must accept the ``IV'' and ``tweak''
4530+
state variables and updated them prior to returning. Note that you may want to disable \textbf{LRW\_TABLES} in ``tomcrypt\_custom.h'' if you intend
4531+
to use accelerators for LRW.
4532+
4533+
While both encrypt and decrypt accelerators are not required it is suggested as it makes lrw\_setiv() more efficient.
4534+
4535+
Note that calling lrw\_done() will only invoke the cipher\_descriptor[].done() function on the ``symmetric\_key'' parameter of the LRW state. That means
4536+
if your device requires any (LRW specific) resources you should free them in your ciphers() done function. The simplest way to think of it is to write
4537+
the plugin solely to do LRW with the cipher. That way cipher\_descriptor[].setup() means to init LRW resources and cipher\_descriptor[].done() means to
4538+
free them.
4539+
44354540
\subsubsection{Accelerated CCM}
44364541
This function is meant for accelerated CCM encryption or decryption. It processes the entire packet in one call. You can optimize the work flow somewhat
44374542
by allowing the caller to call the setup() function first to schedule the key if your accelerator cannot do the key schedule on the fly (for instance). This
@@ -5076,5 +5181,5 @@ \subsection{RSA Functions}
50765181
\end{document}
50775182
50785183
% $Source: /cvs/libtom/libtomcrypt/crypt.tex,v $
5079-
% $Revision: 1.59 $
5080-
% $Date: 2005/11/24 01:53:18 $
5184+
% $Revision: 1.62 $
5185+
% $Date: 2006/01/26 18:29:02 $

doc/crypt.pdf

6.25 KB
Binary file not shown.

filter.pl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/perl
2+
3+
# we want to filter every between START_INS and END_INS out and then insert crap from another file (this is fun)
4+
5+
$dst = shift;
6+
$ins = shift;
7+
8+
open(SRC,"<$dst");
9+
open(INS,"<$ins");
10+
open(TMP,">tmp.delme");
11+
12+
$l = 0;
13+
while (<SRC>) {
14+
if ($_ =~ /START_INS/) {
15+
print TMP $_;
16+
$l = 1;
17+
while (<INS>) {
18+
print TMP $_;
19+
}
20+
close INS;
21+
} elsif ($_ =~ /END_INS/) {
22+
print TMP $_;
23+
$l = 0;
24+
} elsif ($l == 0) {
25+
print TMP $_;
26+
}
27+
}
28+
29+
close TMP;
30+
close SRC;

makefile

Lines changed: 17 additions & 13 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.08
7+
VERSION=1.09
88

99
# Compiler and Linker Names
1010
#CC=gcc
@@ -111,8 +111,9 @@ src/encauth/eax/eax_decrypt.o src/encauth/eax/eax_decrypt_verify_memory.o src/en
111111
src/encauth/eax/eax_encrypt.o src/encauth/eax/eax_encrypt_authenticate_memory.o \
112112
src/encauth/eax/eax_init.o src/encauth/eax/eax_test.o src/encauth/gcm/gcm_add_aad.o \
113113
src/encauth/gcm/gcm_add_iv.o src/encauth/gcm/gcm_done.o src/encauth/gcm/gcm_gf_mult.o \
114-
src/encauth/gcm/gcm_init.o src/encauth/gcm/gcm_memory.o src/encauth/gcm/gcm_process.o \
115-
src/encauth/gcm/gcm_reset.o src/encauth/gcm/gcm_test.o src/encauth/ocb/ocb_decrypt.o \
114+
src/encauth/gcm/gcm_init.o src/encauth/gcm/gcm_memory.o src/encauth/gcm/gcm_mult_h.o \
115+
src/encauth/gcm/gcm_process.o src/encauth/gcm/gcm_reset.o src/encauth/gcm/gcm_test.o \
116+
src/encauth/nls/nls_memory.o src/encauth/nls/nlsfast.o src/encauth/ocb/ocb_decrypt.o \
116117
src/encauth/ocb/ocb_decrypt_verify_memory.o src/encauth/ocb/ocb_done_decrypt.o \
117118
src/encauth/ocb/ocb_done_encrypt.o src/encauth/ocb/ocb_encrypt.o \
118119
src/encauth/ocb/ocb_encrypt_authenticate_memory.o src/encauth/ocb/ocb_init.o src/encauth/ocb/ocb_ntz.o \
@@ -150,14 +151,16 @@ src/modes/cfb/cfb_getiv.o src/modes/cfb/cfb_setiv.o src/modes/cfb/cfb_start.o \
150151
src/modes/ctr/ctr_decrypt.o src/modes/ctr/ctr_done.o src/modes/ctr/ctr_encrypt.o \
151152
src/modes/ctr/ctr_getiv.o src/modes/ctr/ctr_setiv.o src/modes/ctr/ctr_start.o \
152153
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/ofb/ofb_decrypt.o src/modes/ofb/ofb_done.o \
154-
src/modes/ofb/ofb_encrypt.o src/modes/ofb/ofb_getiv.o src/modes/ofb/ofb_setiv.o \
155-
src/modes/ofb/ofb_start.o src/pk/asn1/der/bit/der_decode_bit_string.o \
156-
src/pk/asn1/der/bit/der_encode_bit_string.o src/pk/asn1/der/bit/der_length_bit_string.o \
157-
src/pk/asn1/der/choice/der_decode_choice.o src/pk/asn1/der/ia5/der_decode_ia5_string.o \
158-
src/pk/asn1/der/ia5/der_encode_ia5_string.o src/pk/asn1/der/ia5/der_length_ia5_string.o \
159-
src/pk/asn1/der/integer/der_decode_integer.o src/pk/asn1/der/integer/der_encode_integer.o \
160-
src/pk/asn1/der/integer/der_length_integer.o \
154+
src/modes/ecb/ecb_start.o src/modes/lrw/lrw_decrypt.o src/modes/lrw/lrw_done.o \
155+
src/modes/lrw/lrw_encrypt.o src/modes/lrw/lrw_getiv.o src/modes/lrw/lrw_process.o \
156+
src/modes/lrw/lrw_setiv.o src/modes/lrw/lrw_start.o src/modes/lrw/lrw_test.o \
157+
src/modes/ofb/ofb_decrypt.o src/modes/ofb/ofb_done.o src/modes/ofb/ofb_encrypt.o \
158+
src/modes/ofb/ofb_getiv.o src/modes/ofb/ofb_setiv.o src/modes/ofb/ofb_start.o \
159+
src/pk/asn1/der/bit/der_decode_bit_string.o src/pk/asn1/der/bit/der_encode_bit_string.o \
160+
src/pk/asn1/der/bit/der_length_bit_string.o src/pk/asn1/der/choice/der_decode_choice.o \
161+
src/pk/asn1/der/ia5/der_decode_ia5_string.o src/pk/asn1/der/ia5/der_encode_ia5_string.o \
162+
src/pk/asn1/der/ia5/der_length_ia5_string.o src/pk/asn1/der/integer/der_decode_integer.o \
163+
src/pk/asn1/der/integer/der_encode_integer.o src/pk/asn1/der/integer/der_length_integer.o \
161164
src/pk/asn1/der/object_identifier/der_decode_object_identifier.o \
162165
src/pk/asn1/der/object_identifier/der_encode_object_identifier.o \
163166
src/pk/asn1/der/object_identifier/der_length_object_identifier.o \
@@ -200,6 +203,7 @@ src/headers/tomcrypt_custom.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt
200203
src/headers/tomcrypt_pk.h src/headers/tomcrypt_hash.h src/headers/tomcrypt_math.h \
201204
src/headers/tomcrypt_misc.h src/headers/tomcrypt.h src/headers/tomcrypt_pkcs.h \
202205
src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h
206+
203207
#END_INS
204208

205209
TESTOBJECTS=demos/test.o
@@ -361,5 +365,5 @@ zipup: no_oops docs
361365

362366

363367
# $Source: /cvs/libtom/libtomcrypt/makefile,v $
364-
# $Revision: 1.108 $
365-
# $Date: 2005/11/23 02:34:57 $
368+
# $Revision: 1.114 $
369+
# $Date: 2006/01/26 06:12:31 $

makefile.icc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ src/encauth/eax/eax_decrypt.o src/encauth/eax/eax_decrypt_verify_memory.o src/en
9898
src/encauth/eax/eax_encrypt.o src/encauth/eax/eax_encrypt_authenticate_memory.o \
9999
src/encauth/eax/eax_init.o src/encauth/eax/eax_test.o src/encauth/gcm/gcm_add_aad.o \
100100
src/encauth/gcm/gcm_add_iv.o src/encauth/gcm/gcm_done.o src/encauth/gcm/gcm_gf_mult.o \
101-
src/encauth/gcm/gcm_init.o src/encauth/gcm/gcm_memory.o src/encauth/gcm/gcm_process.o \
102-
src/encauth/gcm/gcm_reset.o src/encauth/gcm/gcm_test.o src/encauth/ocb/ocb_decrypt.o \
101+
src/encauth/gcm/gcm_init.o src/encauth/gcm/gcm_memory.o src/encauth/gcm/gcm_mult_h.o \
102+
src/encauth/gcm/gcm_process.o src/encauth/gcm/gcm_reset.o src/encauth/gcm/gcm_test.o \
103+
src/encauth/nls/nls_memory.o src/encauth/nls/nlsfast.o src/encauth/ocb/ocb_decrypt.o \
103104
src/encauth/ocb/ocb_decrypt_verify_memory.o src/encauth/ocb/ocb_done_decrypt.o \
104105
src/encauth/ocb/ocb_done_encrypt.o src/encauth/ocb/ocb_encrypt.o \
105106
src/encauth/ocb/ocb_encrypt_authenticate_memory.o src/encauth/ocb/ocb_init.o src/encauth/ocb/ocb_ntz.o \
@@ -137,14 +138,16 @@ src/modes/cfb/cfb_getiv.o src/modes/cfb/cfb_setiv.o src/modes/cfb/cfb_start.o \
137138
src/modes/ctr/ctr_decrypt.o src/modes/ctr/ctr_done.o src/modes/ctr/ctr_encrypt.o \
138139
src/modes/ctr/ctr_getiv.o src/modes/ctr/ctr_setiv.o src/modes/ctr/ctr_start.o \
139140
src/modes/ecb/ecb_decrypt.o src/modes/ecb/ecb_done.o src/modes/ecb/ecb_encrypt.o \
140-
src/modes/ecb/ecb_start.o src/modes/ofb/ofb_decrypt.o src/modes/ofb/ofb_done.o \
141-
src/modes/ofb/ofb_encrypt.o src/modes/ofb/ofb_getiv.o src/modes/ofb/ofb_setiv.o \
142-
src/modes/ofb/ofb_start.o src/pk/asn1/der/bit/der_decode_bit_string.o \
143-
src/pk/asn1/der/bit/der_encode_bit_string.o src/pk/asn1/der/bit/der_length_bit_string.o \
144-
src/pk/asn1/der/choice/der_decode_choice.o src/pk/asn1/der/ia5/der_decode_ia5_string.o \
145-
src/pk/asn1/der/ia5/der_encode_ia5_string.o src/pk/asn1/der/ia5/der_length_ia5_string.o \
146-
src/pk/asn1/der/integer/der_decode_integer.o src/pk/asn1/der/integer/der_encode_integer.o \
147-
src/pk/asn1/der/integer/der_length_integer.o \
141+
src/modes/ecb/ecb_start.o src/modes/lrw/lrw_decrypt.o src/modes/lrw/lrw_done.o \
142+
src/modes/lrw/lrw_encrypt.o src/modes/lrw/lrw_getiv.o src/modes/lrw/lrw_process.o \
143+
src/modes/lrw/lrw_setiv.o src/modes/lrw/lrw_start.o src/modes/lrw/lrw_test.o \
144+
src/modes/ofb/ofb_decrypt.o src/modes/ofb/ofb_done.o src/modes/ofb/ofb_encrypt.o \
145+
src/modes/ofb/ofb_getiv.o src/modes/ofb/ofb_setiv.o src/modes/ofb/ofb_start.o \
146+
src/pk/asn1/der/bit/der_decode_bit_string.o src/pk/asn1/der/bit/der_encode_bit_string.o \
147+
src/pk/asn1/der/bit/der_length_bit_string.o src/pk/asn1/der/choice/der_decode_choice.o \
148+
src/pk/asn1/der/ia5/der_decode_ia5_string.o src/pk/asn1/der/ia5/der_encode_ia5_string.o \
149+
src/pk/asn1/der/ia5/der_length_ia5_string.o src/pk/asn1/der/integer/der_decode_integer.o \
150+
src/pk/asn1/der/integer/der_encode_integer.o src/pk/asn1/der/integer/der_length_integer.o \
148151
src/pk/asn1/der/object_identifier/der_decode_object_identifier.o \
149152
src/pk/asn1/der/object_identifier/der_encode_object_identifier.o \
150153
src/pk/asn1/der/object_identifier/der_length_object_identifier.o \
@@ -187,6 +190,7 @@ src/headers/tomcrypt_custom.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt
187190
src/headers/tomcrypt_pk.h src/headers/tomcrypt_hash.h src/headers/tomcrypt_math.h \
188191
src/headers/tomcrypt_misc.h src/headers/tomcrypt.h src/headers/tomcrypt_pkcs.h \
189192
src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h
193+
190194
#END_INS
191195

192196
#Who do we install as?
@@ -266,6 +270,6 @@ install: library
266270
install -g $(GROUP) -o $(USER) $(HEADERS) $(DESTDIR)$(INCPATH)
267271

268272
# $Source: /cvs/libtom/libtomcrypt/makefile.icc,v $
269-
# $Revision: 1.45 $
270-
# $Date: 2005/11/23 02:34:57 $
273+
# $Revision: 1.49 $
274+
# $Date: 2006/01/26 06:12:31 $
271275

0 commit comments

Comments
 (0)