QTfrontend/sha1.cpp
author unc0rr
Mon, 24 Jul 2006 14:03:51 +0000
changeset 83 207c85fbef51
parent 33 d6363050cad0
permissions -rw-r--r--
- First hedgehog in team has first turn in team - AI fix: let bots go to the right and... Show whether round finished with draw or team won... get rid of error message
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
     1
/*
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
     2
 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
     3
 * All rights reserved.
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
     4
 *
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
     5
 * Copyright (c) 2005 Andrey Korotaev <unC0Rr@gmail.com>
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
     6
 *
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
     7
 * Redistribution and use in source and binary forms, with or without
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
     8
 * modification, are permitted provided that the following conditions
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
     9
 * are met:
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    10
 * 1. Redistributions of source code must retain the above copyright
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    11
 *    notice, this list of conditions and the following disclaimer.
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    12
 * 2. Redistributions in binary form must reproduce the above copyright
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    13
 *    notice, this list of conditions and the following disclaimer in the
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    14
 *    documentation and/or other materials provided with the distribution.
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    15
 * 3. Neither the name of the project nor the names of its contributors
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    16
 *    may be used to endorse or promote products derived from this software
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    17
 *    without specific prior written permission.
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    18
 *
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    19
 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    20
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    21
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    22
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    23
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    24
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    25
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    26
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    27
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    28
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    29
 * SUCH DAMAGE.
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    30
 */
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    31
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    32
/*
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    33
 * FIPS pub 180-1: Secure Hash Algorithm (SHA-1)
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    34
 * based on: http://csrc.nist.gov/fips/fip180-1.txt
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    35
 * implemented by Jun-ichiro itojun Itoh <itojun@itojun.org>
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    36
 */
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    37
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    38
#include "sha1.h"
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    39
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    40
/* constant table */
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    41
static quint32 _K[] = { 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6 };
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    42
#define	K(t)	_K[(t) / 20]
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    43
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    44
#define	F0(b, c, d)	(((b) & (c)) | ((~(b)) & (d)))
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    45
#define	F1(b, c, d)	(((b) ^ (c)) ^ (d))
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    46
#define	F2(b, c, d)	(((b) & (c)) | ((b) & (d)) | ((c) & (d)))
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    47
#define	F3(b, c, d)	(((b) ^ (c)) ^ (d))
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    48
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    49
#define	S(n, x)		(((x) << (n)) | ((x) >> (32 - n)))
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    50
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    51
#define	H(n)	(ctxt->h.b32[(n)])
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    52
#define	COUNT	(ctxt->count)
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    53
#define	BCOUNT	(ctxt->c.b64[0] / 8)
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    54
#define	W(n)	(ctxt->m.b32[(n)])
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    55
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    56
#define	PUTBYTE(x)	{ \
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    57
	ctxt->m.b8[(COUNT % 64)] = (x);		\
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    58
	COUNT++;				\
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    59
	COUNT %= 64;				\
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    60
	ctxt->c.b64[0] += 8;			\
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    61
	if (COUNT % 64 == 0)			\
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    62
		sha1_step(ctxt);		\
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    63
     }
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    64
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    65
#define	PUTPAD(x)	{ \
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    66
	ctxt->m.b8[(COUNT % 64)] = (x);		\
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    67
	COUNT++;				\
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    68
	COUNT %= 64;				\
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    69
	if (COUNT % 64 == 0)			\
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    70
		sha1_step(ctxt);		\
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    71
     }
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    72
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    73
static void sha1_step(struct sha1_ctxt *);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    74
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    75
static void
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    76
sha1_step(struct sha1_ctxt *ctxt)
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    77
{
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    78
	quint32	a, b, c, d, e;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    79
	size_t t, s;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    80
	quint32	tmp;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    81
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    82
	a = H(0); b = H(1); c = H(2); d = H(3); e = H(4);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    83
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    84
	for (t = 0; t < 20; t++) {
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    85
		s = t & 0x0f;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    86
		if (t >= 16) {
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    87
			W(s) = S(1, W((s+13) & 0x0f) ^ W((s+8) & 0x0f) ^ W((s+2) & 0x0f) ^ W(s));
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    88
		}
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    89
		tmp = S(5, a) + F0(b, c, d) + e + W(s) + K(t);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    90
		e = d; d = c; c = S(30, b); b = a; a = tmp;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    91
	}
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    92
	for (t = 20; t < 40; t++) {
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    93
		s = t & 0x0f;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    94
		W(s) = S(1, W((s+13) & 0x0f) ^ W((s+8) & 0x0f) ^ W((s+2) & 0x0f) ^ W(s));
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    95
		tmp = S(5, a) + F1(b, c, d) + e + W(s) + K(t);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    96
		e = d; d = c; c = S(30, b); b = a; a = tmp;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    97
	}
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    98
	for (t = 40; t < 60; t++) {
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    99
		s = t & 0x0f;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   100
		W(s) = S(1, W((s+13) & 0x0f) ^ W((s+8) & 0x0f) ^ W((s+2) & 0x0f) ^ W(s));
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   101
		tmp = S(5, a) + F2(b, c, d) + e + W(s) + K(t);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   102
		e = d; d = c; c = S(30, b); b = a; a = tmp;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   103
	}
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   104
	for (t = 60; t < 80; t++) {
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   105
		s = t & 0x0f;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   106
		W(s) = S(1, W((s+13) & 0x0f) ^ W((s+8) & 0x0f) ^ W((s+2) & 0x0f) ^ W(s));
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   107
		tmp = S(5, a) + F3(b, c, d) + e + W(s) + K(t);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   108
		e = d; d = c; c = S(30, b); b = a; a = tmp;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   109
	}
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   110
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   111
	H(0) = H(0) + a;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   112
	H(1) = H(1) + b;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   113
	H(2) = H(2) + c;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   114
	H(3) = H(3) + d;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   115
	H(4) = H(4) + e;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   116
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   117
	qMemSet(&ctxt->m.b8[0], 0, 64);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   118
}
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   119
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   120
/*------------------------------------------------------------*/
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   121
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   122
void sha1_init(struct sha1_ctxt *ctxt)
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   123
{
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   124
	qMemSet(ctxt, 0, sizeof(struct sha1_ctxt));
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   125
	H(0) = 0x67452301;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   126
	H(1) = 0xefcdab89;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   127
	H(2) = 0x98badcfe;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   128
	H(3) = 0x10325476;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   129
	H(4) = 0xc3d2e1f0;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   130
}
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   131
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   132
void sha1_pad(struct sha1_ctxt *ctxt)
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   133
{
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   134
	size_t padlen;		/*pad length in bytes*/
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   135
	size_t padstart;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   136
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   137
	PUTPAD(0x80);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   138
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   139
	padstart = COUNT % 64;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   140
	padlen = 64 - padstart;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   141
	if (padlen < 8) {
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   142
		qMemSet(&ctxt->m.b8[padstart], 0, padlen);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   143
		COUNT += padlen;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   144
		COUNT %= 64;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   145
		sha1_step(ctxt);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   146
		padstart = COUNT % 64;	/* should be 0 */
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   147
		padlen = 64 - padstart;	/* should be 64 */
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   148
	}
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   149
	qMemSet(&ctxt->m.b8[padstart], 0, padlen - 8);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   150
	COUNT += (padlen - 8);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   151
	COUNT %= 64;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   152
	PUTPAD(ctxt->c.b8[0]); PUTPAD(ctxt->c.b8[1]);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   153
	PUTPAD(ctxt->c.b8[2]); PUTPAD(ctxt->c.b8[3]);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   154
	PUTPAD(ctxt->c.b8[4]); PUTPAD(ctxt->c.b8[5]);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   155
	PUTPAD(ctxt->c.b8[6]); PUTPAD(ctxt->c.b8[7]);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   156
}
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   157
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   158
void sha1_loop(struct sha1_ctxt *ctxt, const quint8 *input, size_t len)
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   159
{
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   160
	size_t gaplen;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   161
	size_t gapstart;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   162
	size_t off;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   163
	size_t copysiz;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   164
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   165
	off = 0;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   166
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   167
	while (off < len) {
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   168
		gapstart = COUNT % 64;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   169
		gaplen = 64 - gapstart;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   170
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   171
		copysiz = (gaplen < len - off) ? gaplen : len - off;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   172
		qMemCopy(&ctxt->m.b8[gapstart], &input[off], copysiz);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   173
		COUNT += copysiz;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   174
		COUNT %= 64;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   175
		ctxt->c.b64[0] += copysiz * 8;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   176
		if (COUNT % 64 == 0)
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   177
			sha1_step(ctxt);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   178
		off += copysiz;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   179
	}
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   180
}
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   181
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   182
void sha1_result(struct sha1_ctxt *ctxt, sha1_digest digest0)
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   183
{
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   184
	quint8 *digest;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   185
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   186
	digest = (quint8 *)digest0;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   187
	sha1_pad(ctxt);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   188
	qMemCopy(digest, &ctxt->h.b8[0], 20);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
   189
}