Skip to content
This repository was archived by the owner on Jan 9, 2021. It is now read-only.

Commit 5a2c6d2

Browse files
author
nicehashdev
committed
Faster Lyra2RE
1 parent a105a75 commit 5a2c6d2

32 files changed

Lines changed: 12839 additions & 706 deletions

algo/aes_ni/README

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
This package contains an implementation of the Groestl-512 hash
2+
function optimized for the Intel AES instructions.
3+
4+
Authors are Krystian Matusiewicz, Günther A. Roland, Martin Schläffer
5+
6+
There are no known present or future claims by a copyright holder that
7+
the distribution of this software infringes the copyright. In
8+
particular, the author of the software is not making such claims and
9+
does not intend to make such claims.
10+
11+
Moreover, there are no known present or future claims by a patent
12+
holder that the use of this software infringes the patent. In
13+
particular, the author of the software is not making such claims and
14+
does not intend to make such claims.

algo/aes_ni/api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define CRYPTO_BYTES 64
2+
#define CRYPTO_VERSION "2.2"

algo/aes_ni/architectures

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
amd64

algo/aes_ni/brg_endian.h

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
---------------------------------------------------------------------------
3+
Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved.
4+
5+
LICENSE TERMS
6+
7+
The redistribution and use of this software (with or without changes)
8+
is allowed without the payment of fees or royalties provided that:
9+
10+
1. source code distributions include the above copyright notice, this
11+
list of conditions and the following disclaimer;
12+
13+
2. binary distributions include the above copyright notice, this list
14+
of conditions and the following disclaimer in their documentation;
15+
16+
3. the name of the copyright holder is not used to endorse products
17+
built using this software without specific written permission.
18+
19+
DISCLAIMER
20+
21+
This software is provided 'as is' with no explicit or implied warranties
22+
in respect of its properties, including, but not limited to, correctness
23+
and/or fitness for purpose.
24+
---------------------------------------------------------------------------
25+
Issue Date: 20/12/2007
26+
*/
27+
28+
#ifndef _BRG_ENDIAN_H
29+
#define _BRG_ENDIAN_H
30+
31+
#define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */
32+
#define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */
33+
34+
/* Include files where endian defines and byteswap functions may reside */
35+
#if defined( __sun )
36+
# include <sys/isa_defs.h>
37+
#elif defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __NetBSD__ )
38+
# include <sys/endian.h>
39+
#elif defined( BSD ) && ( BSD >= 199103 ) || defined( __APPLE__ ) || \
40+
defined( __CYGWIN32__ ) || defined( __DJGPP__ ) || defined( __osf__ )
41+
# include <machine/endian.h>
42+
#elif defined( __linux__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
43+
# if !defined( __MINGW32__ ) && !defined( _AIX )
44+
# include <endian.h>
45+
# if !defined( __BEOS__ )
46+
# include <byteswap.h>
47+
# endif
48+
# endif
49+
#endif
50+
51+
/* Now attempt to set the define for platform byte order using any */
52+
/* of the four forms SYMBOL, _SYMBOL, __SYMBOL & __SYMBOL__, which */
53+
/* seem to encompass most endian symbol definitions */
54+
55+
#if defined( BIG_ENDIAN ) && defined( LITTLE_ENDIAN )
56+
# if defined( BYTE_ORDER ) && BYTE_ORDER == BIG_ENDIAN
57+
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
58+
# elif defined( BYTE_ORDER ) && BYTE_ORDER == LITTLE_ENDIAN
59+
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
60+
# endif
61+
#elif defined( BIG_ENDIAN )
62+
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
63+
#elif defined( LITTLE_ENDIAN )
64+
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
65+
#endif
66+
67+
#if defined( _BIG_ENDIAN ) && defined( _LITTLE_ENDIAN )
68+
# if defined( _BYTE_ORDER ) && _BYTE_ORDER == _BIG_ENDIAN
69+
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
70+
# elif defined( _BYTE_ORDER ) && _BYTE_ORDER == _LITTLE_ENDIAN
71+
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
72+
# endif
73+
#elif defined( _BIG_ENDIAN )
74+
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
75+
#elif defined( _LITTLE_ENDIAN )
76+
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
77+
#endif
78+
79+
#if defined( __BIG_ENDIAN ) && defined( __LITTLE_ENDIAN )
80+
# if defined( __BYTE_ORDER ) && __BYTE_ORDER == __BIG_ENDIAN
81+
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
82+
# elif defined( __BYTE_ORDER ) && __BYTE_ORDER == __LITTLE_ENDIAN
83+
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
84+
# endif
85+
#elif defined( __BIG_ENDIAN )
86+
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
87+
#elif defined( __LITTLE_ENDIAN )
88+
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
89+
#endif
90+
91+
#if defined( __BIG_ENDIAN__ ) && defined( __LITTLE_ENDIAN__ )
92+
# if defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __BIG_ENDIAN__
93+
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
94+
# elif defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __LITTLE_ENDIAN__
95+
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
96+
# endif
97+
#elif defined( __BIG_ENDIAN__ )
98+
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
99+
#elif defined( __LITTLE_ENDIAN__ )
100+
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
101+
#endif
102+
103+
/* if the platform byte order could not be determined, then try to */
104+
/* set this define using common machine defines */
105+
#if !defined(PLATFORM_BYTE_ORDER)
106+
107+
#if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \
108+
defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \
109+
defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \
110+
defined( vax ) || defined( vms ) || defined( VMS ) || \
111+
defined( __VMS ) || defined( _M_X64 )
112+
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
113+
114+
#elif defined( AMIGA ) || defined( applec ) || defined( __AS400__ ) || \
115+
defined( _CRAY ) || defined( __hppa ) || defined( __hp9000 ) || \
116+
defined( ibm370 ) || defined( mc68000 ) || defined( m68k ) || \
117+
defined( __MRC__ ) || defined( __MVS__ ) || defined( __MWERKS__ ) || \
118+
defined( sparc ) || defined( __sparc) || defined( SYMANTEC_C ) || \
119+
defined( __VOS__ ) || defined( __TIGCC__ ) || defined( __TANDEM ) || \
120+
defined( THINK_C ) || defined( __VMCMS__ ) || defined( _AIX )
121+
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
122+
123+
#elif 0 /* **** EDIT HERE IF NECESSARY **** */
124+
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
125+
#elif 0 /* **** EDIT HERE IF NECESSARY **** */
126+
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
127+
#else
128+
# error Please edit lines 126 or 128 in brg_endian.h to set the platform byte order
129+
#endif
130+
131+
#endif
132+
133+
#endif

algo/aes_ni/brg_types.h

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
/*
2+
---------------------------------------------------------------------------
3+
Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved.
4+
5+
(a few lines added by Soeren S. Thomsen, October 2008)
6+
7+
LICENSE TERMS
8+
9+
The redistribution and use of this software (with or without changes)
10+
is allowed without the payment of fees or royalties provided that:
11+
12+
1. source code distributions include the above copyright notice, this
13+
list of conditions and the following disclaimer;
14+
15+
2. binary distributions include the above copyright notice, this list
16+
of conditions and the following disclaimer in their documentation;
17+
18+
3. the name of the copyright holder is not used to endorse products
19+
built using this software without specific written permission.
20+
21+
DISCLAIMER
22+
23+
This software is provided 'as is' with no explicit or implied warranties
24+
in respect of its properties, including, but not limited to, correctness
25+
and/or fitness for purpose.
26+
---------------------------------------------------------------------------
27+
Issue Date: 20/12/2007
28+
29+
The unsigned integer types defined here are of the form uint_<nn>t where
30+
<nn> is the length of the type; for example, the unsigned 32-bit type is
31+
'uint_32t'. These are NOT the same as the 'C99 integer types' that are
32+
defined in the inttypes.h and stdint.h headers since attempts to use these
33+
types have shown that support for them is still highly variable. However,
34+
since the latter are of the form uint<nn>_t, a regular expression search
35+
and replace (in VC++ search on 'uint_{:z}t' and replace with 'uint\1_t')
36+
can be used to convert the types used here to the C99 standard types.
37+
*/
38+
39+
#ifndef _BRG_TYPES_H
40+
#define _BRG_TYPES_H
41+
42+
#if defined(__cplusplus)
43+
extern "C" {
44+
#endif
45+
46+
#include <limits.h>
47+
48+
#if defined( _MSC_VER ) && ( _MSC_VER >= 1300 )
49+
# include <stddef.h>
50+
# define ptrint_t intptr_t
51+
#elif defined( __GNUC__ ) && ( __GNUC__ >= 3 )
52+
# include <stdint.h>
53+
# define ptrint_t intptr_t
54+
#else
55+
# define ptrint_t int
56+
#endif
57+
58+
#ifndef BRG_UI8
59+
# define BRG_UI8
60+
# if UCHAR_MAX == 255u
61+
typedef unsigned char uint_8t;
62+
# else
63+
# error Please define uint_8t as an 8-bit unsigned integer type in brg_types.h
64+
# endif
65+
#endif
66+
67+
#ifndef BRG_UI16
68+
# define BRG_UI16
69+
# if USHRT_MAX == 65535u
70+
typedef unsigned short uint_16t;
71+
# else
72+
# error Please define uint_16t as a 16-bit unsigned short type in brg_types.h
73+
# endif
74+
#endif
75+
76+
#ifndef BRG_UI32
77+
# define BRG_UI32
78+
# if UINT_MAX == 4294967295u
79+
# define li_32(h) 0x##h##u
80+
typedef unsigned int uint_32t;
81+
# elif ULONG_MAX == 4294967295u
82+
# define li_32(h) 0x##h##ul
83+
typedef unsigned long uint_32t;
84+
# elif defined( _CRAY )
85+
# error This code needs 32-bit data types, which Cray machines do not provide
86+
# else
87+
# error Please define uint_32t as a 32-bit unsigned integer type in brg_types.h
88+
# endif
89+
#endif
90+
91+
#ifndef BRG_UI64
92+
# if defined( __BORLANDC__ ) && !defined( __MSDOS__ )
93+
# define BRG_UI64
94+
# define li_64(h) 0x##h##ui64
95+
typedef unsigned __int64 uint_64t;
96+
# elif defined( _MSC_VER ) && ( _MSC_VER < 1300 ) /* 1300 == VC++ 7.0 */
97+
# define BRG_UI64
98+
# define li_64(h) 0x##h##ui64
99+
typedef unsigned __int64 uint_64t;
100+
# elif defined( __sun ) && defined( ULONG_MAX ) && ULONG_MAX == 0xfffffffful
101+
# define BRG_UI64
102+
# define li_64(h) 0x##h##ull
103+
typedef unsigned long long uint_64t;
104+
# elif defined( __MVS__ )
105+
# define BRG_UI64
106+
# define li_64(h) 0x##h##ull
107+
typedef unsigned int long long uint_64t;
108+
# elif defined( UINT_MAX ) && UINT_MAX > 4294967295u
109+
# if UINT_MAX == 18446744073709551615u
110+
# define BRG_UI64
111+
# define li_64(h) 0x##h##u
112+
typedef unsigned int uint_64t;
113+
# endif
114+
# elif defined( ULONG_MAX ) && ULONG_MAX > 4294967295u
115+
# if ULONG_MAX == 18446744073709551615ul
116+
# define BRG_UI64
117+
# define li_64(h) 0x##h##ul
118+
typedef unsigned long uint_64t;
119+
# endif
120+
# elif defined( ULLONG_MAX ) && ULLONG_MAX > 4294967295u
121+
# if ULLONG_MAX == 18446744073709551615ull
122+
# define BRG_UI64
123+
# define li_64(h) 0x##h##ull
124+
typedef unsigned long long uint_64t;
125+
# endif
126+
# elif defined( ULONG_LONG_MAX ) && ULONG_LONG_MAX > 4294967295u
127+
# if ULONG_LONG_MAX == 18446744073709551615ull
128+
# define BRG_UI64
129+
# define li_64(h) 0x##h##ull
130+
typedef unsigned long long uint_64t;
131+
# endif
132+
# endif
133+
#endif
134+
135+
#if !defined( BRG_UI64 )
136+
# if defined( NEED_UINT_64T )
137+
# define BRG_UI64
138+
# define li_64(h) 0x##h##ull
139+
typedef unsigned long long uint_64t;
140+
/*# error Please define uint_64t as an unsigned 64 bit type in brg_types.h*/
141+
# endif
142+
#endif
143+
144+
#ifndef RETURN_VALUES
145+
# define RETURN_VALUES
146+
# if defined( DLL_EXPORT )
147+
# if defined( _MSC_VER ) || defined ( __INTEL_COMPILER )
148+
# define VOID_RETURN __declspec( dllexport ) void __stdcall
149+
# define INT_RETURN __declspec( dllexport ) int __stdcall
150+
# elif defined( __GNUC__ )
151+
# define VOID_RETURN __declspec( __dllexport__ ) void
152+
# define INT_RETURN __declspec( __dllexport__ ) int
153+
# else
154+
# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers
155+
# endif
156+
# elif defined( DLL_IMPORT )
157+
# if defined( _MSC_VER ) || defined ( __INTEL_COMPILER )
158+
# define VOID_RETURN __declspec( dllimport ) void __stdcall
159+
# define INT_RETURN __declspec( dllimport ) int __stdcall
160+
# elif defined( __GNUC__ )
161+
# define VOID_RETURN __declspec( __dllimport__ ) void
162+
# define INT_RETURN __declspec( __dllimport__ ) int
163+
# else
164+
# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers
165+
# endif
166+
# elif defined( __WATCOMC__ )
167+
# define VOID_RETURN void __cdecl
168+
# define INT_RETURN int __cdecl
169+
# else
170+
# define VOID_RETURN void
171+
# define INT_RETURN int
172+
# endif
173+
#endif
174+
175+
/* These defines are used to detect and set the memory alignment of pointers.
176+
Note that offsets are in bytes.
177+
178+
ALIGN_OFFSET(x,n) return the positive or zero offset of
179+
the memory addressed by the pointer 'x'
180+
from an address that is aligned on an
181+
'n' byte boundary ('n' is a power of 2)
182+
183+
ALIGN_FLOOR(x,n) return a pointer that points to memory
184+
that is aligned on an 'n' byte boundary
185+
and is not higher than the memory address
186+
pointed to by 'x' ('n' is a power of 2)
187+
188+
ALIGN_CEIL(x,n) return a pointer that points to memory
189+
that is aligned on an 'n' byte boundary
190+
and is not lower than the memory address
191+
pointed to by 'x' ('n' is a power of 2)
192+
*/
193+
194+
#define ALIGN_OFFSET(x,n) (((ptrint_t)(x)) & ((n) - 1))
195+
#define ALIGN_FLOOR(x,n) ((uint_8t*)(x) - ( ((ptrint_t)(x)) & ((n) - 1)))
196+
#define ALIGN_CEIL(x,n) ((uint_8t*)(x) + (-((ptrint_t)(x)) & ((n) - 1)))
197+
198+
/* These defines are used to declare buffers in a way that allows
199+
faster operations on longer variables to be used. In all these
200+
defines 'size' must be a power of 2 and >= 8. NOTE that the
201+
buffer size is in bytes but the type length is in bits
202+
203+
UNIT_TYPEDEF(x,size) declares a variable 'x' of length
204+
'size' bits
205+
206+
BUFR_TYPEDEF(x,size,bsize) declares a buffer 'x' of length 'bsize'
207+
bytes defined as an array of variables
208+
each of 'size' bits (bsize must be a
209+
multiple of size / 8)
210+
211+
UNIT_CAST(x,size) casts a variable to a type of
212+
length 'size' bits
213+
214+
UPTR_CAST(x,size) casts a pointer to a pointer to a
215+
varaiable of length 'size' bits
216+
*/
217+
218+
#define UI_TYPE(size) uint_##size##t
219+
#define UNIT_TYPEDEF(x,size) typedef UI_TYPE(size) x
220+
#define BUFR_TYPEDEF(x,size,bsize) typedef UI_TYPE(size) x[bsize / (size >> 3)]
221+
#define UNIT_CAST(x,size) ((UI_TYPE(size) )(x))
222+
#define UPTR_CAST(x,size) ((UI_TYPE(size)*)(x))
223+
224+
/* Added by Soeren S. Thomsen (begin) */
225+
#define u8 uint_8t
226+
#define u32 uint_32t
227+
#define u64 uint_64t
228+
/* (end) */
229+
230+
#if defined(__cplusplus)
231+
}
232+
#endif
233+
234+
#endif

0 commit comments

Comments
 (0)