Skip to content

Commit 9264e34

Browse files
Tom St Denissjaeckel
authored andcommitted
added libtomcrypt-1.05
1 parent 9da48eb commit 9264e34

49 files changed

Lines changed: 1008 additions & 109 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.04
26+
PROJECT_NUMBER = 1.05
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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Things ideal for 1.05
2-
3-
- ASN.1 SET and UTCtime and CHOICE (hint for choice do it as a sep list and just use error codes to know when you got a hit)
4-
- Start working towards making the bignum code plugable
5-
- Add OID for ciphers and PRNGs to their descriptors
6-
- Document the ASN.1 a bit more verbosely ;-)
7-
- Some ASN.1 demo programs [for now read the source code!]
8-
- export ECC functions globally
9-
- Look into other ECC point muls and consider a "precomp" interface
1+
For 1.06
102

3+
1. export ECC functions globally [e.g. mulmod and the sets]
4+
- goal is tv_gen module and test vectors
5+
2. ASN.1 SET and T61String
6+
3. phase out DH code [RSA/ECC/DSA is enough]
7+
4. Some ASN.1 demo programs [for now read the source code!]
8+
5. Start working towards making the bignum code plugable
9+
6. Look into other ECC point muls and consider a "precomp" interface
10+
7. Add OID for ciphers and PRNGs to their descriptors

build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
echo "$1 ($2, $3)..."
33
make clean 1>/dev/null 2>/dev/null
44
echo -n "building..."
5-
CFLAGS="$2 $CFLAGS" make -f $3 test tv_gen 1>gcc_1.txt 2>gcc_2.txt || (echo "build $1 failed see gcc_2.txt for more information" && cat gcc_2.txt && exit 1)
5+
CFLAGS="$2 $CFLAGS" make -j3 -f $3 test tv_gen 1>gcc_1.txt 2>gcc_2.txt || (echo "build $1 failed see gcc_2.txt for more information" && cat gcc_2.txt && exit 1)
66
echo -n "testing..."
77
if [ -a test ] && [ -f test ] && [ -x test ]; then
88
((./test >test_std.txt 2>test_err.txt && ./tv_gen > tv.txt) && echo "$1 test passed." && echo "y" > testok.txt) || (echo "$1 test failed" && cat test_err.txt && exit 1)
@@ -16,5 +16,5 @@ fi
1616
exit 1
1717
1818
# $Source: /cvs/libtom/libtomcrypt/build.sh,v $
19-
# $Revision: 1.4 $
20-
# $Date: 2005/05/05 14:49:27 $
19+
# $Revision: 1.5 $
20+
# $Date: 2005/06/27 13:04:05 $

changes

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
June 27th, 2005
2+
v1.05
3+
-- Added Technote #6 which covers the current PK compliance.
4+
-- Fixed buffer overflow in OAEP decoder
5+
-- Added CHOICE to the list of ASN.1 types
6+
-- Added UTCTIME to the list of ASN.1 types
7+
-- Added MUTEX locks around descriptor table functions [but not on the functions that are dependent on them]
8+
All functions call *_is_valid() before using a descriptor index which means the respective table must be unlocked before
9+
it can be accessed. However, during the operation [e.g. CCM] if the descriptor has been altered the results will be
10+
undefined.
11+
-- Minor updates to the manual to reflect recent changes
12+
-- Added a catch to for an error that should never come up in rsa_exptmod(). Just being thorough.
13+
114
June 15th, 2005
215
v1.04
316
-- Fixed off by one [bit] error in dsa_make_key() it was too high by one bit [not a security problem just inconsistent]
@@ -1308,6 +1321,6 @@ v0.02 -- Changed RC5 to only allow 12 to 24 rounds
13081321
v0.01 -- We will call this the first version.
13091322

13101323
/* $Source: /cvs/libtom/libtomcrypt/changes,v $ */
1311-
/* $Revision: 1.97 $ */
1312-
/* $Date: 2005/06/14 23:09:41 $ */
1324+
/* $Revision: 1.106 $ */
1325+
/* $Date: 2005/06/27 12:37:06 $ */
13131326

crypt.tex

Lines changed: 86 additions & 18 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.04}
50+
\title{LibTomCrypt \\ Version 1.05}
5151
\author{Tom St Denis \\
5252
\\
5353
tomstdenis@gmail.com \\
@@ -3051,8 +3051,8 @@ \section{Core Functions}
30513051
int keysize, ecc_key *key);
30523052
\end{verbatim}
30533053

3054-
The ``keysize'' is the size of the modulus in bytes desired. Currently directly supported values are 20, 24, 28, 32, 48 and 65 bytes which
3055-
correspond to key sizes of 160, 192, 224, 256, 384 and 521 bits respectively. If you pass a key size that is between any key size
3054+
The ``keysize'' is the size of the modulus in bytes desired. Currently directly supported values are 24, 28, 32, 48 and 65 bytes which
3055+
correspond to key sizes of 192, 224, 256, 384 and 521 bits respectively. If you pass a key size that is between any key size
30563056
it will round the keysize up to the next available one. The rest of the parameters work like they do in the ``dh\_make\_key()'' function.
30573057
To free the ram allocated by a key call:
30583058
\index{ecc\_free()}
@@ -3150,8 +3150,8 @@ \subsection{Signature Format}
31503150
\section{ECC Keysizes}
31513151
With ECC if you try and sign a hash that is bigger than your ECC key you can run into problems. The math will still work
31523152
and in effect the signature will still work. With ECC keys the strength of the signature is limited by the size of
3153-
the hash or the size of they key, whichever is smaller. For example, if you sign with SHA256 and a ECC-160 key in effect
3154-
you have 160-bits of security (e.g. as if you signed with SHA-1).
3153+
the hash or the size of they key, whichever is smaller. For example, if you sign with SHA256 and an ECC-192 key in effect
3154+
you have 192-bits of security.
31553155

31563156
The library will not warn you if you make this mistake so it is important to check yourself before using the
31573157
signatures.
@@ -3324,7 +3324,7 @@ \section{ASN.1 Formats}
33243324
are all provided with three basic functions with \textit{similar} prototypes. One function has been dedicated to calculate the length in octets of a given
33253325
format and two functions have been dedicated to encoding and decoding the format.
33263326
3327-
On top of the basic data types are the SEQUENCE and\footnote{Planned for LTC 1.04} SET data types which are collections of other ASN.1 types. They are provided
3327+
On top of the basic data types are the SEQUENCE and\footnote{Planned for LTC 1.06} SET data types which are collections of other ASN.1 types. They are provided
33283328
in the same manner as the other data types except they use list of objects known as the \textbf{ltc\_asn1\_list} structure. It is defined as
33293329
33303330
\index{ltc\_asn1\_list structure}
@@ -3333,11 +3333,13 @@ \section{ASN.1 Formats}
33333333
int type;
33343334
void *data;
33353335
unsigned long size;
3336+
int used;
33363337
} ltc_asn1_list;
33373338
\end{verbatim}
33383339
33393340
The ``type'' field is one of the following ASN.1 field definitions. The ``data'' pointer is a void pointer to the data to be encoded (or the destination) and the
3340-
``size'' field is specific to what you are encoding (e.g. number of bits in the BIT STRING data type). To help build the lists in an orderly fashion the macro
3341+
``size'' field is specific to what you are encoding (e.g. number of bits in the BIT STRING data type). The ``used'' field is primarily for the CHOICE decoder
3342+
and reflects if the particular member of a list was the decoded data type. To help build the lists in an orderly fashion the macro
33413343
``LTC\_SET\_ASN1(list, index, Type, Data, Size)'' has been provided.
33423344
33433345
It will assign to the ``index''th position in the ``list'' the tripplet (Type, Data, Size). An example usage would be:
@@ -3382,7 +3384,9 @@ \section{ASN.1 Formats}
33823384
\hline LTC\_ASN1\_OBJECT\_IDENTIFIER & OBJECT IDENTIFIER (words are in unsigned long) \\
33833385
\hline LTC\_ASN1\_IA5\_STRING & IA5 STRING (one octet per char) \\
33843386
\hline LTC\_ASN1\_PRINTABLE\_STRING & PRINTABLE STIRNG (one octet per char) \\
3387+
\hline LTC\_ASN1\_UTCTIME & UTCTIME (see ltc\_utctime structure) \\
33853388
\hline LTC\_ASN1\_SEQUENCE & SEQUENCE OF \\
3389+
\hline LTC\_ASN1\_CHOICE & CHOICE \\
33863390
\hline
33873391
\end{tabular}
33883392
\caption{List of ASN.1 Supported Types}
@@ -3466,7 +3470,7 @@ \subsubsection{SEQUENCE Multiple Argument Lists}
34663470
It's ideal that you cast the ``size'' values to unsigned long to ensure that the proper data type is passed to the function. Constants such as ``1'' without
34673471
a cast or prototype are of type \textbf{int} by default. Appending \textit{UL} or prepending \textit{(unsigned long)} is enough to cast it to the correct type.
34683472
3469-
\subsubsection{ASN.1 INTEGER}
3473+
\subsection{ASN.1 INTEGER}
34703474
34713475
To encode or decode INTEGER data types use the following functions.
34723476
@@ -3498,7 +3502,7 @@ \subsubsection{ASN.1 INTEGER}
34983502
These will encode or decode an unsigned \textbf{unsigned long} type (only reads upto 32--bits). For values in the range $0 \dots 2^{32} - 1$ the integer
34993503
and short integer functions can encode and decode each others outputs.
35003504
3501-
\subsubsection{ASN.1 BIT STRING}
3505+
\subsection{ASN.1 BIT STRING}
35023506
35033507
\index{der\_encode\_bit\_string()}
35043508
\index{der\_decode\_bit\_string()}
@@ -3516,7 +3520,7 @@ \subsubsection{ASN.1 BIT STRING}
35163520
These will encode or decode a BIT STRING data type. The bits are passed in (or read out) using one \textbf{char} per bit. A non--zero value will be interpretted
35173521
as a one bit and a zero value a zero bit.
35183522
3519-
\subsubsection{ASN.1 OCTET STRING}
3523+
\subsection{ASN.1 OCTET STRING}
35203524
35213525
\index{der\_encode\_octet\_string()}
35223526
\index{der\_decode\_octet\_string()}
@@ -3533,7 +3537,7 @@ \subsubsection{ASN.1 OCTET STRING}
35333537
35343538
These will encode or decode an OCTET STRING data type. The octets are stored using one \textbf{char} each.
35353539
3536-
\subsubsection{ASN.1 OBJECT IDENTIFIER}
3540+
\subsection{ASN.1 OBJECT IDENTIFIER}
35373541
35383542
\index{der\_encode\_object\_identifier()}
35393543
\index{der\_decode\_object\_identifier()}
@@ -3552,7 +3556,7 @@ \subsubsection{ASN.1 OBJECT IDENTIFIER}
35523556
These will encode or decode an OBJECT IDENTIFIER object. The words of the OID are stored in individual \textbf{unsigned long} elements and must be in the range
35533557
$0 \ldots 2^{32} - 1$.
35543558
3555-
\subsubsection{ASN.1 IA5 STRING}
3559+
\subsection{ASN.1 IA5 STRING}
35563560
35573561
\index{der\_encode\_ia5\_string()}
35583562
\index{der\_decode\_ia5\_string()}
@@ -3575,7 +3579,7 @@ \subsubsection{ASN.1 IA5 STRING}
35753579
35763580
If you're worried try building the test suite and running it. It has hard coded test vectors to ensure it is operating properly.
35773581
3578-
\subsubsection{ASN.1 PRINTABLE STRING}
3582+
\subsection{ASN.1 PRINTABLE STRING}
35793583
35803584
\index{der\_encode\_printable\_string()}
35813585
\index{der\_decode\_printable\_string()}
@@ -3598,6 +3602,64 @@ \subsubsection{ASN.1 PRINTABLE STRING}
35983602
35993603
If you're worried try building the test suite and running it. It has hard coded test vectors to ensure it is operating properly.
36003604
3605+
\subsection{ASN.1 UTCTIME}
3606+
3607+
The UTCTIME type is to store a date and time in ASN.1 format. It uses the following structure to organize the time.
3608+
3609+
\begin{verbatim}
3610+
typedef struct {
3611+
unsigned YY, /* year 00--99 */
3612+
MM, /* month 01--12 */
3613+
DD, /* day 01--31 */
3614+
hh, /* hour 00--23 */
3615+
mm, /* minute 00--59 */
3616+
ss, /* second 00--59 */
3617+
off_dir, /* timezone offset direction 0 == +, 1 == - */
3618+
off_hh, /* timezone offset hours */
3619+
off_mm; /* timezone offset minutes */
3620+
} ltc_utctime;
3621+
\end{verbatim}
3622+
3623+
The time can be offset plus or minus a set amount of hours (off\_hh) and minutes (off\_mm). When ``off\_dir'' is zero the time will be added otherwise it
3624+
will be subtracted.
3625+
3626+
For instance, the array $\lbrace 5, 6, 20, 22, 4, 00, 0, 5, 0 \rbrace$ represents the current time of 2005, June 20th, 22:04:00 with a time offset of +05h00.
3627+
3628+
\index{der\_encode\_utctime()}
3629+
\index{der\_decode\_utctime()}
3630+
\index{der\_length\_utctime()}
3631+
\begin{verbatim}
3632+
int der_encode_utctime(ltc_utctime *utctime,
3633+
unsigned char *out, unsigned long *outlen);
3634+
3635+
int der_decode_utctime(const unsigned char *in, unsigned long *inlen,
3636+
ltc_utctime *out);
3637+
3638+
int der_length_utctime(ltc_utctime *utctime, unsigned long *outlen);
3639+
\end{verbatim}
3640+
3641+
The encoder will store time in one of the two ASN.1 formats, either ``YYMMDDhhmmssZ'' or ``YYMMDDhhmmss$\pm$hhmm'' and perform minimal error checking on the
3642+
input. The decoder will read all valid ASN.1 formats and perform range checking on the values (not complete but rational) useful for catching packet errors.
3643+
3644+
It is suggested that decoded data be further scrutinized (e.g. days of month in particular).
3645+
3646+
\subsection{ASN.1 CHOICE}
3647+
3648+
The CHOICE ASN.1 type represents a union of ASN.1 types all of which are stored in a ``ltc\_asn1\_list''. There is no encoder for the CHOICE type, only a
3649+
decoder. The decoder will scan through the provided list attempting to use the appropriate decoder on the input packet. The list can contain any ASN.1 data
3650+
type\footnote{Except it cannot have LTC\_ASN1\_INTEGER and LTC\_ASN1\_SHORT\_INTEGER simultaneously.} except for other CHOICE types.
3651+
3652+
There is no encoder for the CHOICE type as the actual DER encoding is the encoding of the chosen type.
3653+
3654+
\index{der\_decode\_choice()}
3655+
\begin{verbatim}
3656+
int der_decode_choice(const unsigned char *in, unsigned long *inlen,
3657+
ltc_asn1_list *list, unsigned long outlen);
3658+
\end{verbatim}
3659+
3660+
This will decode the input in the ``in'' field of length ``inlen''. It uses the provided ASN.1 list specified in the ``list'' field which has ``outlen'' elements.
3661+
The ``inlen'' field will be updated with the length of the decoded data type as well as the respective entry in the ``list'' field will have the ``used'' flag
3662+
set to non--zero to reflect it was the data type decoded.
36013663
36023664
\section{Password Based Cryptography}
36033665
\subsection{PKCS \#5}
@@ -3871,7 +3933,6 @@ \subsection{Assymetric Ciphers}
38713933
\begin{center}
38723934
\begin{tabular}{|c|c|}
38733935
\hline ECC Key Size (bits) & Work Factor ($log_2$) \\
3874-
\hline 160 & 80 \\
38753936
\hline 192 & 96 \\
38763937
\hline 224 & 112 \\
38773938
\hline 256 & 128 \\
@@ -4029,8 +4090,8 @@ \subsection{TWOFISH\_SMALL and TWOFISH\_TABLES}
40294090
it will not speed up the encryption or decryption functions.
40304091
40314092
\subsection{GCM\_TABLES}
4032-
When defined GCM will use a 64KB table (per GCM state) which will greatly lower up the per--packet latency.
4033-
It also increases the initialization time.
4093+
When defined GCM will use a 64KB table (per GCM state) which will greatly speed up the per--packet latency.
4094+
It also increases the initialization time and isn't suitable when you are going to use a key a few times only.
40344095
40354096
\subsection{SMALL\_CODE}
40364097
When this is defined some of the code such as the Rijndael and SAFER+ ciphers are replaced with smaller code variants.
@@ -4061,6 +4122,13 @@ \subsection{LTC\_FAST}
40614122
of your block cipher (e.g. 16 bytes for AES). This means sadly if you're on a platform with 57--bit words (or something) you can't
40624123
use this mode. So sad.
40634124
4125+
\subsection{LTC\_PTHREAD}
4126+
When this is activated all of the descriptor table functions will use pthread locking to ensure thread safe updates to the tables. Note that
4127+
it doesn't prevent a thread that is passively using a table from being messed up by another thread that updates the table.
4128+
4129+
Generally the rule of thumb is to setup the tables once at startup and then leave them be. This added build flag simply makes updating
4130+
the tables safer.
4131+
40644132
\section{MPI Tweaks}
40654133
\subsection{RSA Only Tweak}
40664134
If you plan on only using RSA with moduli in the range of 1024 to 2560 bits you can enable a series of tweaks
@@ -4491,5 +4559,5 @@ \subsection{Exporting and Importing}
44914559
\end{document}
44924560
44934561
% $Source: /cvs/libtom/libtomcrypt/crypt.tex,v $
4494-
% $Revision: 1.33 $
4495-
% $Date: 2005/06/14 22:53:24 $
4562+
% $Revision: 1.39 $
4563+
% $Date: 2005/06/27 13:08:28 $

demos/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ int main(void)
88
printf("\nstore_test...."); fflush(stdout); x = store_test(); printf(x ? "failed" : "passed");if (x) exit(EXIT_FAILURE);
99
printf("\ncipher_test..."); fflush(stdout); x = cipher_hash_test(); printf(x ? "failed" : "passed");if (x) exit(EXIT_FAILURE);
1010
printf("\nmodes_test...."); fflush(stdout); x = modes_test(); printf(x ? "failed" : "passed");if (x) exit(EXIT_FAILURE);
11-
printf("\nmac_test......"); fflush(stdout); x = mac_test(); printf(x ? "failed" : "passed");if (x) exit(EXIT_FAILURE);
1211
printf("\nder_test......"); fflush(stdout); x = der_tests(); printf(x ? "failed" : "passed");if (x) exit(EXIT_FAILURE);
12+
printf("\nmac_test......"); fflush(stdout); x = mac_test(); printf(x ? "failed" : "passed");if (x) exit(EXIT_FAILURE);
1313
printf("\npkcs_1_test..."); fflush(stdout); x = pkcs_1_test(); printf(x ? "failed" : "passed");if (x) exit(EXIT_FAILURE);
1414
printf("\nrsa_test......"); fflush(stdout); x = rsa_test(); printf(x ? "failed" : "passed");if (x) exit(EXIT_FAILURE);
1515
printf("\necc_test......"); fflush(stdout); x = ecc_tests(); printf(x ? "failed" : "passed");if (x) exit(EXIT_FAILURE);

doc/crypt.pdf

7.56 KB
Binary file not shown.

0 commit comments

Comments
 (0)