diff --git a/Doxyfile b/Doxyfile index 1b70a62..d42b778 100644 --- a/Doxyfile +++ b/Doxyfile @@ -23,7 +23,7 @@ PROJECT_NAME = LibTomCrypt # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 1.00rc1 +PROJECT_NUMBER = 1.02 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. diff --git a/changes b/changes index bdc2c06..54480cf 100644 --- a/changes +++ b/changes @@ -1,3 +1,11 @@ +April 19th, 2005 +v1.02 + -- Added LTC_TEST support to gcm_test() + -- "pt/ct" can now be NULL in gcm_process() if you are processing zero bytes + -- Optimized GCM by removing the "double copy" handling of the plaintext/aad + -- Richard Outerbridge pointed out that x86_prof won't build on MACOS and that the manual + erroneously refers to "mycrypt" all over the place. Fixed. + April 17th, 2005 v1.01 ** Secure Science Corporation has supported this release cycle by sponsoring the development time taken. Their @@ -54,7 +62,7 @@ v1.01 -- Added "stest" build to intel CC to test static linked from within the dir (so you don't have to install to test) -- Moved testing/benchmark into testprof directory and build it as part of the build. Now you can link against libtomcrypt_prof.a to get testing info (hint: hardware developers ;-) ) - -- Added CCM to tv_gen + -- Added CCM to tv_gen -- Added demos to MSVC makefile -- Removed -funroll-all-loops from GCC makefile and replaced with -funroll-loops which is a bit more sane (P4 ain't got much cache for the IDATA) -- Fixed GCM prior to release and re-enabled it. It has not been optimized but it does conform when compiled with optimizations. diff --git a/crypt.tex b/crypt.tex index fd8f2e7..c785e83 100644 --- a/crypt.tex +++ b/crypt.tex @@ -47,7 +47,7 @@ \def\gap{\vspace{0.5ex}} \makeindex \begin{document} -\title{LibTomCrypt \\ Version 1.01} +\title{LibTomCrypt \\ Version 1.02} \author{Tom St Denis \\ \\ tomstdenis@gmail.com \\ @@ -167,7 +167,7 @@ The project is hereby released as public domain. The author (Tom St Denis) is not a patent lawyer so this section is not to be treated as legal advice. To the best of the authors knowledge the only patent related issues within the library are the RC5 and RC6 symmetric block ciphers. -They can be removed from a build by simply commenting out the two appropriate lines in ``mycrypt\_custom.h''. The rest +They can be removed from a build by simply commenting out the two appropriate lines in ``tomcrypt\_custom.h''. The rest of the ciphers and hashes are patent free or under patents that have since expired. The RC2 and RC4 symmetric ciphers are not under patents but are under trademark regulations. This means you can use @@ -593,7 +593,7 @@ byte string from the real 7/21 byte key. \item Note that ``Twofish'' has additional configuration options that take place at build time. These options are found in -the file ``mycrypt\_cfg.h''. The first option is ``TWOFISH\_SMALL'' which when defined will force the Twofish code +the file ``tomcrypt\_cfg.h''. The first option is ``TWOFISH\_SMALL'' which when defined will force the Twofish code to not pre-compute the Twofish ``$g(X)$'' function as a set of four $8 \times 32$ s-boxes. This means that a scheduled key will require less ram but the resulting cipher will be slower. The second option is ``TWOFISH\_TABLES'' which when defined will force the Twofish code to use pre-computed tables for the two s-boxes $q_0, q_1$ as well as the multiplication @@ -3728,8 +3728,8 @@ This will use libtool and gcc to build a shared library ``libtomcrypt.la'' as we and install them into /usr/lib (and the headers into /usr/include). To link your application you should use the libtool program in ``--mode=link''. -\section{mycrypt\_cfg.h} -The file ``mycrypt\_cfg.h'' is what lets you control various high level macros which control the behaviour +\section{tomcrypt\_cfg.h} +The file ``tomcrypt\_cfg.h'' is what lets you control various high level macros which control the behaviour of the library. \subsubsection{ARGTYPE} @@ -3748,10 +3748,10 @@ which will work on all platforms. Currently LibTomCrypt will detect x86-32 and x86-64 running GCC as well as x86-32 running MSVC. \section{The Configure Script} -There are also options you can specify from the configure script or ``mycrypt\_custom.h''. +There are also options you can specify from the configure script or ``tomcrypt\_custom.h''. \subsection{X memory routines} -At the top of mycrypt\_custom.h are four macros denoted as XMALLOC, XCALLOC, XREALLOC and XFREE which resolve to +At the top of tomcrypt\_custom.h are four macros denoted as XMALLOC, XCALLOC, XREALLOC and XFREE which resolve to the name of the respective functions. This lets you substitute in your own memory routines. If you substitute in your own functions they must behave like the standard C library functions in terms of what they expect as input and output. By default the library uses the standard C routines. @@ -3830,7 +3830,7 @@ If you plan on only using RSA with moduli in the range of 1024 to 2560 bits you to reduce the library size. Follow these steps \begin{enumerate} - \item Undefine MDSA, MECC and MDH from mycrypt\_custom.h + \item Undefine MDSA, MECC and MDH from tomcrypt\_custom.h \item Undefine LTM\_ALL from tommath\_superclass.h \item Define SC\_RSA\_1 from tommath\_superclass.h \item Rebuild the library. diff --git a/doc/crypt.pdf b/doc/crypt.pdf index b687065..9eb60c6 100644 Binary files a/doc/crypt.pdf and b/doc/crypt.pdf differ diff --git a/makefile b/makefile index 7562570..b38aa17 100644 --- a/makefile +++ b/makefile @@ -4,7 +4,7 @@ # Modified by Clay Culver # The version -VERSION=1.01 +VERSION=1.02 # Compiler and Linker Names #CC=gcc diff --git a/makefile.shared b/makefile.shared index 2c5c4b3..207ceea 100644 --- a/makefile.shared +++ b/makefile.shared @@ -6,7 +6,7 @@ # Tom St Denis # The version -VERSION=0:101 +VERSION=0:102 # Compiler and Linker Names CC=libtool --mode=compile gcc diff --git a/src/encauth/gcm/gcm_add_aad.c b/src/encauth/gcm/gcm_add_aad.c index 7354e3a..cdcc0d9 100644 --- a/src/encauth/gcm/gcm_add_aad.c +++ b/src/encauth/gcm/gcm_add_aad.c @@ -101,13 +101,10 @@ int gcm_add_aad(gcm_state *gcm, /* start adding AAD data to the state */ for (; x < adatalen; x++) { - gcm->buf[gcm->buflen++] = *adata++; + gcm->X[gcm->buflen++] ^= *adata++; if (gcm->buflen == 16) { /* GF mult it */ - for (y = 0; y < 16; y++) { - gcm->X[y] ^= gcm->buf[y]; - } gcm_mult_h(gcm, gcm->X); gcm->buflen = 0; gcm->totlen += 128; diff --git a/src/encauth/gcm/gcm_done.c b/src/encauth/gcm/gcm_done.c index 49ca638..8b3a6dd 100644 --- a/src/encauth/gcm/gcm_done.c +++ b/src/encauth/gcm/gcm_done.c @@ -49,9 +49,6 @@ int gcm_done(gcm_state *gcm, /* handle remaining ciphertext */ if (gcm->buflen) { - for (x = 0; x < (unsigned long)gcm->buflen; x++) { - gcm->X[x] ^= gcm->buf[x]; - } gcm->pttotlen += gcm->buflen * CONST64(8); gcm_mult_h(gcm, gcm->X); } diff --git a/src/encauth/gcm/gcm_process.c b/src/encauth/gcm/gcm_process.c index 15a9c07..577967b 100644 --- a/src/encauth/gcm/gcm_process.c +++ b/src/encauth/gcm/gcm_process.c @@ -36,8 +36,10 @@ int gcm_process(gcm_state *gcm, int err; LTC_ARGCHK(gcm != NULL); - LTC_ARGCHK(pt != NULL); - LTC_ARGCHK(ct != NULL); + if (ptlen > 0) { + LTC_ARGCHK(pt != NULL); + LTC_ARGCHK(ct != NULL); + } if (gcm->buflen > 16 || gcm->buflen < 0) { return CRYPT_INVALID_ARG; @@ -51,9 +53,6 @@ int gcm_process(gcm_state *gcm, if (gcm->mode == GCM_MODE_AAD) { /* let's process the AAD */ if (gcm->buflen) { - for (x = 0; x < (unsigned long)gcm->buflen; x++) { - gcm->X[x] ^= gcm->buf[x]; - } gcm->totlen += gcm->buflen * CONST64(8); gcm_mult_h(gcm, gcm->X); } @@ -115,9 +114,6 @@ int gcm_process(gcm_state *gcm, /* process text */ for (; x < ptlen; x++) { if (gcm->buflen == 16) { - for (y = 0; y < 16; y++) { - gcm->X[y] ^= gcm->buf[y]; - } gcm->pttotlen += 128; gcm_mult_h(gcm, gcm->X); @@ -135,7 +131,7 @@ int gcm_process(gcm_state *gcm, b = ct[x]; pt[x] = ct[x] ^ gcm->buf[gcm->buflen]; } - gcm->buf[gcm->buflen++] = b; + gcm->X[gcm->buflen++] ^= b; } return CRYPT_OK; diff --git a/src/encauth/gcm/gcm_test.c b/src/encauth/gcm/gcm_test.c index 7c20967..bc6ad7e 100644 --- a/src/encauth/gcm/gcm_test.c +++ b/src/encauth/gcm/gcm_test.c @@ -23,6 +23,9 @@ */ int gcm_test(void) { +#ifndef LTC_TEST + return CRYPT_NOP; +#else static const struct { unsigned char K[32]; int keylen; @@ -355,6 +358,7 @@ int gcm_test(void) } return CRYPT_OK; +#endif } #endif diff --git a/src/headers/tomcrypt.h b/src/headers/tomcrypt.h index b1745c0..0d34c74 100644 --- a/src/headers/tomcrypt.h +++ b/src/headers/tomcrypt.h @@ -16,8 +16,8 @@ extern "C" { #endif /* version */ -#define CRYPT 0x0101 -#define SCRYPT "1.01" +#define CRYPT 0x0102 +#define SCRYPT "1.02" /* max size of either a cipher/hash block or symmetric key [largest of the two] */ #define MAXBLOCKSIZE 128 diff --git a/src/mac/pelican/pelican.c b/src/mac/pelican/pelican.c index d47bd56..fb7ce58 100644 --- a/src/mac/pelican/pelican.c +++ b/src/mac/pelican/pelican.c @@ -142,7 +142,7 @@ int pelican_done(pelican_state *pelmac, unsigned char *out) } pelmac->state[pelmac->buflen++] ^= 0x80; aes_ecb_encrypt(pelmac->state, out, &pelmac->K); - aes_done(&pelmac->K); + aes_done(&pelmac->K); return CRYPT_OK; } diff --git a/src/pk/rsa/rsa_import.c b/src/pk/rsa/rsa_import.c index 6ceac44..5408df0 100644 --- a/src/pk/rsa/rsa_import.c +++ b/src/pk/rsa/rsa_import.c @@ -51,7 +51,7 @@ int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key) /* ok all the ASN.1 params are fine so far, let's move up */ x = ((unsigned long)in[2]); y = 0; - if ((in[1] & 0x0f) == 2) { + if ((in[1] & ~0x80) == 2) { x = (x << 8) + ((unsigned long)in[3]) + 1; in += 1; y = 1; diff --git a/testprof/x86_prof.c b/testprof/x86_prof.c index edccf55..bcc25f4 100644 --- a/testprof/x86_prof.c +++ b/testprof/x86_prof.c @@ -51,12 +51,14 @@ ulong64 rdtsc (void) ulong64 a; asm __volatile__ ("rdtsc\nmovl %%eax,(%0)\nmovl %%edx,4(%0)\n"::"r"(&a):"%eax","%edx"); return a; - #else /* gcc-IA64 version */ + #elif defined(__ia64__) /* gcc-IA64 version */ unsigned long result; __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory"); while (__builtin_expect ((int) result == -1, 0)) __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory"); return result; + #else + return XCLOCK(); #endif // Microsoft and Intel Windows compilers @@ -70,7 +72,7 @@ ulong64 rdtsc (void) #endif return __getReg (3116); #else - #error need rdtsc function for this build + return XCLOCK(); #endif }