Skip to content

Commit bbc52b9

Browse files
Tom St Denissjaeckel
Tom St Denis
authored andcommitted
added libtomcrypt-1.17
1 parent e24b01d commit bbc52b9

File tree

341 files changed

+4806
-1740
lines changed

Some content is hidden

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

341 files changed

+4806
-1740
lines changed

Doxyfile

+1-1
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.16
26+
PROJECT_NUMBER = 1.17
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

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
stopped at ch12
2-
-- needs examples for ecc/dsa!!! (and for asn.1)
3-
4-
must have for v1.16
5-
- document PK build flags
6-
- document makefile flags [INSTALL_* for instance]
7-
- prepare manual for printing (both soft and hard cover)
8-
9-
Nice to have [in order of precedence]
10-
- add X9.63 IES
11-
- add CPP macros like OpenSSL has for ASN1 (e.g. encode/decode functions, etc) shameless ripoff :-)
1+
for 1.18
2+
- document new ECC functions
3+
- add test for new functions

changes

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
May 12th, 2007
2+
v1.17 -- Cryptography Research Inc. contributed another small volley of patches, one to fix __WCHAR_DEFINED__ for BSD platforms,
3+
another to silence MSVC warnings.
4+
-- Added LTC_XCBC_PURE to XCBC mode which lets you use it in three-key mode.
5+
-- [CRI] Added libtomcrypt.dsp for Visual C++ users.
6+
-- [CRI] Added more functions for manipulating the ECC fixed point cache (including saving and loading)
7+
-- [CRI] Modified ecc_make_key() to always produce keys smaller than base point order, for standards-compliance
8+
-- Elliptic Semiconductor contributed XTS chaining mode to the cipher suite (subsequently optimized it)
9+
-- Fixed xcbc_init() keylen when using single key mode.
10+
-- Bruce Fortune pointed out a typo in the hmac_process() description in the manual. Fixed.
11+
-- Added variable width counter support to CTR mode
12+
-- Fixed CMAC (aka OMAC) when using 64-bit block ciphers and LTC_FAST ... my bad.
13+
-- Fixed bug in ecc_is_valid() that would basically always return true
14+
-- renamed a lot of macros to add the LTC_ prefix [e.g. RIJNDAEL => LTC_RIJNDAEL]
15+
116
December 16th, 2006
217
v1.16 -- Brian Gladman pointed out that a recent change to GCM broke how the IV was handled. Currently the code complies against his test vectors
318
so the code should be considered frozen now.
@@ -1551,6 +1566,6 @@ v0.02 -- Changed RC5 to only allow 12 to 24 rounds
15511566
v0.01 -- We will call this the first version.
15521567

15531568
/* $Source: /cvs/libtom/libtomcrypt/changes,v $ */
1554-
/* $Revision: 1.274 $ */
1555-
/* $Date: 2006/12/16 19:08:17 $ */
1569+
/* $Revision: 1.288 $ */
1570+
/* $Date: 2007/05/12 14:37:41 $ */
15561571

crypt.lof

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
\contentsline {figure}{\numberline {3.1}{\ignorespaces Built--In Software Ciphers}}{19}{figure.3.1}
77
\contentsline {figure}{\numberline {3.2}{\ignorespaces Twofish Build Options}}{21}{figure.3.2}
88
\addvspace {10\p@ }
9-
\contentsline {figure}{\numberline {4.1}{\ignorespaces Built--In Software Hashes}}{57}{figure.4.1}
9+
\contentsline {figure}{\numberline {4.1}{\ignorespaces Built--In Software Hashes}}{59}{figure.4.1}
1010
\addvspace {10\p@ }
1111
\addvspace {10\p@ }
12-
\contentsline {figure}{\numberline {6.1}{\ignorespaces List of Provided PRNGs}}{82}{figure.6.1}
12+
\contentsline {figure}{\numberline {6.1}{\ignorespaces List of Provided PRNGs}}{84}{figure.6.1}
1313
\addvspace {10\p@ }
1414
\addvspace {10\p@ }
1515
\addvspace {10\p@ }
16-
\contentsline {figure}{\numberline {9.1}{\ignorespaces DSA Key Sizes}}{119}{figure.9.1}
16+
\contentsline {figure}{\numberline {9.1}{\ignorespaces DSA Key Sizes}}{121}{figure.9.1}
1717
\addvspace {10\p@ }
18-
\contentsline {figure}{\numberline {10.1}{\ignorespaces List of ASN.1 Supported Types}}{127}{figure.10.1}
18+
\contentsline {figure}{\numberline {10.1}{\ignorespaces List of ASN.1 Supported Types}}{129}{figure.10.1}
1919
\addvspace {10\p@ }
2020
\addvspace {10\p@ }
21-
\contentsline {figure}{\numberline {12.1}{\ignorespaces RSA/DH Key Strength}}{149}{figure.12.1}
22-
\contentsline {figure}{\numberline {12.2}{\ignorespaces ECC Key Strength}}{149}{figure.12.2}
21+
\contentsline {figure}{\numberline {12.1}{\ignorespaces RSA/DH Key Strength}}{151}{figure.12.1}
22+
\contentsline {figure}{\numberline {12.2}{\ignorespaces ECC Key Strength}}{151}{figure.12.2}
2323
\addvspace {10\p@ }
2424
\addvspace {10\p@ }

crypt.tex

+87-8
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ \subsection{Modular}
190190
\mysection{Patent Disclosure}
191191

192192
The author (Tom St Denis) is not a patent lawyer so this section is not to be treated as legal advice. To the best
193-
of the authors knowledge the only patent related issues within the library are the RC5 and RC6 symmetric block ciphers.
193+
of the author's knowledge the only patent related issues within the library are the RC5 and RC6 symmetric block ciphers.
194194
They can be removed from a build by simply commenting out the two appropriate lines in \textit{tomcrypt\_custom.h}. The rest
195195
of the ciphers and hashes are patent free or under patents that have since expired.
196196

@@ -616,8 +616,8 @@ \subsection{Simple Encryption Demonstration}
616616
\hline AES & aes\_desc & 16 & 16, 24, 32 & 10, 12, 14 \\
617617
& aes\_enc\_desc & 16 & 16, 24, 32 & 10, 12, 14 \\
618618
\hline Twofish & twofish\_desc & 16 & 16, 24, 32 & 16 \\
619-
\hline DES & des\_desc & 8 & 7 & 16 \\
620-
\hline 3DES (EDE mode) & des3\_desc & 8 & 21 & 16 \\
619+
\hline DES & des\_desc & 8 & 8 & 16 \\
620+
\hline 3DES (EDE mode) & des3\_desc & 8 & 24 & 16 \\
621621
\hline CAST5 (CAST-128) & cast5\_desc & 8 & 5 $\ldots$ 16 & 12, 16 \\
622622
\hline Noekeon & noekeon\_desc & 16 & 16 & 16 \\
623623
\hline Skipjack & skipjack\_desc & 8 & 10 & 32 \\
@@ -879,14 +879,37 @@ \subsection{Initialization}
879879
parameters \textit{key}, \textit{keylen} and \textit{num\_rounds} are the same as in the XXX\_setup() function call. The final parameter
880880
is a pointer to the structure you want to hold the information for the mode of operation.
881881

882+
The routines return {\bf CRYPT\_OK} if the cipher initialized correctly, otherwise, they return an error code.
882883

884+
\subsubsection{CTR Mode}
883885
In the case of CTR mode there is an additional parameter \textit{ctr\_mode} which specifies the mode that the counter is to be used in.
884886
If \textbf{CTR\_COUNTER\_ LITTLE\_ENDIAN} was specified then the counter will be treated as a little endian value. Otherwise, if
885887
\textbf{CTR\_COUNTER\_BIG\_ENDIAN} was specified the counter will be treated as a big endian value. As of v1.15 the RFC 3686 style of
886888
increment then encrypt is also supported. By OR'ing \textbf{LTC\_CTR\_RFC3686} with the CTR \textit{mode} value, ctr\_start() will increment
887889
the counter before encrypting it for the first time.
888890

889-
The routines return {\bf CRYPT\_OK} if the cipher initialized correctly, otherwise, they return an error code.
891+
As of V1.17, the library supports variable length counters for CTR mode. The (optional) counter length is specified by OR'ing the octet
892+
length of the counter against the \textit{ctr\_mode} parameter. The default, zero, indicates that a full block length counter will be used. This also
893+
ensures backwards compatibility with software that uses older versions of the library.
894+
895+
\begin{small}
896+
\begin{verbatim}
897+
symmetric_CTR ctr;
898+
int err;
899+
unsigned char IV[16], key[16];
900+
901+
/* use a 32-bit little endian counter */
902+
if ((err = ctr_start(find_cipher("aes"),
903+
IV, key, 16, 0,
904+
CTR_COUNTER_LITTLE_ENDIAN | 4,
905+
&ctr)) != CRYPT_OK) {
906+
handle_error(err);
907+
}
908+
\end{verbatim}
909+
\end{small}
910+
911+
Changing the counter size has little (really no) effect on the performance of the CTR chaining mode. It is provided for compatibility
912+
with other software (and hardware) which have smaller fixed sized counters.
890913

891914
\subsection{Encryption and Decryption}
892915
To actually encrypt or decrypt the following routines are provided:
@@ -1093,6 +1116,55 @@ \subsection{LRW Mode}
10931116
int lrw_done(symmetric_LRW *lrw);
10941117
\end{verbatim}
10951118

1119+
\subsection{XTS Mode}
1120+
As of v1.17, LibTomCrypt supports XTS mode with code donated by Elliptic Semiconductor Inc.\footnote{www.ellipticsemi.com}.
1121+
XTS is a chaining mode for 128--bit block ciphers, recommended by IEEE (P1619)
1122+
for disk encryption. It is meant to be an encryption mode with random access to the message data without compromising privacy. It requires two private keys (of equal
1123+
length) to perform the encryption process. Each encryption invocation includes a sector number or unique identifier specified as a 128--bit string.
1124+
1125+
To initialize XTS mode use the following function call:
1126+
1127+
\index{xts\_start()}
1128+
\begin{verbatim}
1129+
int xts_start( int cipher,
1130+
const unsigned char *key1,
1131+
const unsigned char *key2,
1132+
unsigned long keylen,
1133+
int num_rounds,
1134+
symmetric_xts *xts)
1135+
\end{verbatim}
1136+
This will start the XTS mode with the two keys pointed to by \textit{key1} and \textit{key2} of length \textit{keylen} octets each.
1137+
1138+
To encrypt or decrypt a sector use the following calls:
1139+
1140+
\index{xts\_encrypt()} \index{xts\_decrypt()}
1141+
\begin{verbatim}
1142+
int xts_encrypt(
1143+
const unsigned char *pt, unsigned long ptlen,
1144+
unsigned char *ct,
1145+
const unsigned char *tweak,
1146+
symmetric_xts *xts);
1147+
1148+
int xts_decrypt(
1149+
const unsigned char *ct, unsigned long ptlen,
1150+
unsigned char *pt,
1151+
const unsigned char *tweak,
1152+
symmetric_xts *xts);
1153+
\end{verbatim}
1154+
The first will encrypt the plaintext pointed to by \textit{pt} of length \textit{ptlen} octets, and store the ciphertext in the array pointed to by
1155+
\textit{ct}. It uses the 128--bit tweak pointed to by \textit{tweak} to encrypt the block. The decrypt function performs the opposite operation. Both
1156+
functions support ciphertext stealing (blocks that are not multiples of 16 bytes).
1157+
1158+
The P1619 specification states the tweak for sector number shall be represented as a 128--bit little endian string.
1159+
1160+
To terminate the XTS state call the following function:
1161+
1162+
\index{xts\_done()}
1163+
\begin{verbatim}
1164+
void xts_done(symmetric_xts *xts);
1165+
\end{verbatim}
1166+
1167+
10961168
\subsection{F8 Mode}
10971169
\index{F8 Mode}
10981170
The F8 Chaining mode (see RFC 3711 for instance) is yet another chaining mode for block ciphers. It behaves much like CTR mode in that it XORs a keystream
@@ -2098,8 +2170,8 @@ \chapter{Message Authentication Codes}
20982170
const unsigned char *in,
20992171
unsigned long inlen);
21002172
\end{verbatim}
2101-
\textit{hmac} is the HMAC state you are working with. \textit{buf} is the array of octets to send into the HMAC process. \textit{len} is the
2102-
number of octets to process. Like the hash process routines you can send the data in arbitrarily sized chunks. When you
2173+
\textit{hmac} is the HMAC state you are working with. \textit{in} is the array of octets to send into the HMAC process. \textit{inlen} is the
2174+
number of octets to process. Like the hash process routines, you can send the data in arbitrarily sized chunks. When you
21032175
are finished with the HMAC process you must call the following function to get the HMAC code:
21042176
\index{hmac\_done()}
21052177
\begin{verbatim}
@@ -2511,6 +2583,13 @@ \subsection{Example}
25112583
This will initialize the XCBC--MAC state \textit{xcbc}, with the key specified in \textit{key} of length \textit{keylen} octets. The cipher indicated
25122584
by the \textit{cipher} index can be either a 64 or 128--bit block cipher. This will return \textbf{CRYPT\_OK} on success.
25132585

2586+
\index{LTC\_XCBC\_PURE}
2587+
It is possible to use XCBC in a three key mode by OR'ing the value \textbf{LTC\_XCBC\_PURE} against the \textit{keylen} parameter. In this mode, the key is
2588+
interpretted as three keys. If the cipher has a block size of $n$ octets, the first key is then $keylen - 2n$ octets and is the encryption key. The next
2589+
$2n$ octets are the $K_1$ and $K_2$ padding keys (used on the last block). For example, to use AES--192 \textit{keylen} should be $24 + 2 \cdot 16 = 56$ octets.
2590+
The three keys are interpretted as if they were concatenated in the \textit{key} buffer.
2591+
2592+
25142593
To process data through XCBC--MAC use the following function:
25152594

25162595
\index{xcbc\_process()}
@@ -6485,5 +6564,5 @@ \subsection{RSA Functions}
64856564
\end{document}
64866565

64876566
% $Source: /cvs/libtom/libtomcrypt/crypt.tex,v $
6488-
% $Revision: 1.123 $
6489-
% $Date: 2006/12/16 19:08:17 $
6567+
% $Revision: 1.128 $
6568+
% $Date: 2007/03/10 23:59:54 $

demos/encrypt.c

+17-17
Original file line numberDiff line numberDiff line change
@@ -26,58 +26,58 @@ void register_algs(void)
2626
{
2727
int x;
2828

29-
#ifdef RIJNDAEL
29+
#ifdef LTC_RIJNDAEL
3030
register_cipher (&aes_desc);
3131
#endif
32-
#ifdef BLOWFISH
32+
#ifdef LTC_BLOWFISH
3333
register_cipher (&blowfish_desc);
3434
#endif
35-
#ifdef XTEA
35+
#ifdef LTC_XTEA
3636
register_cipher (&xtea_desc);
3737
#endif
38-
#ifdef RC5
38+
#ifdef LTC_RC5
3939
register_cipher (&rc5_desc);
4040
#endif
41-
#ifdef RC6
41+
#ifdef LTC_RC6
4242
register_cipher (&rc6_desc);
4343
#endif
44-
#ifdef SAFERP
44+
#ifdef LTC_SAFERP
4545
register_cipher (&saferp_desc);
4646
#endif
47-
#ifdef TWOFISH
47+
#ifdef LTC_TWOFISH
4848
register_cipher (&twofish_desc);
4949
#endif
50-
#ifdef SAFER
50+
#ifdef LTC_SAFER
5151
register_cipher (&safer_k64_desc);
5252
register_cipher (&safer_sk64_desc);
5353
register_cipher (&safer_k128_desc);
5454
register_cipher (&safer_sk128_desc);
5555
#endif
56-
#ifdef RC2
56+
#ifdef LTC_RC2
5757
register_cipher (&rc2_desc);
5858
#endif
59-
#ifdef DES
59+
#ifdef LTC_DES
6060
register_cipher (&des_desc);
6161
register_cipher (&des3_desc);
6262
#endif
63-
#ifdef CAST5
63+
#ifdef LTC_CAST5
6464
register_cipher (&cast5_desc);
6565
#endif
66-
#ifdef NOEKEON
66+
#ifdef LTC_NOEKEON
6767
register_cipher (&noekeon_desc);
6868
#endif
69-
#ifdef SKIPJACK
69+
#ifdef LTC_SKIPJACK
7070
register_cipher (&skipjack_desc);
7171
#endif
72-
#ifdef KHAZAD
72+
#ifdef LTC_KHAZAD
7373
register_cipher (&khazad_desc);
7474
#endif
75-
#ifdef ANUBIS
75+
#ifdef LTC_ANUBIS
7676
register_cipher (&anubis_desc);
7777
#endif
7878

7979
if (register_hash(&sha256_desc) == -1) {
80-
printf("Error registering SHA256\n");
80+
printf("Error registering LTC_SHA256\n");
8181
exit(-1);
8282
}
8383

@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
144144

145145
hash_idx = find_hash("sha256");
146146
if (hash_idx == -1) {
147-
printf("SHA256 not found...?\n");
147+
printf("LTC_SHA256 not found...?\n");
148148
exit(-1);
149149
}
150150

demos/hashsum.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -68,43 +68,43 @@ void register_algs(void)
6868
{
6969
int err;
7070

71-
#ifdef TIGER
71+
#ifdef LTC_TIGER
7272
register_hash (&tiger_desc);
7373
#endif
74-
#ifdef MD2
74+
#ifdef LTC_MD2
7575
register_hash (&md2_desc);
7676
#endif
77-
#ifdef MD4
77+
#ifdef LTC_MD4
7878
register_hash (&md4_desc);
7979
#endif
80-
#ifdef MD5
80+
#ifdef LTC_MD5
8181
register_hash (&md5_desc);
8282
#endif
83-
#ifdef SHA1
83+
#ifdef LTC_SHA1
8484
register_hash (&sha1_desc);
8585
#endif
86-
#ifdef SHA224
86+
#ifdef LTC_SHA224
8787
register_hash (&sha224_desc);
8888
#endif
89-
#ifdef SHA256
89+
#ifdef LTC_SHA256
9090
register_hash (&sha256_desc);
9191
#endif
92-
#ifdef SHA384
92+
#ifdef LTC_SHA384
9393
register_hash (&sha384_desc);
9494
#endif
95-
#ifdef SHA512
95+
#ifdef LTC_SHA512
9696
register_hash (&sha512_desc);
9797
#endif
98-
#ifdef RIPEMD128
98+
#ifdef LTC_RIPEMD128
9999
register_hash (&rmd128_desc);
100100
#endif
101-
#ifdef RIPEMD160
101+
#ifdef LTC_RIPEMD160
102102
register_hash (&rmd160_desc);
103103
#endif
104-
#ifdef WHIRLPOOL
104+
#ifdef LTC_WHIRLPOOL
105105
register_hash (&whirlpool_desc);
106106
#endif
107-
#ifdef CHC_HASH
107+
#ifdef LTC_CHC_HASH
108108
register_hash(&chc_desc);
109109
if ((err = chc_register(register_cipher(&aes_enc_desc))) != CRYPT_OK) {
110110
printf("chc_register error: %s\n", error_to_string(err));

demos/multi.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int main(void)
3333
return EXIT_FAILURE;
3434
}
3535

36-
/* HMAC */
36+
/* LTC_HMAC */
3737
len = sizeof(buf[0]);
3838
hmac_memory(find_hash("sha256"), key, 16, (unsigned char*)"hello", 5, buf[0], &len);
3939
len2 = sizeof(buf[0]);
@@ -55,7 +55,7 @@ int main(void)
5555
return EXIT_FAILURE;
5656
}
5757

58-
/* OMAC */
58+
/* LTC_OMAC */
5959
len = sizeof(buf[0]);
6060
omac_memory(find_cipher("aes"), key, 16, (unsigned char*)"hello", 5, buf[0], &len);
6161
len2 = sizeof(buf[0]);

0 commit comments

Comments
 (0)