QTfrontend/sha1.h
author unc0rr
Tue, 10 Jan 2006 19:53:18 +0000
changeset 43 e297fea1a2f3
parent 33 d6363050cad0
permissions -rw-r--r--
- Removed dark pixels on the corners of health case - Cleaned up dynamite code - Dynamite sprite - Frontend shows error messages from engine (except IPC-related :) ) - changed IPC-related stuff in frontend
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
 * FIPS pub 180-1: Secure Hash Algorithm (SHA-1)
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    33
 * based on: http://csrc.nist.gov/fips/fip180-1.txt
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    34
 * implemented by Jun-ichiro itojun Itoh <itojun@itojun.org>
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    35
 */
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    36
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    37
#include <qglobal.h>
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    38
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    39
#ifdef __cplusplus
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    40
extern "C" {
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    41
#endif
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    42
typedef unsigned char sha1_digest[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
struct sha1_ctxt {
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    45
	union {
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    46
		quint8	b8[20];
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    47
		quint32	b32[5];
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    48
	} h;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    49
	union {
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    50
		quint8	b8[8];
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    51
		quint64	b64[1];
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    52
	} c;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    53
	union {
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    54
		quint8	b8[64];
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    55
		quint32	b32[16];
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    56
	} m;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    57
	quint8	count;
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    58
};
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    59
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    60
void sha1_init(struct sha1_ctxt *ctxt);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    61
void sha1_pad(struct sha1_ctxt *ctxt);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    62
extern void sha1_loop(struct sha1_ctxt *ctxt, const quint8 *input, size_t len);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    63
extern void sha1_result(struct sha1_ctxt *ctxt, sha1_digest digest0);
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    64
#ifdef __cplusplus
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    65
}
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    66
#endif
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    67
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    68
#define SHA1Init(x)		sha1_init((x))
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    69
#define SHA1Update(x, y, z)	sha1_loop((x), (y), (z))
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    70
#define SHA1Final(x, y)		sha1_result((y), (x))
d6363050cad0 fix to compile on Linux
unc0rr
parents: 21
diff changeset
    71