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