Browse Source

added libtomcrypt-1.02

Tom St Denis 20 years ago
parent
commit
65c1317eee

+ 1 - 1
Doxyfile

@@ -23,7 +23,7 @@ PROJECT_NAME           = LibTomCrypt
 # This could be handy for archiving the generated documentation or 
 # This could be handy for archiving the generated documentation or 
 # if some version control system is used.
 # 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) 
 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
 # base path where the generated documentation will be put. 
 # base path where the generated documentation will be put. 

+ 9 - 1
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
 April 17th, 2005
 v1.01
 v1.01
        ** Secure Science Corporation has supported this release cycle by sponsoring the development time taken.  Their 
        ** 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)
        -- 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 
        -- 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 ;-) )
           testing info (hint: hardware developers ;-) )
-		 -- Added CCM to tv_gen 
+       -- Added CCM to tv_gen 
        -- Added demos to MSVC makefile
        -- 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)
        -- 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.
        -- Fixed GCM prior to release and re-enabled it.  It has not been optimized but it does conform when compiled with optimizations.

+ 8 - 8
crypt.tex

@@ -47,7 +47,7 @@
 \def\gap{\vspace{0.5ex}}
 \def\gap{\vspace{0.5ex}}
 \makeindex
 \makeindex
 \begin{document}
 \begin{document}
-\title{LibTomCrypt \\ Version 1.01}
+\title{LibTomCrypt \\ Version 1.02}
 \author{Tom St Denis \\
 \author{Tom St Denis \\
 \\
 \\
 [email protected] \\
 [email protected] \\
@@ -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
 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.  
 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.
 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 
 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
 \item
 Note that ``Twofish'' has additional configuration options that take place at build time.  These options are found in
 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
 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
 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
 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 
 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''.
 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. 
 of the library. 
 
 
 \subsubsection{ARGTYPE}
 \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.  
 Currently LibTomCrypt will detect x86-32 and x86-64 running GCC as well as x86-32 running MSVC.  
 
 
 \section{The Configure Script}
 \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}
 \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 
 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 
 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.
 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
 to reduce the library size.  Follow these steps
 
 
 \begin{enumerate}
 \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 Undefine LTM\_ALL  from tommath\_superclass.h
    \item Define SC\_RSA\_1 from tommath\_superclass.h
    \item Define SC\_RSA\_1 from tommath\_superclass.h
    \item Rebuild the library.
    \item Rebuild the library.

BIN
doc/crypt.pdf


+ 1 - 1
makefile

@@ -4,7 +4,7 @@
 # Modified by Clay Culver
 # Modified by Clay Culver
 
 
 # The version
 # The version
-VERSION=1.01
+VERSION=1.02
 
 
 # Compiler and Linker Names
 # Compiler and Linker Names
 #CC=gcc
 #CC=gcc

+ 1 - 1
makefile.shared

@@ -6,7 +6,7 @@
 # Tom St Denis
 # Tom St Denis
 
 
 # The version
 # The version
-VERSION=0:101
+VERSION=0:102
 
 
 # Compiler and Linker Names
 # Compiler and Linker Names
 CC=libtool --mode=compile gcc
 CC=libtool --mode=compile gcc

+ 1 - 4
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 */
    /* start adding AAD data to the state */
    for (; x < adatalen; x++) {
    for (; x < adatalen; x++) {
-       gcm->buf[gcm->buflen++] = *adata++;
+       gcm->X[gcm->buflen++] ^= *adata++;
 
 
        if (gcm->buflen == 16) {
        if (gcm->buflen == 16) {
          /* GF mult it */
          /* GF mult it */
-         for (y = 0; y < 16; y++) {
-             gcm->X[y] ^= gcm->buf[y];
-         }
          gcm_mult_h(gcm, gcm->X);
          gcm_mult_h(gcm, gcm->X);
          gcm->buflen = 0;
          gcm->buflen = 0;
          gcm->totlen += 128;
          gcm->totlen += 128;

+ 0 - 3
src/encauth/gcm/gcm_done.c

@@ -49,9 +49,6 @@ int gcm_done(gcm_state *gcm,
 
 
    /* handle remaining ciphertext */
    /* handle remaining ciphertext */
    if (gcm->buflen) {
    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->pttotlen += gcm->buflen * CONST64(8);
       gcm_mult_h(gcm, gcm->X);
       gcm_mult_h(gcm, gcm->X);
    }
    }

+ 5 - 9
src/encauth/gcm/gcm_process.c

@@ -36,8 +36,10 @@ int gcm_process(gcm_state *gcm,
    int           err;
    int           err;
 
 
    LTC_ARGCHK(gcm != NULL);
    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) {
    if (gcm->buflen > 16 || gcm->buflen < 0) {
       return CRYPT_INVALID_ARG;
       return CRYPT_INVALID_ARG;
@@ -51,9 +53,6 @@ int gcm_process(gcm_state *gcm,
    if (gcm->mode == GCM_MODE_AAD) {
    if (gcm->mode == GCM_MODE_AAD) {
       /* let's process the AAD */
       /* let's process the AAD */
       if (gcm->buflen) {
       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->totlen += gcm->buflen * CONST64(8);
          gcm_mult_h(gcm, gcm->X);
          gcm_mult_h(gcm, gcm->X);
       }
       }
@@ -115,9 +114,6 @@ int gcm_process(gcm_state *gcm,
    /* process text */
    /* process text */
    for (; x < ptlen; x++) {
    for (; x < ptlen; x++) {
        if (gcm->buflen == 16) {
        if (gcm->buflen == 16) {
-          for (y = 0; y < 16; y++) {
-              gcm->X[y] ^= gcm->buf[y];
-          }
           gcm->pttotlen += 128;
           gcm->pttotlen += 128;
           gcm_mult_h(gcm, gcm->X);
           gcm_mult_h(gcm, gcm->X);
           
           
@@ -135,7 +131,7 @@ int gcm_process(gcm_state *gcm,
           b = ct[x];
           b = ct[x];
           pt[x] = ct[x] ^ gcm->buf[gcm->buflen];
           pt[x] = ct[x] ^ gcm->buf[gcm->buflen];
        }
        }
-       gcm->buf[gcm->buflen++] = b;          
+       gcm->X[gcm->buflen++] ^= b;          
    }
    }
 
 
    return CRYPT_OK;
    return CRYPT_OK;

+ 4 - 0
src/encauth/gcm/gcm_test.c

@@ -23,6 +23,9 @@
  */
  */
 int gcm_test(void)
 int gcm_test(void)
 {
 {
+#ifndef LTC_TEST
+   return CRYPT_NOP;
+#else
    static const struct {
    static const struct {
        unsigned char K[32];
        unsigned char K[32];
        int           keylen;
        int           keylen;
@@ -355,6 +358,7 @@ int gcm_test(void)
 
 
    }
    }
    return CRYPT_OK;
    return CRYPT_OK;
+#endif
 }
 }
 
 
 #endif
 #endif

+ 2 - 2
src/headers/tomcrypt.h

@@ -16,8 +16,8 @@ extern "C" {
 #endif
 #endif
 
 
 /* version */
 /* 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] */
 /* max size of either a cipher/hash block or symmetric key [largest of the two] */
 #define MAXBLOCKSIZE  128
 #define MAXBLOCKSIZE  128

+ 1 - 1
src/mac/pelican/pelican.c

@@ -142,7 +142,7 @@ int pelican_done(pelican_state *pelmac, unsigned char *out)
    }
    }
    pelmac->state[pelmac->buflen++] ^= 0x80;
    pelmac->state[pelmac->buflen++] ^= 0x80;
    aes_ecb_encrypt(pelmac->state, out, &pelmac->K);
    aes_ecb_encrypt(pelmac->state, out, &pelmac->K);
-	aes_done(&pelmac->K);
+   aes_done(&pelmac->K);
    return CRYPT_OK;
    return CRYPT_OK;
 }                        
 }                        
 
 

+ 1 - 1
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 */
    /* ok all the ASN.1 params are fine so far, let's move up */
    x = ((unsigned long)in[2]);
    x = ((unsigned long)in[2]);
    y = 0;
    y = 0;
-   if ((in[1] & 0x0f) == 2) {
+   if ((in[1] & ~0x80) == 2) {
       x   = (x << 8) + ((unsigned long)in[3]) + 1;
       x   = (x << 8) + ((unsigned long)in[3]) + 1;
       in += 1;
       in += 1;
       y   = 1;
       y   = 1;

+ 4 - 2
testprof/x86_prof.c

@@ -51,12 +51,14 @@ ulong64 rdtsc (void)
          ulong64 a;
          ulong64 a;
          asm __volatile__ ("rdtsc\nmovl %%eax,(%0)\nmovl %%edx,4(%0)\n"::"r"(&a):"%eax","%edx");
          asm __volatile__ ("rdtsc\nmovl %%eax,(%0)\nmovl %%edx,4(%0)\n"::"r"(&a):"%eax","%edx");
          return a;
          return a;
-      #else /* gcc-IA64 version */
+      #elif defined(__ia64__)  /* gcc-IA64 version */
          unsigned long result;
          unsigned long result;
          __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
          __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
          while (__builtin_expect ((int) result == -1, 0))
          while (__builtin_expect ((int) result == -1, 0))
          __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
          __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
          return result;
          return result;
+      #else 
+         return XCLOCK();
       #endif
       #endif
 
 
    // Microsoft and Intel Windows compilers
    // Microsoft and Intel Windows compilers
@@ -70,7 +72,7 @@ ulong64 rdtsc (void)
      #endif
      #endif
       return __getReg (3116);
       return __getReg (3116);
    #else
    #else
-     #error need rdtsc function for this build
+     return XCLOCK();
    #endif
    #endif
    }
    }