Fix SHA1 on 64bit architectures.

PR:		ports/136197
Submitted by:	Chris Cowart <ccowart@rescomp.berkeley.edu>
This commit is contained in:
Florent Thoumie 2009-07-15 13:43:54 +00:00
parent 39ec5fa287
commit df9b24e2e2
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=237876
3 changed files with 64 additions and 0 deletions

View file

@ -7,6 +7,7 @@
PORTNAME= bnbt
PORTVERSION= 8.5
PORTREVISION= 1
CATEGORIES= net-p2p
MASTER_SITES= http://opensource.depthstrike.com/${PORTNAME}/
DISTNAME= ${SNAPSHOT}-${PORTNAME}${PORTVERSION:C/\.//}-src

View file

@ -0,0 +1,32 @@
--- sha1.cpp 2009-06-30 14:02:51.000000000 -0700
+++ sha1.cpp.new 2009-06-30 14:02:47.000000000 -0700
@@ -44,9 +44,9 @@
m_count[1] = 0;
}
-void CSHA1::Transform(unsigned long state[5], const unsigned char buffer[64])
+void CSHA1::Transform(unsigned int state[5], const unsigned char buffer[64])
{
- unsigned long a = 0, b = 0, c = 0, d = 0, e = 0;
+ unsigned int a = 0, b = 0, c = 0, d = 0, e = 0;
SHA1_WORKSPACE_BLOCK* block;
static unsigned char workspace[64];
@@ -96,7 +96,7 @@
// Use this function to hash in binary data and strings
void CSHA1::Update(const unsigned char* data, unsigned int len)
{
- unsigned long i = 0, j = 0;
+ unsigned int i = 0, j = 0;
j = (m_count[0] >> 3) & 63;
@@ -123,7 +123,7 @@
void CSHA1::Final()
{
- unsigned long i = 0, j = 0;
+ unsigned int i = 0, j = 0;
unsigned char finalcount[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
for (i = 0; i < 8; i++)

View file

@ -0,0 +1,31 @@
--- sha1.h 2009-06-30 14:02:51.000000000 -0700
+++ sha1.h.new 2009-06-30 14:02:47.000000000 -0700
@@ -59,7 +59,7 @@
typedef union {
unsigned char c[64];
- unsigned long l[16];
+ unsigned int l[16];
} SHA1_WORKSPACE_BLOCK;
// Two different formats for ReportHash(...)
@@ -69,8 +69,8 @@
CSHA1();
virtual ~CSHA1();
- unsigned long m_state[5];
- unsigned long m_count[2];
+ unsigned int m_state[5];
+ unsigned int m_count[2];
unsigned char m_buffer[64];
unsigned char m_digest[20];
@@ -86,7 +86,7 @@
private:
// Private SHA-1 transformation
- void Transform(unsigned long state[5], const unsigned char buffer[64]);
+ void Transform(unsigned int state[5], const unsigned char buffer[64]);
};
#endif // ___SHA1_H___