13b78d
diff -Naur bacula-11.0.1.old/src/lib/lib.h bacula-11.0.1/src/lib/lib.h
13b78d
--- bacula-11.0.1.old/src/lib/lib.h	2021-02-11 14:09:48.598047248 +0100
13b78d
+++ bacula-11.0.1/src/lib/lib.h	2021-02-11 14:10:04.432308524 +0100
13b78d
@@ -57,7 +57,6 @@
13b78d
 #include "fnmatch.h"
13b78d
 #endif
13b78d
 #include "md5.h"
13b78d
-#include "sha1.h"
13b78d
 #include "tree.h"
13b78d
 #include "watchdog.h"
13b78d
 #include "btimers.h"
13b78d
diff -Naur bacula-11.0.1.old/src/lib/Makefile.in bacula-11.0.1/src/lib/Makefile.in
13b78d
--- bacula-11.0.1.old/src/lib/Makefile.in	2021-02-11 14:09:48.598047248 +0100
13b78d
+++ bacula-11.0.1/src/lib/Makefile.in	2021-02-11 14:10:04.433308540 +0100
13b78d
@@ -40,7 +40,7 @@
13b78d
       flist.h fnmatch.h guid_to_name.h htable.h lex.h \
13b78d
       lib.h lz4.h md5.h mem_pool.h message.h \
13b78d
       openssl.h plugins.h protos.h queue.h rblist.h \
13b78d
-      runscript.h rwlock.h serial.h sellist.h sha1.h sha2.h \
13b78d
+      runscript.h rwlock.h serial.h sellist.h sha2.h \
13b78d
       smartall.h status.h tls.h tree.h var.h \
13b78d
       waitq.h watchdog.h workq.h \
13b78d
       parse_conf.h ini.h \
13b78d
@@ -57,7 +57,7 @@
13b78d
       guid_to_name.c hmac.c jcr.c lex.c lz4.c alist.c dlist.c \
13b78d
       md5.c message.c mem_pool.c openssl.c \
13b78d
       plugins.c priv.c queue.c bregex.c bsockcore.c \
13b78d
-      runscript.c rwlock.c scan.c sellist.c serial.c sha1.c sha2.c \
13b78d
+      runscript.c rwlock.c scan.c sellist.c serial.c sha2.c \
13b78d
       signal.c smartall.c rblist.c tls.c tree.c \
13b78d
       util.c var.c watchdog.c workq.c btimers.c \
13b78d
       worker.c flist.c bcollector.c collect.c \
13b78d
@@ -286,22 +286,6 @@
13b78d
 	$(RMF) md5.o
13b78d
 	$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) md5.c
13b78d
 
13b78d
-sha1sum: Makefile libbac.la sha1.c
13b78d
-	$(RMF) sha1.o
13b78d
-	$(CXX) -DSHA1_SUM $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE)	$(CFLAGS) sha1.c
13b78d
-	$(LIBTOOL_LINK) $(CXX) $(LDFLAGS) -L. -o $@ sha1.o $(DLIB) -lbac -lm $(LIBS) $(OPENSSL_LIBS)
13b78d
-	$(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) $@ $(DESTDIR)$(sbindir)/
13b78d
-	$(RMF) sha1.o
13b78d
-	$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) sha1.c
13b78d
-
13b78d
-sha1_test: Makefile libbac.la sha1.c unittests.o
13b78d
-	$(RMF) sha1.o
13b78d
-	$(CXX) -DTEST_PROGRAM $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) sha1.c
13b78d
-	$(LIBTOOL_LINK) $(CXX) $(LDFLAGS) -L. -o $@ sha1.o unittests.o $(DLIB) -lbac -lm $(LIBS)
13b78d
-	$(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) $@ $(DESTDIR)$(sbindir)/
13b78d
-	$(RMF) sha1.o
13b78d
-	$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) sha1.c
13b78d
-
13b78d
 bsnprintf_test: Makefile libbac.la bsnprintf.c unittests.o
13b78d
 	$(RMF) bsnprintf.o
13b78d
 	$(CXX) -DTEST_PROGRAM $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE)  $(CFLAGS) bsnprintf.c
13b78d
@@ -397,7 +381,7 @@
13b78d
 
13b78d
 clean:	libtool-clean
13b78d
 	@$(RMF) core a.out *.o *.bak *.tex *.pdf *~ *.intpro *.extpro 1 2 3
13b78d
-	@$(RMF) rwlock_test md5sum sha1sum
13b78d
+	@$(RMF) rwlock_test md5sum
13b78d
 
13b78d
 realclean: clean
13b78d
 	@$(RMF) tags
13b78d
diff -Naur bacula-11.0.1.old/src/lib/sha1.c bacula-11.0.1/src/lib/sha1.c
13b78d
--- bacula-11.0.1.old/src/lib/sha1.c	2021-02-11 14:09:48.598047248 +0100
13b78d
+++ bacula-11.0.1/src/lib/sha1.c	1970-01-01 01:00:00.000000000 +0100
13b78d
@@ -1,517 +0,0 @@
13b78d
-/*
13b78d
- *  sha1.c
13b78d
- *
13b78d
- *  Description:
13b78d
- *      This file implements the Secure Hashing Algorithm 1 as
13b78d
- *      defined in FIPS PUB 180-1 published April 17, 1995.
13b78d
- *
13b78d
- *      The SHA-1, produces a 160-bit message digest for a given
13b78d
- *      data stream.  It should take about 2**n steps to find a
13b78d
- *      message with the same digest as a given message and
13b78d
- *      2**(n/2) to find any two messages with the same digest,
13b78d
- *      when n is the digest size in bits.  Therefore, this
13b78d
- *      algorithm can serve as a means of providing a
13b78d
- *      "fingerprint" for a message.
13b78d
- *
13b78d
- *  Portability Issues:
13b78d
- *      SHA-1 is defined in terms of 32-bit "words".  This code
13b78d
- *      uses <stdint.h> (included via "sha1.h" to define 32 and 8
13b78d
- *      bit unsigned integer types.  If your C compiler does not
13b78d
- *      support 32 bit unsigned integers, this code is not
13b78d
- *      appropriate.
13b78d
- *
13b78d
- *  Caveats:
13b78d
- *      SHA-1 is designed to work with messages less than 2^64 bits
13b78d
- *      long.  Although SHA-1 allows a message digest to be generated
13b78d
- *      for messages of any number of bits less than 2^64, this
13b78d
- *      implementation only works with messages with a length that is
13b78d
- *      a multiple of the size of an 8-bit character.
13b78d
- *
13b78d
- *  See sha1.h for copyright
13b78d
- */
13b78d
-
13b78d
-#include "sha1.h"
13b78d
-
13b78d
-/*
13b78d
- *  Define the SHA1 circular left shift macro
13b78d
- */
13b78d
-#define SHA1CircularShift(bits,word) \
13b78d
-                (((word) << (bits)) | ((word) >> (32-(bits))))
13b78d
-
13b78d
-/* Local Function Prototyptes */
13b78d
-static void SHA1PadMessage(SHA1Context *);
13b78d
-static void SHA1ProcessMessageBlock(SHA1Context *);
13b78d
-
13b78d
-/*
13b78d
- *  SHA1Init
13b78d
- *
13b78d
- *  Description:
13b78d
- *      This function will initialize the SHA1Context in preparation
13b78d
- *      for computing a new SHA1 message digest.
13b78d
- *
13b78d
- *  Parameters:
13b78d
- *      context: [in/out]
13b78d
- *          The context to reset.
13b78d
- *
13b78d
- *  Returns:
13b78d
- *      sha Error Code.
13b78d
- *
13b78d
- */
13b78d
-int SHA1Init(SHA1Context *context)
13b78d
-{
13b78d
-    if (!context)
13b78d
-    {
13b78d
-        return shaNull;
13b78d
-    }
13b78d
-
13b78d
-    context->Length_Low             = 0;
13b78d
-    context->Length_High            = 0;
13b78d
-    context->Message_Block_Index    = 0;
13b78d
-
13b78d
-    context->Intermediate_Hash[0]   = 0x67452301;
13b78d
-    context->Intermediate_Hash[1]   = 0xEFCDAB89;
13b78d
-    context->Intermediate_Hash[2]   = 0x98BADCFE;
13b78d
-    context->Intermediate_Hash[3]   = 0x10325476;
13b78d
-    context->Intermediate_Hash[4]   = 0xC3D2E1F0;
13b78d
-
13b78d
-    context->Computed   = 0;
13b78d
-    context->Corrupted  = 0;
13b78d
-
13b78d
-    return shaSuccess;
13b78d
-}
13b78d
-
13b78d
-/*
13b78d
- *  SHA1Final
13b78d
- *
13b78d
- *  Description:
13b78d
- *      This function will return the 160-bit message digest into the
13b78d
- *      Message_Digest array  provided by the caller.
13b78d
- *      NOTE: The first octet of hash is stored in the 0th element,
13b78d
- *            the last octet of hash in the 19th element.
13b78d
- *
13b78d
- *  Parameters:
13b78d
- *      context: [in/out]
13b78d
- *          The context to use to calculate the SHA-1 hash.
13b78d
- *      Message_Digest: [out]
13b78d
- *          Where the digest is returned.
13b78d
- *
13b78d
- *  Returns:
13b78d
- *      sha Error Code.
13b78d
- *
13b78d
- */
13b78d
-int SHA1Final(SHA1Context *context,
13b78d
-              uint8_t Message_Digest[SHA1HashSize])
13b78d
-{
13b78d
-    int i;
13b78d
-
13b78d
-    if (!context || !Message_Digest) {
13b78d
-        return shaNull;
13b78d
-    }
13b78d
-
13b78d
-    if (context->Corrupted) {
13b78d
-        return context->Corrupted;
13b78d
-    }
13b78d
-
13b78d
-    if (!context->Computed) {
13b78d
-        SHA1PadMessage(context);
13b78d
-        for(i=0; i<64; ++i) {
13b78d
-            /* message may be sensitive, clear it out */
13b78d
-            context->Message_Block[i] = 0;
13b78d
-        }
13b78d
-        context->Length_Low = 0;    /* and clear length */
13b78d
-        context->Length_High = 0;
13b78d
-        context->Computed = 1;
13b78d
-
13b78d
-    }
13b78d
-
13b78d
-    for(i = 0; i < SHA1HashSize; ++i) {
13b78d
-        Message_Digest[i] = context->Intermediate_Hash[i>>2]
13b78d
-                            >> 8 * ( 3 - ( i & 0x03 ) );
13b78d
-    }
13b78d
-
13b78d
-    return shaSuccess;
13b78d
-}
13b78d
-
13b78d
-/*
13b78d
- *  SHA1Update
13b78d
- *
13b78d
- *  Description:
13b78d
- *      This function accepts an array of octets as the next portion
13b78d
- *      of the message.
13b78d
- *
13b78d
- *  Parameters:
13b78d
- *      context: [in/out]
13b78d
- *          The SHA context to update
13b78d
- *      message_array: [in]
13b78d
- *          An array of characters representing the next portion of
13b78d
- *          the message.
13b78d
- *      length: [in]
13b78d
- *          The length of the message in message_array
13b78d
- *
13b78d
- *  Returns:
13b78d
- *      sha Error Code.
13b78d
- *
13b78d
- */
13b78d
-int SHA1Update(SHA1Context    *context,
13b78d
-               const uint8_t  *message_array,
13b78d
-               unsigned       length)
13b78d
-{
13b78d
-    if (!length) {
13b78d
-        return shaSuccess;
13b78d
-    }
13b78d
-
13b78d
-    if (!context || !message_array) {
13b78d
-        return shaNull;
13b78d
-    }
13b78d
-
13b78d
-    if (context->Computed) {
13b78d
-        context->Corrupted = shaStateError;
13b78d
-
13b78d
-        return shaStateError;
13b78d
-    }
13b78d
-
13b78d
-    if (context->Corrupted) {
13b78d
-         return context->Corrupted;
13b78d
-    }
13b78d
-    while(length-- && !context->Corrupted) {
13b78d
-       context->Message_Block[context->Message_Block_Index++] =
13b78d
-                    (*message_array & 0xFF);
13b78d
-
13b78d
-       context->Length_Low += 8;
13b78d
-       if (context->Length_Low == 0) {
13b78d
-           context->Length_High++;
13b78d
-           if (context->Length_High == 0) {
13b78d
-               /* Message is too long */
13b78d
-               context->Corrupted = 1;
13b78d
-           }
13b78d
-       }
13b78d
-
13b78d
-       if (context->Message_Block_Index == 64) {
13b78d
-           SHA1ProcessMessageBlock(context);
13b78d
-       }
13b78d
-
13b78d
-       message_array++;
13b78d
-    }
13b78d
-
13b78d
-    return shaSuccess;
13b78d
-}
13b78d
-
13b78d
-/*
13b78d
- *  SHA1ProcessMessageBlock
13b78d
- *
13b78d
- *  Description:
13b78d
- *      This function will process the next 512 bits of the message
13b78d
- *      stored in the Message_Block array.
13b78d
- *
13b78d
- *  Parameters:
13b78d
- *      None.
13b78d
- *
13b78d
- *  Returns:
13b78d
- *      Nothing.
13b78d
- *
13b78d
- *  Comments:
13b78d
-
13b78d
- *      Many of the variable names in this code, especially the
13b78d
- *      single character names, were used because those were the
13b78d
- *      names used in the publication.
13b78d
- *
13b78d
- *
13b78d
- */
13b78d
-static void SHA1ProcessMessageBlock(SHA1Context *context)
13b78d
-{
13b78d
-    const uint32_t K[] =    {       /* Constants defined in SHA-1   */
13b78d
-                            0x5A827999,
13b78d
-                            0x6ED9EBA1,
13b78d
-                            0x8F1BBCDC,
13b78d
-                            0xCA62C1D6
13b78d
-                            };
13b78d
-    int           t;                 /* Loop counter                */
13b78d
-    uint32_t      temp;              /* Temporary word value        */
13b78d
-    uint32_t      W[80];             /* Word sequence               */
13b78d
-    uint32_t      A, B, C, D, E;     /* Word buffers                */
13b78d
-
13b78d
-    /*
13b78d
-     *  Initialize the first 16 words in the array W
13b78d
-     */
13b78d
-    for(t = 0; t < 16; t++) {
13b78d
-        W[t] = context->Message_Block[t * 4] << 24;
13b78d
-        W[t] |= context->Message_Block[t * 4 + 1] << 16;
13b78d
-        W[t] |= context->Message_Block[t * 4 + 2] << 8;
13b78d
-        W[t] |= context->Message_Block[t * 4 + 3];
13b78d
-    }
13b78d
-
13b78d
-    for(t = 16; t < 80; t++) {
13b78d
-       W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
13b78d
-    }
13b78d
-
13b78d
-    A = context->Intermediate_Hash[0];
13b78d
-    B = context->Intermediate_Hash[1];
13b78d
-    C = context->Intermediate_Hash[2];
13b78d
-    D = context->Intermediate_Hash[3];
13b78d
-    E = context->Intermediate_Hash[4];
13b78d
-
13b78d
-    for(t = 0; t < 20; t++) {
13b78d
-        temp =  SHA1CircularShift(5,A) +
13b78d
-                ((B & C) | ((~B) & D)) + E + W[t] + K[0];
13b78d
-        E = D;
13b78d
-        D = C;
13b78d
-        C = SHA1CircularShift(30,B);
13b78d
-
13b78d
-        B = A;
13b78d
-        A = temp;
13b78d
-    }
13b78d
-
13b78d
-    for(t = 20; t < 40; t++) {
13b78d
-        temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
13b78d
-        E = D;
13b78d
-        D = C;
13b78d
-        C = SHA1CircularShift(30,B);
13b78d
-        B = A;
13b78d
-        A = temp;
13b78d
-    }
13b78d
-
13b78d
-    for(t = 40; t < 60; t++) {
13b78d
-        temp = SHA1CircularShift(5,A) +
13b78d
-               ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
13b78d
-        E = D;
13b78d
-        D = C;
13b78d
-        C = SHA1CircularShift(30,B);
13b78d
-        B = A;
13b78d
-        A = temp;
13b78d
-    }
13b78d
-
13b78d
-    for(t = 60; t < 80; t++) {
13b78d
-        temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
13b78d
-        E = D;
13b78d
-        D = C;
13b78d
-        C = SHA1CircularShift(30,B);
13b78d
-        B = A;
13b78d
-        A = temp;
13b78d
-    }
13b78d
-
13b78d
-    context->Intermediate_Hash[0] += A;
13b78d
-    context->Intermediate_Hash[1] += B;
13b78d
-    context->Intermediate_Hash[2] += C;
13b78d
-    context->Intermediate_Hash[3] += D;
13b78d
-    context->Intermediate_Hash[4] += E;
13b78d
-
13b78d
-    context->Message_Block_Index = 0;
13b78d
-}
13b78d
-
13b78d
-/*
13b78d
- *  SHA1PadMessage
13b78d
- *
13b78d
-
13b78d
- *  Description:
13b78d
- *      According to the standard, the message must be padded to an even
13b78d
- *      512 bits.  The first padding bit must be a '1'.  The last 64
13b78d
- *      bits represent the length of the original message.  All bits in
13b78d
- *      between should be 0.  This function will pad the message
13b78d
- *      according to those rules by filling the Message_Block array
13b78d
- *      accordingly.  It will also call the ProcessMessageBlock function
13b78d
- *      provided appropriately.  When it returns, it can be assumed that
13b78d
- *      the message digest has been computed.
13b78d
- *
13b78d
- *  Parameters:
13b78d
- *      context: [in/out]
13b78d
- *          The context to pad
13b78d
- *      ProcessMessageBlock: [in]
13b78d
- *          The appropriate SHA*ProcessMessageBlock function
13b78d
- *  Returns:
13b78d
- *      Nothing.
13b78d
- *
13b78d
- */
13b78d
-
13b78d
-static void SHA1PadMessage(SHA1Context *context)
13b78d
-{
13b78d
-    /*
13b78d
-     *  Check to see if the current message block is too small to hold
13b78d
-     *  the initial padding bits and length.  If so, we will pad the
13b78d
-     *  block, process it, and then continue padding into a second
13b78d
-     *  block.
13b78d
-     */
13b78d
-    if (context->Message_Block_Index > 55) {
13b78d
-        context->Message_Block[context->Message_Block_Index++] = 0x80;
13b78d
-        while(context->Message_Block_Index < 64) {
13b78d
-            context->Message_Block[context->Message_Block_Index++] = 0;
13b78d
-        }
13b78d
-
13b78d
-        SHA1ProcessMessageBlock(context);
13b78d
-
13b78d
-        while(context->Message_Block_Index < 56) {
13b78d
-            context->Message_Block[context->Message_Block_Index++] = 0;
13b78d
-        }
13b78d
-    } else {
13b78d
-        context->Message_Block[context->Message_Block_Index++] = 0x80;
13b78d
-        while(context->Message_Block_Index < 56) {
13b78d
-
13b78d
-            context->Message_Block[context->Message_Block_Index++] = 0;
13b78d
-        }
13b78d
-    }
13b78d
-
13b78d
-    /*
13b78d
-     *  Store the message length as the last 8 octets
13b78d
-     */
13b78d
-    context->Message_Block[56] = context->Length_High >> 24;
13b78d
-    context->Message_Block[57] = context->Length_High >> 16;
13b78d
-    context->Message_Block[58] = context->Length_High >> 8;
13b78d
-    context->Message_Block[59] = context->Length_High;
13b78d
-    context->Message_Block[60] = context->Length_Low >> 24;
13b78d
-    context->Message_Block[61] = context->Length_Low >> 16;
13b78d
-    context->Message_Block[62] = context->Length_Low >> 8;
13b78d
-    context->Message_Block[63] = context->Length_Low;
13b78d
-
13b78d
-    SHA1ProcessMessageBlock(context);
13b78d
-}
13b78d
-
13b78d
-
13b78d
-#ifndef TEST_PROGRAM
13b78d
-#define TEST_PROGRAM_A
13b78d
-#endif
13b78d
-
13b78d
-#ifdef TEST_PROGRAM
13b78d
-/*
13b78d
- *  sha1test.c
13b78d
- *
13b78d
- *  Description:
13b78d
- *      This file will exercise the SHA-1 code performing the three
13b78d
- *      tests documented in FIPS PUB 180-1 plus one which calls
13b78d
- *      SHA1Input with an exact multiple of 512 bits, plus a few
13b78d
- *      error test checks.
13b78d
- *
13b78d
- *  Portability Issues:
13b78d
- *      None.
13b78d
- *
13b78d
- */
13b78d
-
13b78d
-#include <stdint.h>
13b78d
-#include <stdio.h>
13b78d
-#include <string.h>
13b78d
-#include "sha1.h"
13b78d
-#include "unittests.h"
13b78d
-
13b78d
-#define NRTESTS   4
13b78d
-
13b78d
-/*
13b78d
- *  Define patterns for testing
13b78d
- */
13b78d
-#define TEST1   "abc"
13b78d
-#define TEST2a  "abcdbcdecdefdefgefghfghighijhi"
13b78d
-
13b78d
-#define TEST2b  "jkijkljklmklmnlmnomnopnopq"
13b78d
-#define TEST2   TEST2a TEST2b
13b78d
-#define TEST3   "a"
13b78d
-#define TEST4a  "01234567012345670123456701234567"
13b78d
-#define TEST4b  "01234567012345670123456701234567"
13b78d
-    /* an exact multiple of 512 bits */
13b78d
-#define TEST4   TEST4a TEST4b
13b78d
-
13b78d
-const char *testarray[NRTESTS] =
13b78d
-{
13b78d
-    TEST1,
13b78d
-    TEST2,
13b78d
-    TEST3,
13b78d
-    TEST4
13b78d
-};
13b78d
-
13b78d
-int repeatcount[NRTESTS] = { 1, 1, 1000000, 10 };
13b78d
-
13b78d
-const uint8_t resultarray[NRTESTS][20] =
13b78d
-{
13b78d
-   { 0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, 0xBA, 0x3E, 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, 0x9C, 0xD0, 0xD8, 0x9D },
13b78d
-   { 0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, 0xBA, 0xAE, 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, 0xE5, 0x46, 0x70, 0xF1 },
13b78d
-   { 0x34, 0xAA, 0x97, 0x3C, 0xD4, 0xC4, 0xDA, 0xA4, 0xF6, 0x1E, 0xEB, 0x2B, 0xDB, 0xAD, 0x27, 0x31, 0x65, 0x34, 0x01, 0x6F },
13b78d
-   { 0xDE, 0xA3, 0x56, 0xA2, 0xCD, 0xDD, 0x90, 0xC7, 0xA7, 0xEC, 0xED, 0xC5, 0xEB, 0xB5, 0x63, 0x93, 0x4F, 0x46, 0x04, 0x52 },
13b78d
-};
13b78d
-
13b78d
-int main()
13b78d
-{
13b78d
-   Unittests sha1_test("sha1_test");
13b78d
-   SHA1Context sha;
13b78d
-   int i, j, err;
13b78d
-   uint8_t Message_Digest[20];
13b78d
-   bool check_cont;
13b78d
-   bool ct;
13b78d
-
13b78d
-   /*
13b78d
-    *  Perform SHA-1 tests
13b78d
-    */
13b78d
-   for(j = 0; j < 4; ++j) {
13b78d
-      // printf( "\nTest %d: %d, '%s'\n", j+1, repeatcount[j], testarray[j]);
13b78d
-      err = SHA1Init(&sha);
13b78d
-      nok(err, "Test SHA1Init");
13b78d
-      if (err) {
13b78d
-         break;    /* out of for j loop */
13b78d
-      }
13b78d
-      ct = true;
13b78d
-      for(i = 0; i < repeatcount[j]; ++i) {
13b78d
-         err = SHA1Update(&sha, (const unsigned char *) testarray[j], strlen(testarray[j]));
13b78d
-         if (i < 5){
13b78d
-            nok(err, "Test SHA1Update");
13b78d
-         }
13b78d
-         if (ct && repeatcount[j] > 4 && i > 4){
13b78d
-            ct = false;
13b78d
-            printf("...\n");
13b78d
-         }
13b78d
-         if (err) {
13b78d
-            nok(err, "Test SHA1Update");
13b78d
-            break;    /* out of for i loop */
13b78d
-         }
13b78d
-      }
13b78d
-
13b78d
-      err = SHA1Final(&sha, Message_Digest);
13b78d
-      nok(err, "Test SHA1Final");
13b78d
-      check_cont = true;
13b78d
-      for(i = 0; i < 20 ; ++i) {
13b78d
-         if (Message_Digest[i] != resultarray[j][i]){
13b78d
-            check_cont = false;
13b78d
-         }
13b78d
-      }
13b78d
-      ok(check_cont, "Checking expected result");
13b78d
-   }
13b78d
-
13b78d
-   /* Test some error returns */
13b78d
-   err = SHA1Update(&sha,(const unsigned char *) testarray[1], 1);
13b78d
-   ok(err == shaStateError, "Checking for shaStateError");
13b78d
-   err = SHA1Init(0);
13b78d
-   ok(err == shaNull, "Checking for shaNull");
13b78d
-
13b78d
-   return report();
13b78d
-}
13b78d
-
13b78d
-#endif /* TEST_PROGRAM */
13b78d
-
13b78d
-#ifdef SHA1_SUM
13b78d
-/*
13b78d
- * Reads a single ASCII file and prints the HEX sha1 sum.
13b78d
- */
13b78d
-#include <stdio.h>
13b78d
-int main(int argc, char *argv[])
13b78d
-{
13b78d
-   FILE *fd;
13b78d
-   SHA1Context ctx;
13b78d
-   char buf[5000];
13b78d
-   char signature[25];
13b78d
-
13b78d
-   if (argc < 1) {
13b78d
-      printf("Must have filename\n");
13b78d
-      exit(1);
13b78d
-   }
13b78d
-   fd = fopen(argv[1], "rb");
13b78d
-   if (!fd) {
13b78d
-      berrno be;
13b78d
-      printf("Could not open %s: ERR=%s\n", argv[1], be.bstrerror(errno));
13b78d
-      exit(1);
13b78d
-   }
13b78d
-   SHA1Init(&ctx;;
13b78d
-   while (fgets(buf, sizeof(buf), fd)) {
13b78d
-      SHA1Update(&ctx, (unsigned char *)buf, strlen(buf));
13b78d
-   }
13b78d
-   SHA1Final(&ctx, (unsigned char *)signature);
13b78d
-   for (int i=0; i < 20; i++) {
13b78d
-      printf("%02x", signature[i]& 0xFF);
13b78d
-   }
13b78d
-   printf("  %s\n", argv[1]);
13b78d
-   fclose(fd);
13b78d
-}
13b78d
-#endif   /* SHA1_SUM */
13b78d
diff -Naur bacula-11.0.1.old/src/lib/sha1.h bacula-11.0.1/src/lib/sha1.h
13b78d
--- bacula-11.0.1.old/src/lib/sha1.h	2021-02-11 14:09:48.599047264 +0100
13b78d
+++ bacula-11.0.1/src/lib/sha1.h	1970-01-01 01:00:00.000000000 +0100
13b78d
@@ -1,107 +0,0 @@
13b78d
-/*
13b78d
- *  sha1.h
13b78d
- *
13b78d
- *  Description:
13b78d
- *      This is the header file for code which implements the Secure
13b78d
- *      Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
13b78d
- *      April 17, 1995.
13b78d
- *
13b78d
- *      Many of the variable names in this code, especially the
13b78d
- *      single character names, were used because those were the names
13b78d
- *      used in the publication.
13b78d
- *
13b78d
- *      Please read the file sha1.c for more information.
13b78d
- *
13b78d
- * Full Copyright Statement
13b78d
- *
13b78d
- *    Copyright (C) The Internet Society (2001).  All Rights Reserved.
13b78d
- *
13b78d
- *    This document and translations of it may be copied and furnished to
13b78d
- *    others, and derivative works that comment on or otherwise explain it
13b78d
- *    or assist in its implementation may be prepared, copied, published
13b78d
- *    and distributed, in whole or in part, without restriction of any
13b78d
- *    kind, provided that the above copyright notice and this paragraph are
13b78d
- *    included on all such copies and derivative works.  However, this
13b78d
- *    document itself may not be modified in any way, such as by removing
13b78d
- *    the copyright notice or references to the Internet Society or other
13b78d
- *    Internet organizations, except as needed for the purpose of
13b78d
- *    developing Internet standards in which case the procedures for
13b78d
- *    copyrights defined in the Internet Standards process must be
13b78d
- *    followed, or as required to translate it into languages other than
13b78d
- *    English.
13b78d
- *
13b78d
- *    The limited permissions granted above are perpetual and will not be
13b78d
- *    revoked by the Internet Society or its successors or assigns.
13b78d
- *
13b78d
- *    This document and the information contained herein is provided on an
13b78d
- *    "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
13b78d
- *    TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
13b78d
- *    BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
13b78d
- *    HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
13b78d
- *    MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
13b78d
- *
13b78d
- * Acknowledgement
13b78d
- *
13b78d
- *    Funding for the RFC Editor function is currently provided by the
13b78d
- *    Internet Society.
13b78d
- *
13b78d
- */
13b78d
-
13b78d
-#ifndef _SHA1_H_
13b78d
-#define _SHA1_H_
13b78d
-
13b78d
-#include "bacula.h"
13b78d
-
13b78d
-/*
13b78d
- * If you do not have the ISO standard stdint.h header file, then you
13b78d
- * must typdef the following:
13b78d
- *    name              meaning
13b78d
- *  uint32_t         unsigned 32 bit integer
13b78d
- *  uint8_t          unsigned 8 bit integer (i.e., unsigned char)
13b78d
- *  int32_t          integer of 32 bits
13b78d
- *
13b78d
- */
13b78d
-
13b78d
-#ifndef _SHA_enum_
13b78d
-#define _SHA_enum_
13b78d
-enum
13b78d
-{
13b78d
-    shaSuccess = 0,
13b78d
-    shaNull,            /* Null pointer parameter */
13b78d
-    shaInputTooLong,    /* input data too long */
13b78d
-    shaStateError       /* called Input after Result */
13b78d
-};
13b78d
-#endif
13b78d
-#define SHA1HashSize 20
13b78d
-
13b78d
-/*
13b78d
- *  This structure will hold context information for the SHA-1
13b78d
- *  hashing operation
13b78d
- */
13b78d
-typedef struct SHA1Context
13b78d
-{
13b78d
-    uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest  */
13b78d
-
13b78d
-    uint32_t Length_Low;            /* Message length in bits      */
13b78d
-    uint32_t Length_High;           /* Message length in bits      */
13b78d
-
13b78d
-			       /* Index into message block array   */
13b78d
-    int32_t Message_Block_Index;
13b78d
-    uint8_t Message_Block[64];      /* 512-bit message blocks      */
13b78d
-
13b78d
-    int Computed;               /* Is the digest computed?         */
13b78d
-    int Corrupted;             /* Is the message digest corrupted? */
13b78d
-} SHA1Context;
13b78d
-
13b78d
-/*
13b78d
- *  Function Prototypes
13b78d
- */
13b78d
-
13b78d
-int SHA1Init(SHA1Context *);
13b78d
-int SHA1Update(SHA1Context *,
13b78d
-	       const uint8_t *,
13b78d
-	       unsigned int);
13b78d
-int SHA1Final(SHA1Context *,
13b78d
-	       uint8_t Message_Digest[SHA1HashSize]);
13b78d
-
13b78d
-#endif