Use freetiger by default.
This commit is contained in:
parent
15e9c905f3
commit
31c1e37180
6 changed files with 47 additions and 14 deletions
|
@ -6,4 +6,6 @@ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -Wall -Wdeprecated")
|
||||||
set(CMAKE_D_FLAGS_DEBUG "${CMAKE_D_FLAGS_DEBUG} -funittest -g -O0 -Wall -Wdeprecated")
|
set(CMAKE_D_FLAGS_DEBUG "${CMAKE_D_FLAGS_DEBUG} -funittest -g -O0 -Wall -Wdeprecated")
|
||||||
set(CMAKE_D_FLAGS_RELEASE "${CMAKE_D_FLAGS_RELEASE} -O3 -Wall -Wdeprecated")
|
set(CMAKE_D_FLAGS_RELEASE "${CMAKE_D_FLAGS_RELEASE} -O3 -Wall -Wdeprecated")
|
||||||
|
|
||||||
|
option(REFERENCE_TIGER "Use the reference implementation of the tiger algorithm." OFF)
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
|
@ -627,16 +627,17 @@ for (j = 0; j < 3; j++) {\
|
||||||
#define fixresendian_2
|
#define fixresendian_2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void tiger_init(t_res res)
|
||||||
void tiger(const char *str, t_word length, t_res res)
|
|
||||||
{
|
{
|
||||||
t_block tmp;
|
|
||||||
const char * end = str + (length&(-64));
|
|
||||||
t_word i;
|
|
||||||
endianvars;
|
|
||||||
res[0]=0x0123456789ABCDEFULL;
|
res[0]=0x0123456789ABCDEFULL;
|
||||||
res[1]=0xFEDCBA9876543210ULL;
|
res[1]=0xFEDCBA9876543210ULL;
|
||||||
res[2]=0xF096A5B4C3B2E187ULL;
|
res[2]=0xF096A5B4C3B2E187ULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tiger_chunk(const char *str, t_word length, t_res res)
|
||||||
|
{
|
||||||
|
const char * end = str + (length&(-64));
|
||||||
|
endianvars;
|
||||||
|
|
||||||
while(str<end)
|
while(str<end)
|
||||||
{
|
{
|
||||||
|
@ -658,6 +659,13 @@ void tiger(const char *str, t_word length, t_res res)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tiger_last_chunk(const char *str, t_word length, t_word reallength, t_res res, char pad)
|
||||||
|
{
|
||||||
|
t_block tmp;
|
||||||
|
t_word i;
|
||||||
|
|
||||||
i=length & 63;
|
i=length & 63;
|
||||||
//Padding on last block
|
//Padding on last block
|
||||||
//add 0x01 afterwards.
|
//add 0x01 afterwards.
|
||||||
|
@ -665,7 +673,7 @@ void tiger(const char *str, t_word length, t_res res)
|
||||||
//If we have a whole block now encrypt and start with empty block
|
//If we have a whole block now encrypt and start with empty block
|
||||||
//Finally add message size at the end of the block.
|
//Finally add message size at the end of the block.
|
||||||
memcpy(tmp,str,(size_t)i);
|
memcpy(tmp,str,(size_t)i);
|
||||||
uc(tmp)[i++]=0x01;
|
uc(tmp)[i++]=pad;
|
||||||
memset(uc(tmp)+i,0,(size_t)((8-i)&7));
|
memset(uc(tmp)+i,0,(size_t)((8-i)&7));
|
||||||
i+=(8-i)&7;
|
i+=(8-i)&7;
|
||||||
//Reorder the block so it uses propper endianism now
|
//Reorder the block so it uses propper endianism now
|
||||||
|
@ -685,12 +693,20 @@ void tiger(const char *str, t_word length, t_res res)
|
||||||
}
|
}
|
||||||
//Reordering here is not needed anymore since these ops are done with propper endian
|
//Reordering here is not needed anymore since these ops are done with propper endian
|
||||||
memset(uc(tmp)+i,0,(size_t)(56-i));
|
memset(uc(tmp)+i,0,(size_t)(56-i));
|
||||||
(tmp[7])=length<<(t_word)3;
|
(tmp[7])=reallength<<(t_word)3;
|
||||||
tiger_block(tmp, res);
|
tiger_block(tmp, res);
|
||||||
//Finally we reorder the result so it is shown in little endian
|
//Finally we reorder the result so it is shown in little endian
|
||||||
fixresendian;
|
fixresendian;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tiger(const char *str, t_word length, t_res res, char pad)
|
||||||
|
{
|
||||||
|
const t_word proc_length = length & ~(t_word)0x3f;
|
||||||
|
tiger_init(res);
|
||||||
|
tiger_chunk(str, proc_length, res);
|
||||||
|
tiger_last_chunk(str + proc_length, length - proc_length, length, res, pad);
|
||||||
|
}
|
||||||
|
|
||||||
void tiger_2(const char *str1, const char *str2, t_word length, t_res res1, t_res res2)
|
void tiger_2(const char *str1, const char *str2, t_word length, t_res res1, t_res res2)
|
||||||
{
|
{
|
||||||
t_block tmp1;
|
t_block tmp1;
|
||||||
|
|
|
@ -95,7 +95,7 @@ typedef struct {
|
||||||
typedef t_word t_block[8];
|
typedef t_word t_block[8];
|
||||||
|
|
||||||
/** Standard tiger calculation, put your string in str and the string length on length and get the result on res **/
|
/** Standard tiger calculation, put your string in str and the string length on length and get the result on res **/
|
||||||
void tiger(const char *str, t_word length, t_res res);
|
void tiger(const char *str, t_word length, t_res res, char pad);
|
||||||
/** Similar to tiger but interleaving accesses to both equally sized strings to reduce overhead and pipeline stalls you get the result of str1 on res1 and the one of str2 on res2 **/
|
/** Similar to tiger but interleaving accesses to both equally sized strings to reduce overhead and pipeline stalls you get the result of str1 on res1 and the one of str2 on res2 **/
|
||||||
void tiger_2(const char *str1, const char *str2, t_word length, t_res res1, t_res res2);
|
void tiger_2(const char *str1, const char *str2, t_word length, t_res res1, t_res res2);
|
||||||
#ifdef __SSE2__
|
#ifdef __SSE2__
|
||||||
|
|
|
@ -5,6 +5,18 @@ set(DEFAULT_TIGER_VERSION "1")
|
||||||
set(TIGERSUM_MAJOR "0")
|
set(TIGERSUM_MAJOR "0")
|
||||||
set(TIGERSUM_MINOR "1")
|
set(TIGERSUM_MINOR "1")
|
||||||
|
|
||||||
|
if (REFERENCE_TIGER)
|
||||||
|
set(BACKEND_NAME "tiger")
|
||||||
|
set(BACKEND_WEBSITE "http://www.cs.technion.ac.il/~biham/Reports/Tiger/")
|
||||||
|
set(BACKEND_AUTHOR "Ross Anderson and Eli Biham")
|
||||||
|
set(TIGER_SRC_FILES ../lib/reference_tiger/sboxes.c ../lib/reference_tiger/tiger.c)
|
||||||
|
else (REFERENCE_TIGER)
|
||||||
|
set(BACKEND_NAME "freetiger")
|
||||||
|
set(BACKEND_WEBSITE "http://klondike.es/freetiger/")
|
||||||
|
set(BACKEND_AUTHOR "klondike")
|
||||||
|
set(TIGER_SRC_FILES ../lib/freetiger/C/tiger.c)
|
||||||
|
endif (REFERENCE_TIGER)
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
"${PROJECT_SOURCE_DIR}/${PROJECT_NAME}Config.d.in"
|
"${PROJECT_SOURCE_DIR}/${PROJECT_NAME}Config.d.in"
|
||||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.d"
|
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.d"
|
||||||
|
@ -16,8 +28,7 @@ include_directories(
|
||||||
add_definitions("-J${PROJECT_BINARY_DIR}")
|
add_definitions("-J${PROJECT_BINARY_DIR}")
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME}
|
add_executable(${PROJECT_NAME}
|
||||||
../lib/reference_tiger/sboxes.c
|
${TIGER_SRC_FILES}
|
||||||
../lib/reference_tiger/tiger.c
|
|
||||||
main.d
|
main.d
|
||||||
tiger.d
|
tiger.d
|
||||||
sums.d
|
sums.d
|
||||||
|
|
|
@ -83,18 +83,19 @@ int main (string[] parArgs) {
|
||||||
writeln(" -v, --version display version informations and exit");
|
writeln(" -v, --version display version informations and exit");
|
||||||
writefln(" --license display details about the license under which %s is distributed", PROGRAM_NAME);
|
writefln(" --license display details about the license under which %s is distributed", PROGRAM_NAME);
|
||||||
writeln();
|
writeln();
|
||||||
writeln("The sums are computed using the reference implementation algorithm. When checking, the input");
|
writefln("The sums are computed using the %s backend. When checking, the input", BACKEND_NAME);
|
||||||
writeln("should be a former output of this program. The default mode is to print");
|
writeln("should be a former output of this program. The default mode is to print");
|
||||||
writeln("a line with checksum, a character indicating type(`*' for binary, ` ' for");
|
writeln("a line with checksum, a character indicating type(`*' for binary, ` ' for");
|
||||||
writeln("text), and name for each FILE.");
|
writeln("text), and name for each FILE.");
|
||||||
writeln();
|
writeln();
|
||||||
writeln("Report bugs on <https://bitbucket.org/King_DuckZ/tigersum/issues?status=new&status=open>");
|
writeln("Report bugs on <https://bitbucket.org/King_DuckZ/tigersum/issues?status=new&status=open>");
|
||||||
writeln("tigersum home page: <https://bitbucket.org/King_DuckZ/tigersum>");
|
writeln("tigersum home page: <https://bitbucket.org/King_DuckZ/tigersum>");
|
||||||
|
writefln("%s home page: <%s>", BACKEND_NAME, BACKEND_WEBSITE);
|
||||||
}
|
}
|
||||||
else if (show_version) {
|
else if (show_version) {
|
||||||
writefln("%s %d.%d Copyright © %d Michele \"King_DuckZ\" Santullo", PROGRAM_NAME, TIGERSUM_VERSION_MAJOR, TIGERSUM_VERSION_MINOR, COPYRIGHT_YEAR);
|
writefln("%s %d.%d Copyright © %d Michele \"King_DuckZ\" Santullo", PROGRAM_NAME, TIGERSUM_VERSION_MAJOR, TIGERSUM_VERSION_MINOR, COPYRIGHT_YEAR);
|
||||||
writeln("Using the reference tiger implementation by Ross Anderson and Eli Biham");
|
writefln("Using the %s implementation by %s", BACKEND_NAME, BACKEND_AUTHOR);
|
||||||
writeln("http://www.cs.technion.ac.il/~biham/Reports/Tiger/");
|
writeln(BACKEND_WEBSITE);
|
||||||
writeln();
|
writeln();
|
||||||
writeln("This program comes with ABSOLUTELY NO WARRANTY.");
|
writeln("This program comes with ABSOLUTELY NO WARRANTY.");
|
||||||
writeln("This is free software, and you are welcome to redistribute it");
|
writeln("This is free software, and you are welcome to redistribute it");
|
||||||
|
|
|
@ -3,3 +3,6 @@ const ushort TIGERSUM_VERSION_MAJOR = @TIGERSUM_MAJOR@;
|
||||||
const ushort TIGERSUM_VERSION_MINOR = @TIGERSUM_MINOR@;
|
const ushort TIGERSUM_VERSION_MINOR = @TIGERSUM_MINOR@;
|
||||||
const ushort COPYRIGHT_YEAR = 2014;
|
const ushort COPYRIGHT_YEAR = 2014;
|
||||||
const string PROGRAM_NAME = "@PROJECT_NAME@";
|
const string PROGRAM_NAME = "@PROJECT_NAME@";
|
||||||
|
const string BACKEND_WEBSITE = "@BACKEND_WEBSITE@";
|
||||||
|
const string BACKEND_NAME = "@BACKEND_NAME@";
|
||||||
|
const string BACKEND_AUTHOR = "@BACKEND_AUTHOR@";
|
||||||
|
|
Loading…
Reference in a new issue