47fa612
diff -Naur bacula-7.0.3.old/src/lib/lib.h bacula-7.0.3/src/lib/lib.h
47fa612
--- bacula-7.0.3.old/src/lib/lib.h	2014-05-15 15:45:13.745148756 +0200
47fa612
+++ bacula-7.0.3/src/lib/lib.h	2014-05-15 15:52:33.005327683 +0200
47fa612
@@ -47,7 +47,6 @@
47fa612
 #include "fnmatch.h"
47fa612
 #endif
47fa612
 #include "md5.h"
47fa612
-#include "sha1.h"
47fa612
 #include "tree.h"
47fa612
 #include "watchdog.h"
47fa612
 #include "btimers.h"
47fa612
diff -Naur bacula-7.0.3.old/src/lib/Makefile.in bacula-7.0.3/src/lib/Makefile.in
47fa612
--- bacula-7.0.3.old/src/lib/Makefile.in	2014-05-15 15:45:13.748148724 +0200
47fa612
+++ bacula-7.0.3/src/lib/Makefile.in	2014-05-15 15:52:33.005327683 +0200
47fa612
@@ -37,7 +37,7 @@
c0772e3
 		fnmatch.h guid_to_name.h htable.h lex.h \
c0772e3
 		lib.h md5.h mem_pool.h message.h mntent_cache.h \
c0772e3
 		openssl.h plugins.h protos.h queue.h rblist.h \
c0772e3
-		runscript.h rwlock.h serial.h sellist.h sha1.h \
c0772e3
+		runscript.h rwlock.h serial.h sellist.h \
c0772e3
 		smartall.h status.h tls.h tree.h var.h \
c0772e3
 		waitq.h watchdog.h workq.h \
c0772e3
 		parse_conf.h ini.h \
47fa612
@@ -53,7 +53,7 @@
c0772e3
 	      guid_to_name.c hmac.c jcr.c lex.c alist.c dlist.c \
c0772e3
 	      md5.c message.c mem_pool.c mntent_cache.c openssl.c \
c0772e3
 	      plugins.c priv.c queue.c bregex.c \
c0772e3
-	      rwlock.c scan.c sellist.c serial.c sha1.c \
c0772e3
+	      rwlock.c scan.c sellist.c serial.c \
c0772e3
 	      signal.c smartall.c rblist.c tls.c tree.c \
c0772e3
 	      util.c var.c watchdog.c workq.c btimers.c \
c0772e3
 	      address_conf.c breg.c htable.c lockmgr.c devlock.c
47fa612
@@ -169,13 +169,6 @@
c0772e3
 	$(RMF) md5.o
c0772e3
 	$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) md5.c
c0772e3
 
c0772e3
-sha1sum: Makefile sha1.o
c0772e3
-	$(RMF) sha1.o
c0772e3
-	$(CXX) -DSHA1_SUM $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE)	$(CFLAGS) sha1.c
c0772e3
-	$(LIBTOOL_LINK) $(CXX) $(LDFLAGS) -L. -o $@ sha1.o $(DLIB) -lbac -lm $(LIBS) $(OPENSSL_LIBS)
c0772e3
-	$(RMF) sha1.o
c0772e3
-	$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) sha1.c
c0772e3
-
c0772e3
 bsnprintf: Makefile bsnprintf.o
c0772e3
 	$(RMF) bsnprintf.o
c0772e3
 	$(CXX) -DTEST_PROGRAM $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE)  $(CFLAGS) bsnprintf.c
47fa612
@@ -225,7 +218,7 @@
c0772e3
 
c0772e3
 clean:	libtool-clean
c0772e3
 	@$(RMF) core a.out *.o *.bak *.tex *.pdf *~ *.intpro *.extpro 1 2 3
c0772e3
-	@$(RMF) rwlock_test md5sum sha1sum
c0772e3
+	@$(RMF) rwlock_test md5sum
c0772e3
 
c0772e3
 realclean: clean
c0772e3
 	@$(RMF) tags
47fa612
diff -Naur bacula-7.0.3.old/src/lib/sha1.c bacula-7.0.3/src/lib/sha1.c
47fa612
--- bacula-7.0.3.old/src/lib/sha1.c	2014-05-15 15:45:13.745148756 +0200
47fa612
+++ bacula-7.0.3/src/lib/sha1.c	1970-01-01 01:00:00.000000000 +0100
c0772e3
@@ -1,510 +0,0 @@
c0772e3
-/*
c0772e3
- *  sha1.c
c0772e3
- *
c0772e3
- *  Description:
c0772e3
- *      This file implements the Secure Hashing Algorithm 1 as
c0772e3
- *      defined in FIPS PUB 180-1 published April 17, 1995.
c0772e3
- *
c0772e3
- *      The SHA-1, produces a 160-bit message digest for a given
c0772e3
- *      data stream.  It should take about 2**n steps to find a
c0772e3
- *      message with the same digest as a given message and
c0772e3
- *      2**(n/2) to find any two messages with the same digest,
c0772e3
- *      when n is the digest size in bits.  Therefore, this
c0772e3
- *      algorithm can serve as a means of providing a
c0772e3
- *      "fingerprint" for a message.
c0772e3
- *
c0772e3
- *  Portability Issues:
c0772e3
- *      SHA-1 is defined in terms of 32-bit "words".  This code
c0772e3
- *      uses <stdint.h> (included via "sha1.h" to define 32 and 8
c0772e3
- *      bit unsigned integer types.  If your C compiler does not
c0772e3
- *      support 32 bit unsigned integers, this code is not
c0772e3
- *      appropriate.
c0772e3
- *
c0772e3
- *  Caveats:
c0772e3
- *      SHA-1 is designed to work with messages less than 2^64 bits
c0772e3
- *      long.  Although SHA-1 allows a message digest to be generated
c0772e3
- *      for messages of any number of bits less than 2^64, this
c0772e3
- *      implementation only works with messages with a length that is
c0772e3
- *      a multiple of the size of an 8-bit character.
c0772e3
- *
c0772e3
- *  See sha1.h for copyright
c0772e3
- */
c0772e3
-
c0772e3
-#include "sha1.h"
c0772e3
-
c0772e3
-/*
c0772e3
- *  Define the SHA1 circular left shift macro
c0772e3
- */
c0772e3
-#define SHA1CircularShift(bits,word) \
c0772e3
-                (((word) << (bits)) | ((word) >> (32-(bits))))
c0772e3
-
c0772e3
-/* Local Function Prototyptes */
c0772e3
-static void SHA1PadMessage(SHA1Context *);
c0772e3
-static void SHA1ProcessMessageBlock(SHA1Context *);
c0772e3
-
c0772e3
-/*
c0772e3
- *  SHA1Init
c0772e3
- *
c0772e3
- *  Description:
c0772e3
- *      This function will initialize the SHA1Context in preparation
c0772e3
- *      for computing a new SHA1 message digest.
c0772e3
- *
c0772e3
- *  Parameters:
c0772e3
- *      context: [in/out]
c0772e3
- *          The context to reset.
c0772e3
- *
c0772e3
- *  Returns:
c0772e3
- *      sha Error Code.
c0772e3
- *
c0772e3
- */
c0772e3
-int SHA1Init(SHA1Context *context)
c0772e3
-{
c0772e3
-    if (!context)
c0772e3
-    {
c0772e3
-        return shaNull;
c0772e3
-    }
c0772e3
-
c0772e3
-    context->Length_Low             = 0;
c0772e3
-    context->Length_High            = 0;
c0772e3
-    context->Message_Block_Index    = 0;
c0772e3
-
c0772e3
-    context->Intermediate_Hash[0]   = 0x67452301;
c0772e3
-    context->Intermediate_Hash[1]   = 0xEFCDAB89;
c0772e3
-    context->Intermediate_Hash[2]   = 0x98BADCFE;
c0772e3
-    context->Intermediate_Hash[3]   = 0x10325476;
c0772e3
-    context->Intermediate_Hash[4]   = 0xC3D2E1F0;
c0772e3
-
c0772e3
-    context->Computed   = 0;
c0772e3
-    context->Corrupted  = 0;
c0772e3
-
c0772e3
-    return shaSuccess;
c0772e3
-}
c0772e3
-
c0772e3
-/*
c0772e3
- *  SHA1Final
c0772e3
- *
c0772e3
- *  Description:
c0772e3
- *      This function will return the 160-bit message digest into the
c0772e3
- *      Message_Digest array  provided by the caller.
c0772e3
- *      NOTE: The first octet of hash is stored in the 0th element,
c0772e3
- *            the last octet of hash in the 19th element.
c0772e3
- *
c0772e3
- *  Parameters:
c0772e3
- *      context: [in/out]
c0772e3
- *          The context to use to calculate the SHA-1 hash.
c0772e3
- *      Message_Digest: [out]
c0772e3
- *          Where the digest is returned.
c0772e3
- *
c0772e3
- *  Returns:
c0772e3
- *      sha Error Code.
c0772e3
- *
c0772e3
- */
c0772e3
-int SHA1Final(SHA1Context *context,
c0772e3
-              uint8_t Message_Digest[SHA1HashSize])
c0772e3
-{
c0772e3
-    int i;
c0772e3
-
c0772e3
-    if (!context || !Message_Digest) {
c0772e3
-        return shaNull;
c0772e3
-    }
c0772e3
-
c0772e3
-    if (context->Corrupted) {
c0772e3
-        return context->Corrupted;
c0772e3
-    }
c0772e3
-
c0772e3
-    if (!context->Computed) {
c0772e3
-        SHA1PadMessage(context);
c0772e3
-        for(i=0; i<64; ++i) {
c0772e3
-            /* message may be sensitive, clear it out */
c0772e3
-            context->Message_Block[i] = 0;
c0772e3
-        }
c0772e3
-        context->Length_Low = 0;    /* and clear length */
c0772e3
-        context->Length_High = 0;
c0772e3
-        context->Computed = 1;
c0772e3
-
c0772e3
-    }
c0772e3
-
c0772e3
-    for(i = 0; i < SHA1HashSize; ++i) {
c0772e3
-        Message_Digest[i] = context->Intermediate_Hash[i>>2]
c0772e3
-                            >> 8 * ( 3 - ( i & 0x03 ) );
c0772e3
-    }
c0772e3
-
c0772e3
-    return shaSuccess;
c0772e3
-}
c0772e3
-
c0772e3
-/*
c0772e3
- *  SHA1Update
c0772e3
- *
c0772e3
- *  Description:
c0772e3
- *      This function accepts an array of octets as the next portion
c0772e3
- *      of the message.
c0772e3
- *
c0772e3
- *  Parameters:
c0772e3
- *      context: [in/out]
c0772e3
- *          The SHA context to update
c0772e3
- *      message_array: [in]
c0772e3
- *          An array of characters representing the next portion of
c0772e3
- *          the message.
c0772e3
- *      length: [in]
c0772e3
- *          The length of the message in message_array
c0772e3
- *
c0772e3
- *  Returns:
c0772e3
- *      sha Error Code.
c0772e3
- *
c0772e3
- */
c0772e3
-int SHA1Update(SHA1Context    *context,
c0772e3
-               const uint8_t  *message_array,
c0772e3
-               unsigned       length)
c0772e3
-{
c0772e3
-    if (!length) {
c0772e3
-        return shaSuccess;
c0772e3
-    }
c0772e3
-
c0772e3
-    if (!context || !message_array) {
c0772e3
-        return shaNull;
c0772e3
-    }
c0772e3
-
c0772e3
-    if (context->Computed) {
c0772e3
-        context->Corrupted = shaStateError;
c0772e3
-
c0772e3
-        return shaStateError;
c0772e3
-    }
c0772e3
-
c0772e3
-    if (context->Corrupted) {
c0772e3
-         return context->Corrupted;
c0772e3
-    }
c0772e3
-    while(length-- && !context->Corrupted) {
c0772e3
-       context->Message_Block[context->Message_Block_Index++] =
c0772e3
-                    (*message_array & 0xFF);
c0772e3
-
c0772e3
-       context->Length_Low += 8;
c0772e3
-       if (context->Length_Low == 0) {
c0772e3
-           context->Length_High++;
c0772e3
-           if (context->Length_High == 0) {
c0772e3
-               /* Message is too long */
c0772e3
-               context->Corrupted = 1;
c0772e3
-           }
c0772e3
-       }
c0772e3
-
c0772e3
-       if (context->Message_Block_Index == 64) {
c0772e3
-           SHA1ProcessMessageBlock(context);
c0772e3
-       }
c0772e3
-
c0772e3
-       message_array++;
c0772e3
-    }
c0772e3
-
c0772e3
-    return shaSuccess;
c0772e3
-}
c0772e3
-
c0772e3
-/*
c0772e3
- *  SHA1ProcessMessageBlock
c0772e3
- *
c0772e3
- *  Description:
c0772e3
- *      This function will process the next 512 bits of the message
c0772e3
- *      stored in the Message_Block array.
c0772e3
- *
c0772e3
- *  Parameters:
c0772e3
- *      None.
c0772e3
- *
c0772e3
- *  Returns:
c0772e3
- *      Nothing.
c0772e3
- *
c0772e3
- *  Comments:
c0772e3
-
c0772e3
- *      Many of the variable names in this code, especially the
c0772e3
- *      single character names, were used because those were the
c0772e3
- *      names used in the publication.
c0772e3
- *
c0772e3
- *
c0772e3
- */
c0772e3
-static void SHA1ProcessMessageBlock(SHA1Context *context)
c0772e3
-{
c0772e3
-    const uint32_t K[] =    {       /* Constants defined in SHA-1   */
c0772e3
-                            0x5A827999,
c0772e3
-                            0x6ED9EBA1,
c0772e3
-                            0x8F1BBCDC,
c0772e3
-                            0xCA62C1D6
c0772e3
-                            };
c0772e3
-    int           t;                 /* Loop counter                */
c0772e3
-    uint32_t      temp;              /* Temporary word value        */
c0772e3
-    uint32_t      W[80];             /* Word sequence               */
c0772e3
-    uint32_t      A, B, C, D, E;     /* Word buffers                */
c0772e3
-
c0772e3
-    /*
c0772e3
-     *  Initialize the first 16 words in the array W
c0772e3
-     */
c0772e3
-    for(t = 0; t < 16; t++) {
c0772e3
-        W[t] = context->Message_Block[t * 4] << 24;
c0772e3
-        W[t] |= context->Message_Block[t * 4 + 1] << 16;
c0772e3
-        W[t] |= context->Message_Block[t * 4 + 2] << 8;
c0772e3
-        W[t] |= context->Message_Block[t * 4 + 3];
c0772e3
-    }
c0772e3
-
c0772e3
-    for(t = 16; t < 80; t++) {
c0772e3
-       W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
c0772e3
-    }
c0772e3
-
c0772e3
-    A = context->Intermediate_Hash[0];
c0772e3
-    B = context->Intermediate_Hash[1];
c0772e3
-    C = context->Intermediate_Hash[2];
c0772e3
-    D = context->Intermediate_Hash[3];
c0772e3
-    E = context->Intermediate_Hash[4];
c0772e3
-
c0772e3
-    for(t = 0; t < 20; t++) {
c0772e3
-        temp =  SHA1CircularShift(5,A) +
c0772e3
-                ((B & C) | ((~B) & D)) + E + W[t] + K[0];
c0772e3
-        E = D;
c0772e3
-        D = C;
c0772e3
-        C = SHA1CircularShift(30,B);
c0772e3
-
c0772e3
-        B = A;
c0772e3
-        A = temp;
c0772e3
-    }
c0772e3
-
c0772e3
-    for(t = 20; t < 40; t++) {
c0772e3
-        temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
c0772e3
-        E = D;
c0772e3
-        D = C;
c0772e3
-        C = SHA1CircularShift(30,B);
c0772e3
-        B = A;
c0772e3
-        A = temp;
c0772e3
-    }
c0772e3
-
c0772e3
-    for(t = 40; t < 60; t++) {
c0772e3
-        temp = SHA1CircularShift(5,A) +
c0772e3
-               ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
c0772e3
-        E = D;
c0772e3
-        D = C;
c0772e3
-        C = SHA1CircularShift(30,B);
c0772e3
-        B = A;
c0772e3
-        A = temp;
c0772e3
-    }
c0772e3
-
c0772e3
-    for(t = 60; t < 80; t++) {
c0772e3
-        temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
c0772e3
-        E = D;
c0772e3
-        D = C;
c0772e3
-        C = SHA1CircularShift(30,B);
c0772e3
-        B = A;
c0772e3
-        A = temp;
c0772e3
-    }
c0772e3
-
c0772e3
-    context->Intermediate_Hash[0] += A;
c0772e3
-    context->Intermediate_Hash[1] += B;
c0772e3
-    context->Intermediate_Hash[2] += C;
c0772e3
-    context->Intermediate_Hash[3] += D;
c0772e3
-    context->Intermediate_Hash[4] += E;
c0772e3
-
c0772e3
-    context->Message_Block_Index = 0;
c0772e3
-}
c0772e3
-
c0772e3
-/*
c0772e3
- *  SHA1PadMessage
c0772e3
- *
c0772e3
-
c0772e3
- *  Description:
c0772e3
- *      According to the standard, the message must be padded to an even
c0772e3
- *      512 bits.  The first padding bit must be a '1'.  The last 64
c0772e3
- *      bits represent the length of the original message.  All bits in
c0772e3
- *      between should be 0.  This function will pad the message
c0772e3
- *      according to those rules by filling the Message_Block array
c0772e3
- *      accordingly.  It will also call the ProcessMessageBlock function
c0772e3
- *      provided appropriately.  When it returns, it can be assumed that
c0772e3
- *      the message digest has been computed.
c0772e3
- *
c0772e3
- *  Parameters:
c0772e3
- *      context: [in/out]
c0772e3
- *          The context to pad
c0772e3
- *      ProcessMessageBlock: [in]
c0772e3
- *          The appropriate SHA*ProcessMessageBlock function
c0772e3
- *  Returns:
c0772e3
- *      Nothing.
c0772e3
- *
c0772e3
- */
c0772e3
-
c0772e3
-static void SHA1PadMessage(SHA1Context *context)
c0772e3
-{
c0772e3
-    /*
c0772e3
-     *  Check to see if the current message block is too small to hold
c0772e3
-     *  the initial padding bits and length.  If so, we will pad the
c0772e3
-     *  block, process it, and then continue padding into a second
c0772e3
-     *  block.
c0772e3
-     */
c0772e3
-    if (context->Message_Block_Index > 55) {
c0772e3
-        context->Message_Block[context->Message_Block_Index++] = 0x80;
c0772e3
-        while(context->Message_Block_Index < 64) {
c0772e3
-            context->Message_Block[context->Message_Block_Index++] = 0;
c0772e3
-        }
c0772e3
-
c0772e3
-        SHA1ProcessMessageBlock(context);
c0772e3
-
c0772e3
-        while(context->Message_Block_Index < 56) {
c0772e3
-            context->Message_Block[context->Message_Block_Index++] = 0;
c0772e3
-        }
c0772e3
-    } else {
c0772e3
-        context->Message_Block[context->Message_Block_Index++] = 0x80;
c0772e3
-        while(context->Message_Block_Index < 56) {
c0772e3
-
c0772e3
-            context->Message_Block[context->Message_Block_Index++] = 0;
c0772e3
-        }
c0772e3
-    }
c0772e3
-
c0772e3
-    /*
c0772e3
-     *  Store the message length as the last 8 octets
c0772e3
-     */
c0772e3
-    context->Message_Block[56] = context->Length_High >> 24;
c0772e3
-    context->Message_Block[57] = context->Length_High >> 16;
c0772e3
-    context->Message_Block[58] = context->Length_High >> 8;
c0772e3
-    context->Message_Block[59] = context->Length_High;
c0772e3
-    context->Message_Block[60] = context->Length_Low >> 24;
c0772e3
-    context->Message_Block[61] = context->Length_Low >> 16;
c0772e3
-    context->Message_Block[62] = context->Length_Low >> 8;
c0772e3
-    context->Message_Block[63] = context->Length_Low;
c0772e3
-
c0772e3
-    SHA1ProcessMessageBlock(context);
c0772e3
-}
c0772e3
-
c0772e3
-#ifdef TEST_DRIVER
c0772e3
-
c0772e3
-/*
c0772e3
- *  sha1test.c
c0772e3
- *
c0772e3
- *  Description:
c0772e3
- *      This file will exercise the SHA-1 code performing the three
c0772e3
- *      tests documented in FIPS PUB 180-1 plus one which calls
c0772e3
- *      SHA1Input with an exact multiple of 512 bits, plus a few
c0772e3
- *      error test checks.
c0772e3
- *
c0772e3
- *  Portability Issues:
c0772e3
- *      None.
c0772e3
- *
c0772e3
- */
c0772e3
-
c0772e3
-#include <stdint.h>
c0772e3
-#include <stdio.h>
c0772e3
-#include <string.h>
c0772e3
-#include "sha1.h"
c0772e3
-
c0772e3
-/*
c0772e3
- *  Define patterns for testing
c0772e3
- */
c0772e3
-#define TEST1   "abc"
c0772e3
-#define TEST2a  "abcdbcdecdefdefgefghfghighijhi"
c0772e3
-
c0772e3
-#define TEST2b  "jkijkljklmklmnlmnomnopnopq"
c0772e3
-#define TEST2   TEST2a TEST2b
c0772e3
-#define TEST3   "a"
c0772e3
-#define TEST4a  "01234567012345670123456701234567"
c0772e3
-#define TEST4b  "01234567012345670123456701234567"
c0772e3
-    /* an exact multiple of 512 bits */
c0772e3
-#define TEST4   TEST4a TEST4b
c0772e3
-char *testarray[4] =
c0772e3
-{
c0772e3
-    TEST1,
c0772e3
-    TEST2,
c0772e3
-    TEST3,
c0772e3
-    TEST4
c0772e3
-};
c0772e3
-long int repeatcount[4] = { 1, 1, 1000000, 10 };
c0772e3
-char *resultarray[4] =
c0772e3
-{
c0772e3
-    "A9 99 3E 36 47 06 81 6A BA 3E 25 71 78 50 C2 6C 9C D0 D8 9D",
c0772e3
-    "84 98 3E 44 1C 3B D2 6E BA AE 4A A1 F9 51 29 E5 E5 46 70 F1",
c0772e3
-    "34 AA 97 3C D4 C4 DA A4 F6 1E EB 2B DB AD 27 31 65 34 01 6F",
c0772e3
-    "DE A3 56 A2 CD DD 90 C7 A7 EC ED C5 EB B5 63 93 4F 46 04 52"
c0772e3
-};
c0772e3
-
c0772e3
-int main()
c0772e3
-{
c0772e3
-    SHA1Context sha;
c0772e3
-    int i, j, err;
c0772e3
-    uint8_t Message_Digest[20];
c0772e3
-
c0772e3
-    /*
c0772e3
-     *  Perform SHA-1 tests
c0772e3
-     */
c0772e3
-    for(j = 0; j < 4; ++j) {
c0772e3
-        printf( "\nTest %d: %d, '%s'\n",
c0772e3
-                j+1,
c0772e3
-                repeatcount[j],
c0772e3
-                testarray[j]);
c0772e3
-
c0772e3
-        err = SHA1Init(&sha);
c0772e3
-        if (err) {
c0772e3
-            fprintf(stderr, "SHA1Reset Error %d.\n", err );
c0772e3
-            break;    /* out of for j loop */
c0772e3
-        }
c0772e3
-
c0772e3
-        for(i = 0; i < repeatcount[j]; ++i) {
c0772e3
-
c0772e3
-            err = SHA1Input(&sha,
c0772e3
-                  (const unsigned char *) testarray[j],
c0772e3
-                  strlen(testarray[j]));
c0772e3
-            if (err) {
c0772e3
-                fprintf(stderr, "SHA1Input Error %d.\n", err );
c0772e3
-                break;    /* out of for i loop */
c0772e3
-            }
c0772e3
-        }
c0772e3
-
c0772e3
-        err = SHA1Final(&sha, Message_Digest);
c0772e3
-        if (err) {
c0772e3
-            fprintf(stderr,
c0772e3
-            "SHA1Result Error %d, could not compute message digest.\n",
c0772e3
-            err );
c0772e3
-        }
c0772e3
-        else
c0772e3
-        {
c0772e3
-            printf("\t");
c0772e3
-            for(i = 0; i < 20 ; ++i) {
c0772e3
-                printf("%02X ", Message_Digest[i]);
c0772e3
-            }
c0772e3
-            printf("\n");
c0772e3
-        }
c0772e3
-        printf("Should match:\n");
c0772e3
-        printf("\t%s\n", resultarray[j]);
c0772e3
-    }
c0772e3
-
c0772e3
-    /* Test some error returns */
c0772e3
-    err = SHA1Input(&sha,(const unsigned char *) testarray[1], 1);
c0772e3
-    printf ("\nError %d. Should be %d.\n", err, shaStateError );
c0772e3
-    err = SHA1Init(0);
c0772e3
-    printf ("\nError %d. Should be %d.\n", err, shaNull );
c0772e3
-    return 0;
c0772e3
-}
c0772e3
-
c0772e3
-#endif /* TEST_DRIVER */
c0772e3
-
c0772e3
-#ifdef SHA1_SUM
c0772e3
-/*
c0772e3
- * Reads a single ASCII file and prints the HEX sha1 sum.
c0772e3
- */
c0772e3
-#include <stdio.h>
c0772e3
-int main(int argc, char *argv[])
c0772e3
-{
c0772e3
-   FILE *fd;
c0772e3
-   SHA1Context ctx;
c0772e3
-   char buf[5000];
c0772e3
-   char signature[25];
c0772e3
-
c0772e3
-   if (argc < 1) {
c0772e3
-      printf("Must have filename\n");
c0772e3
-      exit(1);
c0772e3
-   }
c0772e3
-   fd = fopen(argv[1], "rb");
c0772e3
-   if (!fd) {
c0772e3
-      berrno be;
c0772e3
-      printf("Could not open %s: ERR=%s\n", argv[1], be.bstrerror(errno));
c0772e3
-      exit(1);
c0772e3
-   }
c0772e3
-   SHA1Init(&ctx;;
c0772e3
-   while (fgets(buf, sizeof(buf), fd)) {
c0772e3
-      SHA1Update(&ctx, (unsigned char *)buf, strlen(buf));
c0772e3
-   }
c0772e3
-   SHA1Final(&ctx, (unsigned char *)signature);
c0772e3
-   for (int i=0; i < 20; i++) {
c0772e3
-      printf("%02x", signature[i]& 0xFF);
c0772e3
-   }
c0772e3
-   printf("  %s\n", argv[1]);
c0772e3
-   fclose(fd);
c0772e3
-}
c0772e3
-#endif
47fa612
diff -Naur bacula-7.0.3.old/src/lib/sha1.h bacula-7.0.3/src/lib/sha1.h
47fa612
--- bacula-7.0.3.old/src/lib/sha1.h	2014-05-15 15:45:13.742148789 +0200
47fa612
+++ bacula-7.0.3/src/lib/sha1.h	1970-01-01 01:00:00.000000000 +0100
c0772e3
@@ -1,107 +0,0 @@
c0772e3
-/*
c0772e3
- *  sha1.h
c0772e3
- *
c0772e3
- *  Description:
c0772e3
- *      This is the header file for code which implements the Secure
c0772e3
- *      Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
c0772e3
- *      April 17, 1995.
c0772e3
- *
c0772e3
- *      Many of the variable names in this code, especially the
c0772e3
- *      single character names, were used because those were the names
c0772e3
- *      used in the publication.
c0772e3
- *
c0772e3
- *      Please read the file sha1.c for more information.
c0772e3
- *
c0772e3
- * Full Copyright Statement
c0772e3
- *
c0772e3
- *    Copyright (C) The Internet Society (2001).  All Rights Reserved.
c0772e3
- *
c0772e3
- *    This document and translations of it may be copied and furnished to
c0772e3
- *    others, and derivative works that comment on or otherwise explain it
c0772e3
- *    or assist in its implementation may be prepared, copied, published
c0772e3
- *    and distributed, in whole or in part, without restriction of any
c0772e3
- *    kind, provided that the above copyright notice and this paragraph are
c0772e3
- *    included on all such copies and derivative works.  However, this
c0772e3
- *    document itself may not be modified in any way, such as by removing
c0772e3
- *    the copyright notice or references to the Internet Society or other
c0772e3
- *    Internet organizations, except as needed for the purpose of
c0772e3
- *    developing Internet standards in which case the procedures for
c0772e3
- *    copyrights defined in the Internet Standards process must be
c0772e3
- *    followed, or as required to translate it into languages other than
c0772e3
- *    English.
c0772e3
- *
c0772e3
- *    The limited permissions granted above are perpetual and will not be
c0772e3
- *    revoked by the Internet Society or its successors or assigns.
c0772e3
- *
c0772e3
- *    This document and the information contained herein is provided on an
c0772e3
- *    "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
c0772e3
- *    TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
c0772e3
- *    BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
c0772e3
- *    HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
c0772e3
- *    MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
c0772e3
- *
c0772e3
- * Acknowledgement
c0772e3
- *
c0772e3
- *    Funding for the RFC Editor function is currently provided by the
c0772e3
- *    Internet Society.
c0772e3
- *
c0772e3
- */
c0772e3
-
c0772e3
-#ifndef _SHA1_H_
c0772e3
-#define _SHA1_H_
c0772e3
-
c0772e3
-#include "bacula.h"
c0772e3
-
c0772e3
-/*
c0772e3
- * If you do not have the ISO standard stdint.h header file, then you
c0772e3
- * must typdef the following:
c0772e3
- *    name              meaning
c0772e3
- *  uint32_t         unsigned 32 bit integer
c0772e3
- *  uint8_t          unsigned 8 bit integer (i.e., unsigned char)
c0772e3
- *  int32_t          integer of 32 bits
c0772e3
- *
c0772e3
- */
c0772e3
-
c0772e3
-#ifndef _SHA_enum_
c0772e3
-#define _SHA_enum_
c0772e3
-enum
c0772e3
-{
c0772e3
-    shaSuccess = 0,
c0772e3
-    shaNull,            /* Null pointer parameter */
c0772e3
-    shaInputTooLong,    /* input data too long */
c0772e3
-    shaStateError       /* called Input after Result */
c0772e3
-};
c0772e3
-#endif
c0772e3
-#define SHA1HashSize 20
c0772e3
-
c0772e3
-/*
c0772e3
- *  This structure will hold context information for the SHA-1
c0772e3
- *  hashing operation
c0772e3
- */
c0772e3
-typedef struct SHA1Context
c0772e3
-{
c0772e3
-    uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest  */
c0772e3
-
c0772e3
-    uint32_t Length_Low;            /* Message length in bits      */
c0772e3
-    uint32_t Length_High;           /* Message length in bits      */
c0772e3
-
c0772e3
-			       /* Index into message block array   */
c0772e3
-    int32_t Message_Block_Index;
c0772e3
-    uint8_t Message_Block[64];      /* 512-bit message blocks      */
c0772e3
-
c0772e3
-    int Computed;               /* Is the digest computed?         */
c0772e3
-    int Corrupted;             /* Is the message digest corrupted? */
c0772e3
-} SHA1Context;
c0772e3
-
c0772e3
-/*
c0772e3
- *  Function Prototypes
c0772e3
- */
c0772e3
-
c0772e3
-int SHA1Init(SHA1Context *);
c0772e3
-int SHA1Update(SHA1Context *,
c0772e3
-	       const uint8_t *,
c0772e3
-	       unsigned int);
c0772e3
-int SHA1Final(SHA1Context *,
c0772e3
-	       uint8_t Message_Digest[SHA1HashSize]);
c0772e3
-
c0772e3
-#endif