[simutrans] 04/09: Add sha1.patch.
Markus Koschany
apo at moszumanska.debian.org
Thu Nov 10 23:37:37 UTC 2016
This is an automated email from the git hooks/post-receive script.
apo pushed a commit to branch master
in repository simutrans.
commit ab73c5d730009d13dc607ca3e678ae486583555a
Author: Markus Koschany <apo at debian.org>
Date: Thu Nov 10 23:24:23 2016 +0100
Add sha1.patch.
This is the original upstream version. It is free software. Add a clarification
to debian/copyright. This also fixes the FTBFS with OpenSSL 1.1.0.
Closes: #828545
---
debian/copyright | 30 ++-
debian/patches/series | 1 +
debian/patches/sha1.patch | 472 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 500 insertions(+), 3 deletions(-)
diff --git a/debian/copyright b/debian/copyright
index c6cc211..84a0130 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,9 +1,6 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Simutrans
Source: http://sourceforge.net/projects/simutrans
-Files-Excluded:
- utils/sha1.cc
- utils/sha1.h
Files: *
Copyright: 1997-2004 Hansjörg Malthaner
@@ -27,6 +24,33 @@ Files: squirrel/sqstdlib/*
Copyright: 2003-2014 Alberto Demichelis
License: Expat
+Files: utils/sha1.*
+Copyright: Paul E. Jones <paulej at packetizer.com>
+License: sha1-license
+ Pau,
+ .
+ That is a little odd to claim it can't be modified. The whole point of
+ making it free is so that developers can do anything they want with it.
+ Somebody is adding more to what free means than what free means.
+ .
+ The code is totally free, with no restrictions on it whatsoever. There are no
+ fees, no requirements to provide changes back to me, etc., and of course
+ people can modify it. It would not be free if they couldn't. (And many people
+ have. It's used in lots of projects, some free and some commercial.)
+ .
+ I inserted the "Freeware Public License" line to poke fun at the GNU Public
+ License, which really is encumbered by silly restrictions. My code has
+ absolutely no restrictions whatsoever.
+ .
+ You are hereby authorized to make any change you want to the license file or
+ even adapt it as you see fit to address your own concerns.
+ When I say it is free, I mean it really is free :-)
+ .
+ Paul
+Comment:
+ See also https://bugs.debian.org/730758 for the clarification of Paul E.
+ Jones.
+
Files: debian/*
Copyright: 2008-2012 Ansgar Burchardt <ansgar at debian.org>
2015-2016 Jörg Frings-Fürst <debian at jff-webhosting.net>
diff --git a/debian/patches/series b/debian/patches/series
index c1c43c8..6929bcb 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -5,3 +5,4 @@
0505-link-less-libraries.diff
#0510-missing_uncommon_mk.patch
reproducible-build.patch
+sha1.patch
diff --git a/debian/patches/sha1.patch b/debian/patches/sha1.patch
new file mode 100644
index 0000000..6c3df46
--- /dev/null
+++ b/debian/patches/sha1.patch
@@ -0,0 +1,472 @@
+From: Markus Koschany <apo at debian.org>
+Date: Thu, 10 Nov 2016 23:23:52 +0100
+Subject: sha1
+
+---
+ utils/sha1.cc | 368 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ utils/sha1.h | 81 +++++++++++++
+ 2 files changed, 449 insertions(+)
+ create mode 100644 utils/sha1.cc
+ create mode 100644 utils/sha1.h
+
+diff --git a/utils/sha1.cc b/utils/sha1.cc
+new file mode 100644
+index 0000000..2d20ab4
+--- /dev/null
++++ b/utils/sha1.cc
+@@ -0,0 +1,368 @@
++/*
++ * sha1.cpp
++ *
++ * Copyright (C) 1998, 2009
++ * Paul E. Jones <paulej at packetizer.com>
++ * All Rights Reserved.
++ *
++ *****************************************************************************
++ * $Id: sha1.cpp 12 2009-06-22 19:34:25Z paulej $
++ *****************************************************************************
++ *
++ * Description:
++ * This class implements the Secure Hashing Standard as defined
++ * in FIPS PUB 180-1 published April 17, 1995.
++ *
++ * The Secure Hashing Standard, which uses the Secure Hashing
++ * Algorithm (SHA), produces a 160-bit message digest for a
++ * given data stream. In theory, it is highly improbable that
++ * two messages will produce the same message digest. Therefore,
++ * this algorithm can serve as a means of providing a "fingerprint"
++ * for a message.
++ *
++ * Caveats:
++ * SHA-1 is designed to work with messages less than 2^64 bits long.
++ * Although SHA-1 allows a message digest to be generated for
++ * messages of any number of bits less than 2^64, this implementation
++ * only works with messages with a length that is a multiple of 8
++ * bits.
++ *
++ */
++
++#include <string.h>
++
++#include "sha1.h"
++
++/*
++ * Reset
++ *
++ * Description:
++ * This function will initialize the sha1 class member variables
++ * in preparation for computing a new message digest.
++ *
++ * Parameters:
++ * None.
++ *
++ * Returns:
++ * Nothing.
++ *
++ * Comments:
++ *
++ */
++void SHA1::Reset()
++{
++ Length_Low = 0;
++ Length_High = 0;
++ Message_Block_Index = 0;
++
++ H[0] = 0x67452301;
++ H[1] = 0xEFCDAB89;
++ H[2] = 0x98BADCFE;
++ H[3] = 0x10325476;
++ H[4] = 0xC3D2E1F0;
++
++ Computed = false;
++ Corrupted = false;
++}
++
++/*
++ * Result
++ *
++ * Description:
++ * This function will return the 160-bit message digest into the
++ * array provided.
++ *
++ * Parameters:
++ * message_digest_array: [out]
++ * This is an array of five uint32 integers which will be filled
++ * with the message digest that has been computed.
++ *
++ * Returns:
++ * True if successful, false if it failed.
++ *
++ * Comments:
++ *
++ */
++bool SHA1::Result(uint8 *message_digest_array )
++{
++ if (Corrupted) {
++ return false;
++ }
++
++ if (!Computed) {
++ PadMessage();
++ Computed = true;
++ }
++
++#ifdef SIM_BIG_ENDIAN
++ uint32 H_little_endian[5];
++ for(int i = 0; i < 5; i++) {
++ H_little_endian[i] = endian( H[i] );
++ }
++ memcpy( message_digest_array, H_little_endian, 20 );
++#else
++ memcpy( message_digest_array, H, 20 );
++#endif
++
++ return true;
++}
++
++/*
++ * Input
++ *
++ * Description:
++ * This function accepts an array of octets as the next portion of
++ * the message.
++ *
++ * Parameters:
++ * message_array: [in]
++ * An array of characters representing the next portion of the
++ * message.
++ *
++ * Returns:
++ * Nothing.
++ *
++ * Comments:
++ *
++ */
++void SHA1::Input( const char *message_array, uint32 length)
++{
++ if (!length) {
++ return;
++ }
++
++ if (Computed || Corrupted) {
++ Corrupted = true;
++ return;
++ }
++
++ while(length-- && !Corrupted) {
++ Message_Block[Message_Block_Index++] = (*message_array & 0xFF);
++
++ Length_Low += 8;
++ Length_Low &= 0xFFFFFFFF; // Force it to 32 bits
++ if (Length_Low == 0) {
++ Length_High++;
++ Length_High &= 0xFFFFFFFF; // Force it to 32 bits
++ if (Length_High == 0) {
++ Corrupted = true; // Message is too long
++ }
++ }
++
++ if (Message_Block_Index == 64) {
++ ProcessMessageBlock();
++ }
++
++ message_array++;
++ }
++}
++
++/*
++ * Input
++ *
++ * Description:
++ * This function accepts a single octets as the next message element.
++ *
++ * Parameters:
++ * message_element: [in]
++ * The next octet in the message.
++ *
++ * Returns:
++ * Nothing.
++ *
++ * Comments:
++ *
++ */
++void SHA1::Input(char message_element)
++{
++ Input(&message_element, 1);
++}
++
++/*
++ * ProcessMessageBlock
++ *
++ * Description:
++ * This function will process the next 512 bits of the message
++ * stored in the Message_Block array.
++ *
++ * Parameters:
++ * None.
++ *
++ * Returns:
++ * Nothing.
++ *
++ * Comments:
++ * Many of the variable names in this function, especially the single
++ * character names, were used because those were the names used
++ * in the publication.
++ *
++ */
++void SHA1::ProcessMessageBlock()
++{
++ const uint32 K[] = { // Constants defined for SHA-1
++ 0x5A827999,
++ 0x6ED9EBA1,
++ 0x8F1BBCDC,
++ 0xCA62C1D6
++ };
++ int t; // Loop counter
++ uint32 temp; // Temporary word value
++ uint32 W[80]; // Word sequence
++ uint32 A, B, C, D, E; // Word buffers
++
++ /*
++ * Initialize the first 16 words in the array W
++ */
++ for(t = 0; t < 16; t++) {
++ W[t] = ((uint32) Message_Block[t * 4]) << 24;
++ W[t] |= ((uint32) Message_Block[t * 4 + 1]) << 16;
++ W[t] |= ((uint32) Message_Block[t * 4 + 2]) << 8;
++ W[t] |= ((uint32) Message_Block[t * 4 + 3]);
++ }
++
++ for(t = 16; t < 80; t++) {
++ W[t] = CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
++ }
++
++ A = H[0];
++ B = H[1];
++ C = H[2];
++ D = H[3];
++ E = H[4];
++
++ for(t = 0; t < 20; t++) {
++ temp = CircularShift(5,A) + ((B & C) | ((~B) & D)) + E + W[t] + K[0];
++ temp &= 0xFFFFFFFF;
++ E = D;
++ D = C;
++ C = CircularShift(30,B);
++ B = A;
++ A = temp;
++ }
++
++ for(t = 20; t < 40; t++) {
++ temp = CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
++ temp &= 0xFFFFFFFF;
++ E = D;
++ D = C;
++ C = CircularShift(30,B);
++ B = A;
++ A = temp;
++ }
++
++ for(t = 40; t < 60; t++) {
++ temp = CircularShift(5,A) +
++ ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
++ temp &= 0xFFFFFFFF;
++ E = D;
++ D = C;
++ C = CircularShift(30,B);
++ B = A;
++ A = temp;
++ }
++
++ for(t = 60; t < 80; t++) {
++ temp = CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
++ temp &= 0xFFFFFFFF;
++ E = D;
++ D = C;
++ C = CircularShift(30,B);
++ B = A;
++ A = temp;
++ }
++
++ H[0] = (H[0] + A) & 0xFFFFFFFF;
++ H[1] = (H[1] + B) & 0xFFFFFFFF;
++ H[2] = (H[2] + C) & 0xFFFFFFFF;
++ H[3] = (H[3] + D) & 0xFFFFFFFF;
++ H[4] = (H[4] + E) & 0xFFFFFFFF;
++
++ Message_Block_Index = 0;
++}
++
++/*
++ * PadMessage
++ *
++ * Description:
++ * According to the standard, the message must be padded to an even
++ * 512 bits. The first padding bit must be a '1'. The last 64 bits
++ * represent the length of the original message. All bits in between
++ * should be 0. This function will pad the message according to those
++ * rules by filling the message_block array accordingly. It will also
++ * call ProcessMessageBlock() appropriately. When it returns, it
++ * can be assumed that the message digest has been computed.
++ *
++ * Parameters:
++ * None.
++ *
++ * Returns:
++ * Nothing.
++ *
++ * Comments:
++ *
++ */
++void SHA1::PadMessage()
++{
++ /*
++ * Check to see if the current message block is too small to hold
++ * the initial padding bits and length. If so, we will pad the
++ * block, process it, and then continue padding into a second block.
++ */
++ if (Message_Block_Index > 55) {
++ Message_Block[Message_Block_Index++] = 0x80;
++ while(Message_Block_Index < 64) {
++ Message_Block[Message_Block_Index++] = 0;
++ }
++
++ ProcessMessageBlock();
++
++ while(Message_Block_Index < 56) {
++ Message_Block[Message_Block_Index++] = 0;
++ }
++ }
++ else {
++ Message_Block[Message_Block_Index++] = 0x80;
++ while(Message_Block_Index < 56) {
++ Message_Block[Message_Block_Index++] = 0;
++ }
++
++ }
++
++ /*
++ * Store the message length as the last 8 octets
++ */
++ Message_Block[56] = (Length_High >> 24) & 0xFF;
++ Message_Block[57] = (Length_High >> 16) & 0xFF;
++ Message_Block[58] = (Length_High >> 8) & 0xFF;
++ Message_Block[59] = (Length_High) & 0xFF;
++ Message_Block[60] = (Length_Low >> 24) & 0xFF;
++ Message_Block[61] = (Length_Low >> 16) & 0xFF;
++ Message_Block[62] = (Length_Low >> 8) & 0xFF;
++ Message_Block[63] = (Length_Low) & 0xFF;
++
++ ProcessMessageBlock();
++}
++
++
++/*
++ * CircularShift
++ *
++ * Description:
++ * This member function will perform a circular shifting operation.
++ *
++ * Parameters:
++ * bits: [in]
++ * The number of bits to shift (1-31)
++ * word: [in]
++ * The value to shift (assumes a 32-bit integer)
++ *
++ * Returns:
++ * The shifted value.
++ *
++ * Comments:
++ *
++ */
++uint32 SHA1::CircularShift(int bits, uint32 word)
++{
++ return ((word << bits) & 0xFFFFFFFF) | ((word & 0xFFFFFFFF) >> (32-bits));
++}
+diff --git a/utils/sha1.h b/utils/sha1.h
+new file mode 100644
+index 0000000..1604f07
+--- /dev/null
++++ b/utils/sha1.h
+@@ -0,0 +1,81 @@
++/*
++ * sha1.h
++ *
++ * Copyright (C) 1998, 2009
++ * Paul E. Jones <paulej at packetizer.com>
++ * All Rights Reserved.
++ *
++ *****************************************************************************
++ * $Id: sha1.h 12 2009-06-22 19:34:25Z paulej $
++ *****************************************************************************
++ *
++ * Description:
++ * This class implements the Secure Hashing Standard as defined
++ * in FIPS PUB 180-1 published April 17, 1995.
++ *
++ * Many of the variable names in this class, especially the single
++ * character names, were used because those were the names used
++ * in the publication.
++ *
++ * Please read the file sha1.cpp for more information.
++ *
++ */
++
++#ifndef _SHA1_H_
++#define _SHA1_H_
++
++#include "../simtypes.h"
++
++class SHA1
++{
++
++ public:
++
++ SHA1() { Reset(); }
++
++ /*
++ * Re-initialize the class
++ */
++ void Reset();
++
++ /*
++ * Returns the message digest (must be 20 bytes long!)
++ */
++ bool Result(uint8 *message_digest_array );
++
++ /*
++ * Provide input to SHA1
++ */
++ void Input( const char *message_array, uint32 length);
++ void Input( char message_element);
++
++private:
++
++ /*
++ * Process the next 512 bits of the message
++ */
++ void ProcessMessageBlock();
++
++ /*
++ * Pads the current message block to 512 bits
++ */
++ void PadMessage();
++
++ /*
++ * Performs a circular left shift operation
++ */
++ inline unsigned CircularShift(int bits, unsigned word);
++
++ uint32 H[5]; // Message digest buffers
++
++ uint32 Length_Low; // Message length in bits
++ uint32 Length_High; // Message length in bits
++
++ uint8 Message_Block[64]; // 512-bit message blocks
++ int Message_Block_Index; // Index into message block array
++
++ bool Computed; // Is the digest computed?
++ bool Corrupted; // Is the message digest corruped?
++};
++
++#endif
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/simutrans.git
More information about the Pkg-games-commits
mailing list