aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/aesGladman/sha2.h
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/aesGladman/sha2.h')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/aesGladman/sha2.h320
1 files changed, 160 insertions, 160 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/aesGladman/sha2.h b/libraries/irrlicht-1.8/source/Irrlicht/aesGladman/sha2.h
index 34e84aa..006dd62 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/aesGladman/sha2.h
+++ b/libraries/irrlicht-1.8/source/Irrlicht/aesGladman/sha2.h
@@ -1,160 +1,160 @@
1/* 1/*
2 --------------------------------------------------------------------------- 2 ---------------------------------------------------------------------------
3 Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK. 3 Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK.
4 All rights reserved. 4 All rights reserved.
5 5
6 LICENSE TERMS 6 LICENSE TERMS
7 7
8 The free distribution and use of this software in both source and binary 8 The free distribution and use of this software in both source and binary
9 form is allowed (with or without changes) provided that: 9 form is allowed (with or without changes) provided that:
10 10
11 1. distributions of this source code include the above copyright 11 1. distributions of this source code include the above copyright
12 notice, this list of conditions and the following disclaimer; 12 notice, this list of conditions and the following disclaimer;
13 13
14 2. distributions in binary form include the above copyright 14 2. distributions in binary form include the above copyright
15 notice, this list of conditions and the following disclaimer 15 notice, this list of conditions and the following disclaimer
16 in the documentation and/or other associated materials; 16 in the documentation and/or other associated materials;
17 17
18 3. the copyright holder's name is not used to endorse products 18 3. the copyright holder's name is not used to endorse products
19 built using this software without specific written permission. 19 built using this software without specific written permission.
20 20
21 ALTERNATIVELY, provided that this notice is retained in full, this product 21 ALTERNATIVELY, provided that this notice is retained in full, this product
22 may be distributed under the terms of the GNU General Public License (GPL), 22 may be distributed under the terms of the GNU General Public License (GPL),
23 in which case the provisions of the GPL apply INSTEAD OF those given above. 23 in which case the provisions of the GPL apply INSTEAD OF those given above.
24 24
25 DISCLAIMER 25 DISCLAIMER
26 26
27 This software is provided 'as is' with no explicit or implied warranties 27 This software is provided 'as is' with no explicit or implied warranties
28 in respect of its properties, including, but not limited to, correctness 28 in respect of its properties, including, but not limited to, correctness
29 and/or fitness for purpose. 29 and/or fitness for purpose.
30 --------------------------------------------------------------------------- 30 ---------------------------------------------------------------------------
31 Issue Date: 26/08/2003 31 Issue Date: 26/08/2003
32*/ 32*/
33 33
34#ifndef _SHA2_H 34#ifndef _SHA2_H
35#define _SHA2_H 35#define _SHA2_H
36 36
37#include "irrMath.h" 37#include "irrMath.h"
38 38
39/* Defines for suffixes to 32 and 64 bit unsigned numeric values */ 39/* Defines for suffixes to 32 and 64 bit unsigned numeric values */
40 40
41#define sfx_lo(x,y) x##y 41#define sfx_lo(x,y) x##y
42#define sfx_hi(x,y) sfx_lo(x,y) 42#define sfx_hi(x,y) sfx_lo(x,y)
43#define n_u32(p) sfx_hi(0x##p,s_u32) 43#define n_u32(p) sfx_hi(0x##p,s_u32)
44#define n_u64(p) sfx_hi(0x##p,s_u64) 44#define n_u64(p) sfx_hi(0x##p,s_u64)
45 45
46/* define an unsigned 32-bit type */ 46/* define an unsigned 32-bit type */
47 47
48#if UINT_MAX == 0xffffffff 48#if UINT_MAX == 0xffffffff
49 typedef unsigned int sha2_32t; 49 typedef unsigned int sha2_32t;
50 #define s_u32 u 50 #define s_u32 u
51#elif ULONG_MAX == 0xffffffff 51#elif ULONG_MAX == 0xffffffff
52 typedef unsigned long sha2_32t; 52 typedef unsigned long sha2_32t;
53 #define s_u32 ul 53 #define s_u32 ul
54#else 54#else
55#error Please define sha2_32t as an unsigned 32 bit type in sha2.h 55#error Please define sha2_32t as an unsigned 32 bit type in sha2.h
56#endif 56#endif
57 57
58/* define an unsigned 64-bit type */ 58/* define an unsigned 64-bit type */
59 59
60#ifdef _MSC_VER 60#ifdef _MSC_VER
61#if _MSC_VER < 1300 61#if _MSC_VER < 1300
62 typedef unsigned __int64 sha2_64t; 62 typedef unsigned __int64 sha2_64t;
63 #define s_u64 ui64 63 #define s_u64 ui64
64#elif ULONG_MAX == 0xffffffffffffffff 64#elif ULONG_MAX == 0xffffffffffffffff
65 typedef unsigned long sha2_64t; 65 typedef unsigned long sha2_64t;
66 #define s_u64 ul 66 #define s_u64 ul
67#elif ULONG_MAX == 0xffffffff 67#elif ULONG_MAX == 0xffffffff
68 typedef unsigned long long sha2_64t; /* a somewhat dangerous guess */ 68 typedef unsigned long long sha2_64t; /* a somewhat dangerous guess */
69 #define s_u64 ull 69 #define s_u64 ull
70#else 70#else
71#error Please define sha2_64t as an unsigned 64 bit type in sha2.h 71#error Please define sha2_64t as an unsigned 64 bit type in sha2.h
72#endif 72#endif
73#else 73#else
74#ifdef _IRR_SOLARIS_PLATFORM_ 74#ifdef _IRR_SOLARIS_PLATFORM_
75#include <sys/int_types.h> 75#include <sys/int_types.h>
76#else 76#else
77#include <stdint.h> 77#include <stdint.h>
78#endif 78#endif
79 typedef int64_t sha2_64t; 79 typedef int64_t sha2_64t;
80#if __WORDSIZE==64 80#if __WORDSIZE==64
81#define s_u64 ul 81#define s_u64 ul
82#else 82#else
83#define s_u64 ull 83#define s_u64 ull
84#endif 84#endif
85#endif 85#endif
86 86
87#define SHA256_DIGEST_SIZE 32 87#define SHA256_DIGEST_SIZE 32
88#define SHA384_DIGEST_SIZE 48 88#define SHA384_DIGEST_SIZE 48
89#define SHA512_DIGEST_SIZE 64 89#define SHA512_DIGEST_SIZE 64
90 90
91#define SHA256_BLOCK_SIZE 64 91#define SHA256_BLOCK_SIZE 64
92#define SHA384_BLOCK_SIZE 128 92#define SHA384_BLOCK_SIZE 128
93#define SHA512_BLOCK_SIZE 128 93#define SHA512_BLOCK_SIZE 128
94 94
95#define SHA2_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE 95#define SHA2_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE
96 96
97#define SHA2_GOOD 0 97#define SHA2_GOOD 0
98#define SHA2_BAD 1 98#define SHA2_BAD 1
99 99
100/* type to hold the SHA256 context */ 100/* type to hold the SHA256 context */
101 101
102typedef struct 102typedef struct
103{ sha2_32t count[2]; 103{ sha2_32t count[2];
104 sha2_32t hash[8]; 104 sha2_32t hash[8];
105 sha2_32t wbuf[16]; 105 sha2_32t wbuf[16];
106} sha256_ctx; 106} sha256_ctx;
107 107
108/* type to hold the SHA384/512 context */ 108/* type to hold the SHA384/512 context */
109 109
110typedef struct 110typedef struct
111{ sha2_64t count[2]; 111{ sha2_64t count[2];
112 sha2_64t hash[8]; 112 sha2_64t hash[8];
113 sha2_64t wbuf[16]; 113 sha2_64t wbuf[16];
114} sha512_ctx; 114} sha512_ctx;
115 115
116typedef sha512_ctx sha384_ctx; 116typedef sha512_ctx sha384_ctx;
117 117
118/* type to hold a SHA2 context (256/384/512) */ 118/* type to hold a SHA2 context (256/384/512) */
119 119
120typedef struct 120typedef struct
121{ union 121{ union
122 { sha256_ctx ctx256[1]; 122 { sha256_ctx ctx256[1];
123 sha512_ctx ctx512[1]; 123 sha512_ctx ctx512[1];
124 } uu[1]; 124 } uu[1];
125 sha2_32t sha2_len; 125 sha2_32t sha2_len;
126} sha2_ctx; 126} sha2_ctx;
127 127
128#ifndef SHA2_DLL /* implement normal or DLL functions */ 128#ifndef SHA2_DLL /* implement normal or DLL functions */
129#define sha2_void void 129#define sha2_void void
130#define sha2_int int 130#define sha2_int int
131#else 131#else
132#define sha2_void void __declspec(dllexport) _stdcall 132#define sha2_void void __declspec(dllexport) _stdcall
133#define sha2_int int __declspec(dllexport) _stdcall 133#define sha2_int int __declspec(dllexport) _stdcall
134#endif 134#endif
135 135
136sha2_void sha256_compile(sha256_ctx ctx[1]); 136sha2_void sha256_compile(sha256_ctx ctx[1]);
137sha2_void sha512_compile(sha512_ctx ctx[1]); 137sha2_void sha512_compile(sha512_ctx ctx[1]);
138 138
139sha2_void sha256_begin(sha256_ctx ctx[1]); 139sha2_void sha256_begin(sha256_ctx ctx[1]);
140sha2_void sha256_hash(const unsigned char data[], unsigned long len, sha256_ctx ctx[1]); 140sha2_void sha256_hash(const unsigned char data[], unsigned long len, sha256_ctx ctx[1]);
141sha2_void sha256_end(unsigned char hval[], sha256_ctx ctx[1]); 141sha2_void sha256_end(unsigned char hval[], sha256_ctx ctx[1]);
142sha2_void sha256(unsigned char hval[], const unsigned char data[], unsigned long len); 142sha2_void sha256(unsigned char hval[], const unsigned char data[], unsigned long len);
143 143
144sha2_void sha384_begin(sha384_ctx ctx[1]); 144sha2_void sha384_begin(sha384_ctx ctx[1]);
145#define sha384_hash sha512_hash 145#define sha384_hash sha512_hash
146sha2_void sha384_end(unsigned char hval[], sha384_ctx ctx[1]); 146sha2_void sha384_end(unsigned char hval[], sha384_ctx ctx[1]);
147sha2_void sha384(unsigned char hval[], const unsigned char data[], unsigned long len); 147sha2_void sha384(unsigned char hval[], const unsigned char data[], unsigned long len);
148 148
149sha2_void sha512_begin(sha512_ctx ctx[1]); 149sha2_void sha512_begin(sha512_ctx ctx[1]);
150sha2_void sha512_hash(const unsigned char data[], unsigned long len, sha512_ctx ctx[1]); 150sha2_void sha512_hash(const unsigned char data[], unsigned long len, sha512_ctx ctx[1]);
151sha2_void sha512_end(unsigned char hval[], sha512_ctx ctx[1]); 151sha2_void sha512_end(unsigned char hval[], sha512_ctx ctx[1]);
152sha2_void sha512(unsigned char hval[], const unsigned char data[], unsigned long len); 152sha2_void sha512(unsigned char hval[], const unsigned char data[], unsigned long len);
153 153
154sha2_int sha2_begin(unsigned long size, sha2_ctx ctx[1]); 154sha2_int sha2_begin(unsigned long size, sha2_ctx ctx[1]);
155sha2_void sha2_hash(const unsigned char data[], unsigned long len, sha2_ctx ctx[1]); 155sha2_void sha2_hash(const unsigned char data[], unsigned long len, sha2_ctx ctx[1]);
156sha2_void sha2_end(unsigned char hval[], sha2_ctx ctx[1]); 156sha2_void sha2_end(unsigned char hval[], sha2_ctx ctx[1]);
157sha2_int sha2(unsigned char hval[], unsigned long size, const unsigned char data[], unsigned long len); 157sha2_int sha2(unsigned char hval[], unsigned long size, const unsigned char data[], unsigned long len);
158 158
159#endif 159#endif
160 160