├── lib ├── src │ ├── hashalgorithm.cpp │ ├── qcryptohash.cpp │ ├── rmd160.cpp │ ├── tiger.cpp │ └── whirlpool.cpp ├── include │ ├── hashalgorithm.hpp │ ├── bithelp.h │ ├── rmd160.hpp │ ├── whirlpool.hpp │ ├── tiger.hpp │ ├── err.h │ └── qcryptohash.hpp └── lib.pro ├── QtCryptoHash.pro ├── common.pri ├── test ├── test.pro └── tst_qcryptohash.cpp ├── .gitignore ├── README.md ├── doc └── QCryptoHash.md ├── appveyor.yml └── LICENSE /lib/src/hashalgorithm.cpp: -------------------------------------------------------------------------------- 1 | #include "hashalgorithm.hpp" 2 | 3 | HashAlgorithm::~HashAlgorithm() {} 4 | -------------------------------------------------------------------------------- /QtCryptoHash.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | CONFIG += ordered 3 | 4 | SUBDIRS = lib \ 5 | test 6 | test.depends = lib 7 | -------------------------------------------------------------------------------- /common.pri: -------------------------------------------------------------------------------- 1 | # Uncomment the following line to compile QtCrypotHash as static library! 2 | # CONFIG += static 3 | 4 | contains(QT_ARCH, i386) { 5 | PLATFORM = x86 6 | } else { 7 | PLATFORM = x64 8 | ARCH_SUFFIX = 64 9 | } 10 | 11 | CONFIG(debug, debug|release) { 12 | BUILD = debug 13 | } else { 14 | BUILD = release 15 | } 16 | 17 | static { 18 | DEFINES += QTCRYPTOHASH_STATIC 19 | DESTDIR = $$PWD/bin/$${PLATFORM}/static/$${BUILD} 20 | } else { 21 | DESTDIR = $$PWD/bin/$${PLATFORM}/dynamic/$${BUILD} 22 | } 23 | -------------------------------------------------------------------------------- /test/test.pro: -------------------------------------------------------------------------------- 1 | include(../common.pri) 2 | 3 | QT += testlib 4 | QT -= gui 5 | 6 | TARGET = tst_qcryptohash$${ARCH_SUFFIX} 7 | 8 | CONFIG += testcase 9 | CONFIG += console 10 | CONFIG -= app_bundle 11 | 12 | TEMPLATE = app 13 | 14 | SOURCES += \ 15 | tst_qcryptohash.cpp 16 | 17 | ########################### CONFIGURATION ############################ 18 | CONFIG += c++14 19 | 20 | LIBS += -L$${DESTDIR} -lQtCryptoHash$${ARCH_SUFFIX} 21 | 22 | INCLUDEPATH += $$PWD/../lib/include 23 | DEPENDPATH += $$PWD/../lib/include 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | *.debug 25 | Makefile* 26 | *.prl 27 | *.app 28 | moc_*.cpp 29 | ui_*.h 30 | qrc_*.cpp 31 | Thumbs.db 32 | *.res 33 | *.rc 34 | *.cppcheck 35 | *.exp 36 | /.qmake.cache 37 | /.qmake.stash 38 | /bin/* 39 | /build/* 40 | 41 | # qtcreator generated files 42 | *.pro.user* 43 | 44 | # xemacs temporary files 45 | *.flc 46 | 47 | # Vim temporary files 48 | .*.swp 49 | 50 | # Visual Studio generated files 51 | *.ib_pdb_index 52 | *.idb 53 | *.ilk 54 | *.pdb 55 | *.sln 56 | *.suo 57 | *.vcproj 58 | *vcproj.*.*.user 59 | *.ncb 60 | *.sdf 61 | *.opensdf 62 | *.vcxproj 63 | *vcxproj.* 64 | 65 | # MinGW generated files 66 | *.Debug 67 | *.Release 68 | 69 | # Python byte code 70 | *.pyc 71 | 72 | # Binaries 73 | # -------- 74 | *.dll 75 | *.exe 76 | *.7z 77 | .idea/ 78 | doc/Doxyfile 79 | doc/xml/ 80 | test2/ 81 | -------------------------------------------------------------------------------- /lib/include/hashalgorithm.hpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * Copyright (C) 2015 by Riccardo Ostani * 4 | * email: rik20@live.it * 5 | * * 6 | * This program is free software; you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License version 2 * 8 | * as published by the Free Software Foundation. * 9 | * * 10 | ***************************************************************************/ 11 | 12 | #ifndef HASHALGORITHM_HPP 13 | #define HASHALGORITHM_HPP 14 | 15 | #if __cplusplus < 201103L 16 | #include 17 | #else 18 | #include 19 | #endif 20 | 21 | typedef uint8_t byte; 22 | 23 | class HashAlgorithm { 24 | public: 25 | virtual ~HashAlgorithm(); 26 | 27 | virtual void init() = 0; 28 | virtual void write( const byte* inbuf, int inlen ) = 0; 29 | virtual byte* final() = 0; 30 | virtual int hash_length() const = 0; 31 | }; 32 | 33 | #endif // HASHALGORITHM_HPP 34 | -------------------------------------------------------------------------------- /lib/lib.pro: -------------------------------------------------------------------------------- 1 | include(../common.pri) 2 | 3 | TARGET = QtCryptoHash$${ARCH_SUFFIX} 4 | 5 | QT -= gui 6 | 7 | TEMPLATE = lib 8 | 9 | INCLUDEPATH += ./include/ \ 10 | ./3rdparty/include 11 | 12 | SOURCES += \ 13 | src/rmd160.cpp \ 14 | src/tiger.cpp \ 15 | src/whirlpool.cpp \ 16 | src/qcryptohash.cpp \ 17 | src/hashalgorithm.cpp 18 | 19 | HEADERS += \ 20 | include/rmd160.hpp \ 21 | include/tiger.hpp \ 22 | include/whirlpool.hpp \ 23 | include/hashalgorithm.hpp \ 24 | include/qcryptohash.hpp 25 | 26 | ########################### CONFIGURATION ############################ 27 | !static { 28 | DEFINES += QTCRYPTOHASH_EXPORT 29 | } 30 | 31 | VER_MAJ = 0 32 | VER_MIN = 1 33 | VER_PAT = 2 34 | VERSION = $${VER_MAJ}.$${VER_MIN}.$${VER_PAT} 35 | 36 | ######################## OS DEPENDENT OPTIONS ######################## 37 | win32 { 38 | CONFIG += skip_target_version_ext # no version in lib file 39 | 40 | !static : !staticlib { 41 | CONFIG += dll 42 | TARGET_EXT = .dll 43 | 44 | # CONTENT OF THE RC FILE # 45 | QMAKE_TARGET_PRODUCT = QtCryptoHash 46 | QMAKE_TARGET_COMPANY = rikyoz 47 | QMAKE_TARGET_COPYRIGHT = Copyright (c) 2016 $${QMAKE_TARGET_COMPANY} 48 | } 49 | 50 | !win32-g++ { 51 | contains(QT_ARCH, i386) { 52 | QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS,5.01 53 | } else { 54 | QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS,5.02 55 | } 56 | } 57 | } 58 | 59 | unix { 60 | target.path = /usr/lib 61 | INSTALLS += target 62 | } 63 | -------------------------------------------------------------------------------- /lib/include/bithelp.h: -------------------------------------------------------------------------------- 1 | /* bithelp.h - Some bit manipulation helpers 2 | * Copyright (C) 1999, 2002 Free Software Foundation, Inc. 3 | * 4 | * This file is part of Libgcrypt. 5 | * 6 | * Libgcrypt is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser general Public License as 8 | * published by the Free Software Foundation; either version 2.1 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Libgcrypt is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | #ifndef G10_BITHELP_H 21 | #define G10_BITHELP_H 22 | 23 | #if __cplusplus < 201103L 24 | #include 25 | #else 26 | #include 27 | #endif 28 | 29 | /**************** 30 | * Rotate the 32 bit unsigned integer X by N bits left/right 31 | */ 32 | #if defined(__GNUC__) && defined(__i386__) 33 | static inline uint32_t 34 | rol(uint32_t x, int n) 35 | { 36 | __asm__("roll %%cl,%0" 37 | :"=r" (x) 38 | :"0" (x),"c" (n)); 39 | return x; 40 | } 41 | #else 42 | #define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) ) 43 | #endif 44 | 45 | #if defined(__GNUC__) && defined(__i386__) 46 | static inline uint32_t 47 | ror(uint32_t x, int n) 48 | { 49 | __asm__("rorl %%cl,%0" 50 | :"=r" (x) 51 | :"0" (x),"c" (n)); 52 | return x; 53 | } 54 | #else 55 | #define ror(x,n) ( ((x) >> (n)) | ((x) << (32-(n))) ) 56 | #endif 57 | 58 | 59 | #endif /*G10_BITHELP_H*/ 60 | -------------------------------------------------------------------------------- /lib/include/rmd160.hpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * Copyright (C) 2015 by Riccardo Ostani * 4 | * email: rik20@live.it * 5 | * * 6 | * copyright (C) 2004 by Michael Buesch * 7 | * email: mbuesch@freenet.de * 8 | * * 9 | * This program is free software; you can redistribute it and/or modify * 10 | * it under the terms of the GNU General Public License version 2 * 11 | * as published by the Free Software Foundation. * 12 | * * 13 | ***************************************************************************/ 14 | 15 | #ifndef RMD160_HPP 16 | #define RMD160_HPP 17 | 18 | #include "hashalgorithm.hpp" 19 | 20 | #include 21 | 22 | #define RMD160_HASHLEN_BYTE (160 / 8) 23 | 24 | class Rmd160 : public HashAlgorithm { 25 | struct RMD160_CONTEXT { 26 | uint32_t h0, h1, h2, h3, h4; 27 | uint32_t nblocks; 28 | byte buf[64]; 29 | int count; 30 | }; 31 | 32 | public: 33 | Rmd160(); 34 | virtual ~Rmd160(); 35 | 36 | void init() Q_DECL_OVERRIDE; 37 | void write( const byte* inbuf, int inlen ) Q_DECL_OVERRIDE; 38 | byte* final() Q_DECL_OVERRIDE; 39 | 40 | int hash_length() const Q_DECL_OVERRIDE { return RMD160_HASHLEN_BYTE; } 41 | 42 | protected: 43 | RMD160_CONTEXT* context; 44 | 45 | private: 46 | void burn_stack( int bytes ); 47 | void transform( const byte* data ); 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /lib/include/whirlpool.hpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * Copyright (C) 2015 by Riccardo Ostani * 4 | * email: rik20@live.it * 5 | * * 6 | * This program is free software; you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License version 2 * 8 | * as published by the Free Software Foundation. * 9 | * * 10 | ***************************************************************************/ 11 | 12 | #ifndef WHIRLPOOL_HPP 13 | #define WHIRLPOOL_HPP 14 | 15 | #include "hashalgorithm.hpp" 16 | 17 | #include 18 | 19 | #define WHIRLPOOL_DIGEST_SIZE 64 20 | #define WHIRLPOOL_DIGEST_BITSIZE ( 8 * WHIRLPOOL_DIGEST_SIZE ) /* 512 */ 21 | 22 | #define WHIRLPOOL_BLOCK_SIZE 64 23 | #define WHIRLPOOL_BLOCK_BITSIZE ( 8 * WHIRLPOOL_BLOCK_SIZE ) /* 512 */ 24 | 25 | #define WHIRLPOOL_SIZE 32 26 | #define WHIRLPOOL_BITSIZE ( 8 * WHIRLPOOL_SIZE ) /* 256 */ 27 | 28 | class Whirlpool : public HashAlgorithm { 29 | typedef struct whirlpool_ctx { 30 | uint8_t bitLength[ WHIRLPOOL_SIZE ]; /* global number of hashed bits (256-bit counter) */ 31 | uint8_t buffer[ WHIRLPOOL_BLOCK_SIZE ]; /* buffer of data to hash */ 32 | int bufferBits; /* current number of bits on the buffer */ 33 | int bufferPos; /* current (possibly incomplete) byte slot on the buffer */ 34 | uint64_t hash[ WHIRLPOOL_DIGEST_SIZE / 8 ]; /* the hashing state */ 35 | } WHIRLPOOL_CONTEXT; 36 | 37 | public: 38 | Whirlpool(); 39 | virtual ~Whirlpool(); 40 | 41 | void init() Q_DECL_OVERRIDE; 42 | void write( const byte* data, int length ) Q_DECL_OVERRIDE; 43 | byte* final() Q_DECL_OVERRIDE; 44 | 45 | int hash_length() const Q_DECL_OVERRIDE { return WHIRLPOOL_DIGEST_SIZE; } 46 | 47 | protected: 48 | WHIRLPOOL_CONTEXT* context; 49 | 50 | private: 51 | void processBuffer(); 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /lib/include/tiger.hpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * Copyright (C) 2015 by Riccardo Ostani * 4 | * email: rik20@live.it * 5 | * * 6 | * copyright (C) 2002, 2003, 2004 by Michael Buesch * 7 | * email: mbuesch@freenet.de * 8 | * * 9 | * tiger.c - The TIGER hash function * 10 | * Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc. * 11 | * * 12 | * This program is free software; you can redistribute it and/or modify * 13 | * it under the terms of the GNU General Public License version 2 * 14 | * as published by the Free Software Foundation. * 15 | * * 16 | ***************************************************************************/ 17 | 18 | #ifndef TIGER_HPP 19 | #define TIGER_HPP 20 | 21 | #include "hashalgorithm.hpp" 22 | 23 | #include 24 | 25 | #define TIGER_HASHLEN_BYTE (192 / 8) 26 | 27 | class Tiger : public HashAlgorithm { 28 | struct TIGER_CONTEXT { 29 | uint64_t a, b, c; 30 | byte buf[64]; 31 | int count; 32 | uint32_t nblocks; 33 | }; 34 | 35 | public: 36 | Tiger(); 37 | virtual ~Tiger(); 38 | 39 | void init() Q_DECL_OVERRIDE; 40 | void write( const byte* inbuf, int inlen ) Q_DECL_OVERRIDE; 41 | byte* final() Q_DECL_OVERRIDE; 42 | 43 | int hash_length() const Q_DECL_OVERRIDE { return TIGER_HASHLEN_BYTE; } 44 | 45 | protected: 46 | TIGER_CONTEXT* context; 47 | 48 | private: 49 | Q_DISABLE_COPY( Tiger ) 50 | 51 | void burn_stack( int bytes ); 52 | void round( uint64_t* ra, uint64_t* rb, uint64_t* rc, uint64_t x, int mul ); 53 | void pass( uint64_t* ra, uint64_t* rb, uint64_t* rc, uint64_t* x, int mul ); 54 | void key_schedule( uint64_t* x ); 55 | void transform( const byte* data ); 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /lib/include/err.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * copyright (C) 2003, 2004 by Michael Buesch * 4 | * email: mbuesch@freenet.de * 5 | * * 6 | * This program is free software; you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License version 2 * 8 | * as published by the Free Software Foundation. * 9 | * * 10 | ***************************************************************************/ 11 | 12 | #ifndef ERR_H 13 | #define ERR_H 14 | 15 | #include "globalstuff.hpp" 16 | 17 | #include 18 | #include 19 | 20 | using std::string; 21 | using std::cerr; 22 | using std::cout; 23 | using std::endl; 24 | 25 | 26 | /** Assertion function */ 27 | #ifdef CALCCHECKSUM_DEBUG 28 | # define CALCCHECKSUM_ASSERT(x) do { \ 29 | if (!(x)) { \ 30 | cerr << "CALCCHECKSUM_ASSERT failed: " << #x \ 31 | << " in " << __FILE__ \ 32 | << ":" << __LINE__ \ 33 | << endl; \ 34 | } \ 35 | } while (0) 36 | #else 37 | # define CALCCHECKSUM_ASSERT(x) do {} while (0) 38 | #endif 39 | 40 | #define BUG() do { \ 41 | cerr << "CalcChecksum BUG at " \ 42 | << __FILE__ << ":" << __LINE__ \ 43 | << endl; \ 44 | } while (0) 45 | 46 | #define TODO() do { \ 47 | cerr << "CalcChecksum TODO at " \ 48 | << __FILE__ << ":" << __LINE__ \ 49 | << endl; \ 50 | } while (0) 51 | 52 | #define FIXME() do { \ 53 | cerr << "CalcChecksum FIXME at " \ 54 | << __FILE__ << ":" << __LINE__ \ 55 | << endl; \ 56 | } while (0) 57 | 58 | #ifdef CALCCHECKSUM_DEBUG 59 | inline 60 | void printDebug(string msg) 61 | { 62 | cout << "CalcChecksum DEBUG: " << msg << endl; 63 | } 64 | #else 65 | # define printDebug(x) do {} while (0) 66 | #endif 67 | 68 | inline 69 | void printInfo(string msg) 70 | { 71 | cout << "CalcChecksum INFO: " << msg << endl; 72 | } 73 | 74 | inline 75 | void printWarn(string msg) 76 | { 77 | cerr << "CalcChecksum WARNING: " << msg << endl; 78 | } 79 | 80 | inline 81 | void printError(string msg) 82 | { 83 | msg = "CalcChecksum generated a fatal fault:\n" + msg; 84 | cerr << "\n\n" << msg << endl; 85 | } 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /lib/src/qcryptohash.cpp: -------------------------------------------------------------------------------- 1 | /* QCryptoHash.cpp - The QCryptoHash class 2 | * Copyright (C) 2015 Riccardo Ostani 3 | * 4 | * This file is part of QtCryptoHash library. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "qcryptohash.hpp" 22 | 23 | #include "tiger.hpp" 24 | #include "rmd160.hpp" 25 | #include "whirlpool.hpp" 26 | 27 | #include 28 | 29 | QCryptoHash::QCryptoHash( Algorithm method ) { 30 | switch ( method ) { 31 | case QCryptoHash::TIGER: 32 | hash_algorithm = new Tiger(); 33 | break; 34 | case QCryptoHash::RMD160: 35 | hash_algorithm = new Rmd160(); 36 | break; 37 | case QCryptoHash::WHIRLPOOL: 38 | hash_algorithm = new Whirlpool(); 39 | break; 40 | } 41 | reset(); 42 | } 43 | 44 | QCryptoHash::~QCryptoHash() { 45 | if ( hash_algorithm ) { 46 | delete hash_algorithm; 47 | hash_algorithm = NULL; 48 | } 49 | } 50 | 51 | void QCryptoHash::reset() { 52 | hash_algorithm->init(); 53 | } 54 | 55 | void QCryptoHash::addData( const char* data, int length ) { 56 | hash_algorithm->write( reinterpret_cast< const byte* >( data ), length ); 57 | } 58 | 59 | void QCryptoHash::addData( const QByteArray &data ) { 60 | addData( data.constData(), data.length() ); 61 | } 62 | 63 | bool QCryptoHash::addData( QIODevice* device ) { 64 | if ( !device->isReadable() || !device->isOpen() ) { 65 | return false; 66 | } 67 | 68 | char buffer[1024]; 69 | int length; 70 | 71 | while ( ( length = device->read( buffer, sizeof( buffer ) ) ) > 0 ) { 72 | addData( buffer, length ); 73 | } 74 | 75 | return device->atEnd(); 76 | } 77 | 78 | QByteArray QCryptoHash::result() const { 79 | byte* hash_array = hash_algorithm->final(); 80 | return QByteArray( reinterpret_cast< char* >( hash_array ), hash_algorithm->hash_length() ); 81 | } 82 | 83 | QByteArray QCryptoHash::hash( const QByteArray &data, QCryptoHash::Algorithm method ) { 84 | QCryptoHash hash( method ); 85 | hash.addData( data ); 86 | return hash.result(); 87 | } 88 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QtCryptoHash [![Build Status](https://ci.appveyor.com/api/projects/status/bg4it7o8d5chbfvm?svg=true&passingText=build%20OK&pendingText=building...&failingText=build%20failed)](https://ci.appveyor.com/project/rikyoz/qtcryptohash) 2 | 3 | **QtCryptoHash** is a Qt C++ library providing a way to calculate some of the cryptographic hashes not supported by the *QCryptographicHash* class from the Qt library. 4 | 5 | [![](http://img.shields.io/badge/version-v0.1.2-blue.png?style=flat)](https://github.com/rikyoz/qtcryptohash/releases/latest) 6 | ![](http://img.shields.io/badge/compiler-MSVC%20|%20MinGW%20|%20GCC%20|%20Clang-red.png?style=flat) 7 | ![](http://img.shields.io/badge/architecture-x86%20|%20x64-yellow.png?style=flat) 8 | [![](http://img.shields.io/badge/license-GNU%20GPL%20v2-lightgrey.png?style=flat)](/LICENSE) 9 | 10 | ## Features 11 | + Supports **Tiger-192**, **RipeMD-160** and **Whirlpool** algorithms 12 | + Simple interface, identical to the QCryptographicHash class, but renamed [**QCryptoHash**](https://github.com/rikyoz/QtCryptoHash/wiki/QCryptoHash) 13 | + Works with **Qt 5.x** 14 | + Supports **MSVC**, **MinGW**, **GCC** and **Clang** 15 | 16 | ## Basic Usage 17 | 18 | ### String Hash Calculation 19 | ```cpp 20 | #include "qcryptohash.hpp" 21 | ... 22 | QByteArray stringHash = QCryptoHash::hash( "abc", QCryptoHash::TIGER ); 23 | qInfo() << stringHash.toHex(); //f258c1e88414ab2a527ab541ffc5b8bf935f7b951c132951 24 | ``` 25 | 26 | ### File Hash Calculation 27 | ```cpp 28 | #include "qcryptohash.hpp" 29 | ... 30 | QFile file( filename ); 31 | if ( file.open( QFile::ReadOnly ) ) { 32 | QCryptoHash ripemdHash( QCryptoHash::RMD160 ); 33 | while( !file.atEnd() ){ 34 | ripemdHash.addData( file.read( 8192 ) ); 35 | } 36 | QByteArray fileHash = ripemdHash.result(); 37 | qInfo() << fileHash.toHex(); //RipeMD hash of 'filename' file content 38 | } 39 | ``` 40 | 41 | For a complete description of the QCryptoHash API, see the relative [wiki](https://github.com/rikyoz/QtCryptoHash/wiki/QCryptoHash). 42 | 43 | ## Dependencies 44 | QtCryptoHash needs only **QtCore** library to be linked to the program. 45 | 46 | ## Building 47 | A complete guide to build this library is available [here](https://github.com/rikyoz/QtCryptoHash/wiki/Building). 48 | 49 | ## License (GPL v2) 50 | This program is free software; you can redistribute it and/or modify 51 | it under the terms of the GNU General Public License as published by 52 | the Free Software Foundation; either version 2 of the License, or 53 | (at your option) any later version. 54 | 55 | This program is distributed in the hope that it will be useful, 56 | but WITHOUT ANY WARRANTY; without even the implied warranty of 57 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 58 | GNU General Public License for more details. 59 | 60 | You should have received a copy of the GNU General Public License along 61 | with this program; if not, write to the Free Software Foundation, Inc., 62 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------------- /doc/QCryptoHash.md: -------------------------------------------------------------------------------- 1 | The **QCryptoHash** class provides a way to generate cryptographic hashes. 2 | It can be used to generate cryptographic hashes of binary or text data. 3 | 4 | Currently **Tiger-192**, **RipeMD-160** and **Whirlpool** are supported. 5 | 6 | ~~~~{.cpp} 7 | #include "qcryptohash.hpp" 8 | ~~~~ 9 | 10 | ## List of all members 11 | 12 | ### Public Types 13 | | Type | Name | 14 | |-----:|------| 15 | | enum | [Algorithm](#enum-algorithm) { TIGER, RMD160, WHIRLPOOL } | 16 | 17 | ### Public Members 18 | | Return type | Name | 19 | |------------:|----------| 20 | | | [QCryptoHash](#qcryptohashqcryptohash-algorithm-method-)( Algorithm method ) | 21 | | | [~QCryptoHash](#qcryptohashqcryptohash)() | 22 | | void | [reset](#void-qcryptohashreset)() | 23 | | void | [addData](#void-qcryptohashadddata-const-char-data-int-length-)( const char *data, int length ) | 24 | | void | [addData](#void-qcryptohashadddata-const-qbytearray-data-)( const QByteArray &data ) | 25 | | bool | [addData](#bool-qcryptohashadddata-qiodevice-device-)( QIODevice *device ) | 26 | | QByteArray | [result](#qbytearray-qcryptohashresult-const)() const | 27 | 28 | ### Static Public Members 29 | | Return type | Name | 30 | |------------:|----------| 31 | | QByteArray | [hash](#static-qbytearray-qcryptohashhash-const-qbytearray-data-algorithm-method-)( const QByteArray &data, Algorithm method ) | 32 | 33 | 34 | ## Member Type Documentation 35 | 36 | #### enum Algorithm 37 | 38 | The Algorithm enum specifies the hashing algorithms supported by QCryptoHash. 39 | 40 | | Constant | Value | Description | 41 | |----------|-------|-------------| 42 | | QCryptoHash::TIGER | 0 | Generate a Tiger-192 hash sum. | 43 | | QCryptoHash::RMD160 | 1 | Generate a RipeMD-160 hash sum. | 44 | | QCryptoHash::WHIRLPOOL | 2 | Generate a Whirlpool hash sum. | 45 | 46 |
47 | 48 | ## Member Function Documentation 49 | 50 | #### [QCryptoHash](./QCryptoHash)::[QCryptoHash](./QCryptoHash)( [Algorithm](./QCryptoHash) method ) 51 | Constructs an object that can be used to create a cryptographic hash from data using *method*. 52 | 53 |
54 | #### [QCryptoHash](./QCryptoHash)::~[QCryptoHash](./QCryptoHash)() 55 | Destroys the object. 56 | 57 |
58 | #### void [QCryptoHash](./QCryptoHash)::reset() 59 | Resets the object. 60 | 61 |
62 | #### void [QCryptoHash](./QCryptoHash)::addData( const char *data, int length ) 63 | Adds the first *length* chars of *data* to the cryptographic hash. 64 | 65 |
66 | #### void [QCryptoHash](./QCryptoHash)::addData( const QByteArray &data ) 67 | Adds the bytes of *data* to the cryptographic hash. 68 | 69 |
70 | #### bool [QCryptoHash](./QCryptoHash)::addData( QIODevice *device ) 71 | Reads the data from the open QIODevice *device* until it ends and hashes it. 72 | 73 | Returns true if reading was successful. 74 | 75 |
76 | #### QByteArray [QCryptoHash](./QCryptoHash)::result() const 77 | Returns the final hash value. 78 | 79 |
80 | #### [static] QByteArray [QCryptoHash](./QCryptoHash)::hash( const QByteArray &data, [Algorithm](./QCryptoHash) method ) 81 | Returns the hash of *data* using *method*. 82 | 83 |
84 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 0.1.2-build{build} 2 | skip_non_tags: true 3 | os: Windows Server 2012 R2 4 | shallow_clone: true 5 | 6 | branches: 7 | only: 8 | - master 9 | - /v\d\.\d\.\d/ 10 | 11 | configuration: Release 12 | 13 | environment: 14 | qtcryptohash_version: 0.1.2 15 | qt_version: 5.6 16 | msvc_dir: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC 17 | mingw_dir: C:\Qt\Tools\mingw492_32\bin 18 | 19 | matrix: 20 | #MSVC x86 21 | - name: msvc2015-win32 22 | arch: x86 23 | compiler: msvc 24 | type: dynamic 25 | qt_dir: C:\Qt\%qt_version%\msvc2015\bin 26 | 27 | #MSVC x86 STATIC 28 | - name: msvc2015-win32-static 29 | arch: x86 30 | compiler: msvc 31 | type: static 32 | qt_dir: C:\Qt\%qt_version%\msvc2015\bin 33 | 34 | #MSVC x64 35 | - name: msvc2015-win64 36 | arch: x64 37 | compiler: msvc 38 | type: dynamic 39 | qt_dir: C:\Qt\%qt_version%\msvc2015_64\bin 40 | 41 | #MSVC x64 STATIC 42 | - name: msvc2015-win64-static 43 | arch: x64 44 | compiler: msvc 45 | type: static 46 | qt_dir: C:\Qt\%qt_version%\msvc2015_64\bin 47 | 48 | #MinGW x86 49 | - name: mingw49-win32 50 | arch: x86 51 | compiler: mingw 52 | type: dynamic 53 | qt_dir: C:\Qt\%qt_version%\mingw49_32\bin 54 | 55 | #MinGW x86 STATIC 56 | - name: mingw49-win32-static 57 | arch: x86 58 | compiler: mingw 59 | type: static 60 | qt_dir: C:\Qt\%qt_version%\mingw49_32\bin 61 | 62 | init: 63 | - set PATH=%PATH%;%msvc_dir%;%mingw_dir%;%qt_dir% 64 | - if [%compiler%]==[msvc] 65 | call vcvarsall.bat %arch% 66 | 67 | build_script: 68 | - mkdir build 69 | - cd build 70 | - if [%type%]==[static] ( 71 | qmake ..\QtCryptoHash.pro "CONFIG += static" 72 | ) else ( 73 | qmake ..\QtCryptoHash.pro 74 | ) 75 | - if [%compiler%]==[msvc] ( 76 | nmake debug & nmake release 77 | ) else ( 78 | mingw32-make debug & mingw32-make release 79 | ) 80 | - cd .. 81 | - mkdir pkg 82 | - cd pkg 83 | - mkdir bin\%arch%\debug\ 84 | - mkdir bin\%arch%\release\ 85 | - if [%compiler%]==[msvc] ( 86 | copy /y ..\bin\%arch%\%type%\debug\*.lib bin\%arch%\debug\ & 87 | copy /y ..\bin\%arch%\%type%\release\*.lib bin\%arch%\release\ 88 | ) else ( 89 | copy /y ..\bin\%arch%\%type%\debug\*.a bin\%arch%\debug\ & 90 | copy /y ..\bin\%arch%\%type%\release\*.a bin\%arch%\release\ 91 | ) 92 | - if [%type%]==[dynamic] ( 93 | copy /y ..\bin\%arch%\%type%\debug\*.dll bin\%arch%\debug\ & 94 | copy /y ..\bin\%arch%\%type%\release\*.dll bin\%arch%\release\ 95 | ) 96 | - copy /y ..\lib\include\qcryptohash.hpp qcryptohash.hpp 97 | - 7z a -t7z QtCryptoHash-v%qtcryptohash_version%-%name%.7z * 98 | 99 | artifacts: 100 | - path: pkg\**\*.7z 101 | name: binary 102 | 103 | test: off 104 | 105 | deploy: 106 | provider: GitHub 107 | release: $(APPVEYOR_REPO_TAG_NAME) 108 | description: 'Binaries of QtCryptoHash $(APPVEYOR_REPO_TAG_NAME)' 109 | auth_token: 110 | secure: 4V5xJQT+iVPUhK05TBLkNkLY8HTArZ+omH394hfXqQuxfrkaQqnR8132rDnB/HVm 111 | artifact: /.*\.7z/ 112 | draft: true 113 | prerelease: false 114 | on: 115 | # branch: master 116 | appveyor_repo_tag: true -------------------------------------------------------------------------------- /lib/include/qcryptohash.hpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * Copyright (C) 2015 by Riccardo Ostani * 4 | * email: rik20@live.it * 5 | * * 6 | * This program is free software; you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License version 2 * 8 | * as published by the Free Software Foundation. * 9 | * * 10 | ***************************************************************************/ 11 | 12 | #ifndef QCRYPTOHASH_HPP 13 | #define QCRYPTOHASH_HPP 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #ifdef QTCRYPTOHASH_STATIC 20 | #define LIBSHARED_EXPORT 21 | #elif defined(QTCRYPTOHASH_EXPORT) 22 | #define LIBSHARED_EXPORT Q_DECL_EXPORT 23 | #else 24 | #define LIBSHARED_EXPORT Q_DECL_IMPORT 25 | #endif 26 | 27 | class HashAlgorithm; 28 | 29 | /** 30 | * @brief The **QCryptoHash** class provides a way to generate cryptographic hashes. 31 | * 32 | * It can be used to generate cryptographic hashes of binary or text data.
33 | * Currently **Tiger-192**, **RipeMD-160** and **Whirlpool** are supported. 34 | */ 35 | class LIBSHARED_EXPORT QCryptoHash { 36 | public: 37 | /** 38 | * @brief The Algorithm enum specifies the hashing algorithms supported by QCryptoHash 39 | */ 40 | enum Algorithm { TIGER, ///< Generate a Tiger-192 hash sum 41 | RMD160, ///< Generate a RipeMD-160 hash sum 42 | WHIRLPOOL ///< Generate a Whirlpool hash sum 43 | }; 44 | 45 | /** 46 | * @brief Constructs an object that can be used to create a cryptographic hash from data using @a method. 47 | * @param method The method/algorithm used to create the hash 48 | */ 49 | explicit QCryptoHash( Algorithm method ); 50 | 51 | /** 52 | * @brief Destroys the object. 53 | */ 54 | ~QCryptoHash(); 55 | 56 | /** 57 | * @brief Resets the object. 58 | */ 59 | void reset(); 60 | 61 | /** 62 | * @brief Adds the first @a length chars of @a data to the cryptographic hash. 63 | * @param data an array of chars to be added to the hash 64 | * @param length The number of chars to be added 65 | */ 66 | void addData( const char* data, int length ); 67 | 68 | /** 69 | * @brief Adds the bytes of @a data to the cryptographic hash 70 | * @param data a byte array to be added to the hash 71 | */ 72 | void addData( const QByteArray &data ); 73 | 74 | /** 75 | * @brief Reads the data from the open QIODevice @a device until it ends and hashes it. 76 | * @param device QIODevice to be read 77 | * @return true if reading was successful. 78 | */ 79 | bool addData( QIODevice* device ); 80 | 81 | /** 82 | * @return the final hash value. 83 | */ 84 | QByteArray result() const; 85 | 86 | /** 87 | * @param data the byte array to be hashed 88 | * @param method the algorithm/method to be used to hash the data 89 | * @return the hash of @a data using @a method. 90 | */ 91 | static QByteArray hash( const QByteArray &data, Algorithm method ); 92 | 93 | private: 94 | Q_DISABLE_COPY( QCryptoHash ) 95 | 96 | HashAlgorithm* hash_algorithm; 97 | }; 98 | 99 | #endif // QCRYPTOHASH_HPP 100 | -------------------------------------------------------------------------------- /test/tst_qcryptohash.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "qcryptohash.hpp" 7 | 8 | static const QMap tigerTests = { 9 | {"", "24f0130c63ac933216166e76b1bb925ff373de2d49584e7a"}, 10 | {"abc", "f258c1e88414ab2a527ab541ffc5b8bf935f7b951c132951"}, 11 | {"Tiger", "9f00f599072300dd276abb38c8eb6dec37790c116f9d2bdf"}, 12 | { 13 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgh" 14 | "ijklmnopqrstuvwxyz0123456789+-", "87fb2a9083851cf7470d2cf810e6df9eb586445034a5a386" 15 | }, 16 | { 17 | "Tiger - A Fast New Hash Function, " 18 | "by Ross Anderson and Eli Biham, proc" 19 | "eedings of Fast Software Encryption " 20 | "3, Cambridge, 1996.", "3d9aeb03d1bd1a6357b2774dfd6d5b24dd68151d503974fc" 21 | } 22 | }; 23 | 24 | static const QMap ripemdTests = { 25 | {"", "9c1185a5c5e9fc54612808977ee8f548b2258d31"}, 26 | {"a", "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe"}, 27 | {"abc", "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"}, 28 | {"message digest", "5d0689ef49d2fae572b881b123a85ffa21595f36"}, 29 | {"abcdefghijklmnopqrstuvwxyz", "f71c27109c692c1b56bbdceb5b9d2865b3708dbc"}, 30 | { 31 | "abcdbcdecdefdefgefghfghi" 32 | "ghijhijkijkljklmklmnlmno" 33 | "mnopnopq", "12a053384a9c0c88e405a06c27dcf49ada62eb2b" 34 | }, 35 | { 36 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgh" 37 | "ijklmnopqrstuvwxyz0123456789", "b0e20b6e3116640286ed3a87a5713079b21f5189" 38 | }, 39 | { 40 | "123456789012345678901234567890" 41 | "123456789012345678901234567890" 42 | "12345678901234567890", "9b752e45573d4b39f4dbd3323cab82bf63326bfb" 43 | } 44 | }; 45 | 46 | static const QMap whirlpoolTests = { 47 | { 48 | "", "19fa61d75522a4669b44e39c1d2e1726c530232130d407f89afee0964997f7a73e" 49 | "83be698b288febcf88e3e03c4f0757ea8964e59b63d93708b138cc42a66eb3" 50 | }, 51 | { 52 | "a", "8aca2602792aec6f11a67206531fb7d7f0dff59413145e6973c45001d0087b42d1" 53 | "1bc645413aeff63a42391a39145a591a92200d560195e53b478584fdae231a" 54 | }, 55 | { 56 | "abc", "4e2448a4c6f486bb16b6562c73b4020bf3043e3a731bce721ae1b303d97e6d4c" 57 | "7181eebdb6c57e277d0e34957114cbd6c797fc9d95d8b582d225292076d4eef5" 58 | }, 59 | { 60 | "message digest", "378c84a4126e2dc6e56dcc7458377aac838d00032230f53ce1f5700c0ffb4d3b" 61 | "8421557659ef55c106b4b52ac5a4aaa692ed920052838f3362e86dbd37a8903e" 62 | }, 63 | { 64 | "abcdefghijklmnopqrstuvwxyz", 65 | "f1d754662636ffe92c82ebb9212a484a8d38631ead4238f5442ee13b8054e41b" 66 | "08bf2a9251c30b6a0b8aae86177ab4a6f68f673e7207865d5d9819a3dba4eb3b" 67 | }, 68 | { 69 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 70 | "dc37e008cf9ee69bf11f00ed9aba26901dd7c28cdec066cc6af42e40f82f3a1e" 71 | "08eba26629129d8fb7cb57211b9281a65517cc879d7b962142c65f5a7af01467" 72 | }, 73 | { 74 | "12345678901234567890123456789012345678901234567890123456789012345678901234567890", 75 | "466ef18babb0154d25b9d38a6414f5c08784372bccb204d6549c4afadb601429" 76 | "4d5bd8df2a6c44e538cd047b2681a51a2c60481e88c5a20b2c2a80cf3a9a083b" 77 | }, 78 | { 79 | "abcdbcdecdefdefgefghfghighijhijk", 80 | "2a987ea40f917061f5d6f0a0e4644f488a7a5a52deee656207c562f988e95c69" 81 | "16bdc8031bc5be1b7b947639fe050b56939baaa0adff9ae6745b7b181c3be3fd" 82 | }, 83 | { 84 | "The quick brown fox jumps over the lazy dog", 85 | "b97de512e91e3828b40d2b0fdce9ceb3c4a71f9bea8d88e75c4fa854df36725f" 86 | "d2b52eb6544edcacd6f8beddfea403cb55ae31f03ad62a5ef54e42ee82c3fb35" 87 | } 88 | }; 89 | 90 | const std::string error_message( unsigned int test_number ) { 91 | return QString( "Failed Test %1" ).arg( test_number ).toStdString(); 92 | } 93 | 94 | class tst_QCryptoHash : public QObject { 95 | Q_OBJECT 96 | 97 | public: 98 | tst_QCryptoHash(); 99 | 100 | private Q_SLOTS: 101 | void initTestCase(); 102 | void cleanupTestCase(); 103 | void testTigerHash(); 104 | void testRipeMDHash(); 105 | void testWhirlpoolHash(); 106 | 107 | private: 108 | void genericHashTest( const QMap &tests, QCryptoHash::Algorithm method ); 109 | }; 110 | 111 | tst_QCryptoHash::tst_QCryptoHash() {} 112 | 113 | void tst_QCryptoHash::initTestCase() {} 114 | 115 | void tst_QCryptoHash::cleanupTestCase() {} 116 | 117 | void tst_QCryptoHash::testTigerHash() { 118 | genericHashTest( tigerTests, QCryptoHash::TIGER ); 119 | } 120 | 121 | void tst_QCryptoHash::testRipeMDHash() { 122 | genericHashTest( ripemdTests, QCryptoHash::RMD160 ); 123 | } 124 | 125 | void tst_QCryptoHash::testWhirlpoolHash() { 126 | genericHashTest( whirlpoolTests, QCryptoHash::WHIRLPOOL ); 127 | } 128 | 129 | void tst_QCryptoHash::genericHashTest( const QMap &tests, QCryptoHash::Algorithm method ) { 130 | unsigned int current_test = 1; 131 | auto it_end = tests.cend(); 132 | for ( auto it_start = tests.cbegin(); it_start != it_end; ++it_start ) { 133 | QByteArray hash = QCryptoHash::hash( it_start.key(), method ).toHex(); 134 | QVERIFY2( hash == it_start.value(), error_message( current_test ).c_str() ); 135 | ++current_test; 136 | } 137 | } 138 | 139 | QTEST_APPLESS_MAIN( tst_QCryptoHash ) 140 | 141 | #include "tst_qcryptohash.moc" 142 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | -------------------------------------------------------------------------------- /lib/src/rmd160.cpp: -------------------------------------------------------------------------------- 1 | /* rmd160.c - RIPE-MD160 2 | * Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc. 3 | * 4 | * This file is part of Libgcrypt. 5 | * 6 | * Libgcrypt is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation; either version 2.1 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Libgcrypt is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /* (C) 2002, 2003, 2004 Michael Buesch : 22 | * Modified/deleted/added some functions. 23 | */ 24 | 25 | /* (C) 2015 Riccardo Ostani 26 | * * Changed old C includes (i.e. ) to C++ equivalent (i.e. ) 27 | * * Now Rmd160 class implements the HashAlgorithm interface 28 | * * Removed "rmd160_" prefix in methods name 29 | * - Removed selfTest method (see test sub-project) 30 | * - Removed calcTiger method (not needed, see QCryptoHash::hash) 31 | */ 32 | 33 | #include "rmd160.hpp" 34 | #include "bithelp.h" 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | /********************************* 41 | * RIPEMD-160 is not patented, see (as of 25.10.97) 42 | * http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html 43 | * Note that the code uses Little Endian byteorder, which is good for 44 | * 386 etc, but we must add some conversion when used on a big endian box. 45 | * 46 | * 47 | * Pseudo-code for RIPEMD-160 48 | * 49 | * RIPEMD-160 is an iterative hash function that operates on 32-bit words. 50 | * The round function takes as input a 5-word chaining variable and a 16-word 51 | * message block and maps this to a new chaining variable. All operations are 52 | * defined on 32-bit words. Padding is identical to that of MD4. 53 | * 54 | * 55 | * RIPEMD-160: definitions 56 | * 57 | * 58 | * nonlinear functions at bit level: exor, mux, -, mux, - 59 | * 60 | * f(j, x, y, z) = x XOR y XOR z (0 <= j <= 15) 61 | * f(j, x, y, z) = (x AND y) OR (NOT(x) AND z) (16 <= j <= 31) 62 | * f(j, x, y, z) = (x OR NOT(y)) XOR z (32 <= j <= 47) 63 | * f(j, x, y, z) = (x AND z) OR (y AND NOT(z)) (48 <= j <= 63) 64 | * f(j, x, y, z) = x XOR (y OR NOT(z)) (64 <= j <= 79) 65 | * 66 | * 67 | * added constants (hexadecimal) 68 | * 69 | * K(j) = 0x00000000 (0 <= j <= 15) 70 | * K(j) = 0x5A827999 (16 <= j <= 31) int(2**30 x sqrt(2)) 71 | * K(j) = 0x6ED9EBA1 (32 <= j <= 47) int(2**30 x sqrt(3)) 72 | * K(j) = 0x8F1BBCDC (48 <= j <= 63) int(2**30 x sqrt(5)) 73 | * K(j) = 0xA953FD4E (64 <= j <= 79) int(2**30 x sqrt(7)) 74 | * K'(j) = 0x50A28BE6 (0 <= j <= 15) int(2**30 x cbrt(2)) 75 | * K'(j) = 0x5C4DD124 (16 <= j <= 31) int(2**30 x cbrt(3)) 76 | * K'(j) = 0x6D703EF3 (32 <= j <= 47) int(2**30 x cbrt(5)) 77 | * K'(j) = 0x7A6D76E9 (48 <= j <= 63) int(2**30 x cbrt(7)) 78 | * K'(j) = 0x00000000 (64 <= j <= 79) 79 | * 80 | * 81 | * selection of message word 82 | * 83 | * r(j) = j (0 <= j <= 15) 84 | * r(16..31) = 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8 85 | * r(32..47) = 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12 86 | * r(48..63) = 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2 87 | * r(64..79) = 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 88 | * r0(0..15) = 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12 89 | * r0(16..31)= 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2 90 | * r0(32..47)= 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13 91 | * r0(48..63)= 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14 92 | * r0(64..79)= 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 93 | * 94 | * 95 | * amount for rotate left (rol) 96 | * 97 | * s(0..15) = 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8 98 | * s(16..31) = 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12 99 | * s(32..47) = 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5 100 | * s(48..63) = 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12 101 | * s(64..79) = 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 102 | * s'(0..15) = 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6 103 | * s'(16..31)= 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11 104 | * s'(32..47)= 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5 105 | * s'(48..63)= 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8 106 | * s'(64..79)= 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 107 | * 108 | * 109 | * initial value (hexadecimal) 110 | * 111 | * h0 = 0x67452301; h1 = 0xEFCDAB89; h2 = 0x98BADCFE; h3 = 0x10325476; 112 | * h4 = 0xC3D2E1F0; 113 | * 114 | * 115 | * RIPEMD-160: pseudo-code 116 | * 117 | * It is assumed that the message after padding consists of t 16-word blocks 118 | * that will be denoted with X[i][j], with 0 <= i <= t-1 and 0 <= j <= 15. 119 | * The symbol [+] denotes addition modulo 2**32 and rol_s denotes cyclic left 120 | * shift (rotate) over s positions. 121 | * 122 | * 123 | * for i := 0 to t-1 { 124 | * A := h0; B := h1; C := h2; D = h3; E = h4; 125 | * A' := h0; B' := h1; C' := h2; D' = h3; E' = h4; 126 | * for j := 0 to 79 { 127 | * T := rol_s(j)(A [+] f(j, B, C, D) [+] X[i][r(j)] [+] K(j)) [+] E; 128 | * A := E; E := D; D := rol_10(C); C := B; B := T; 129 | * T := rol_s'(j)(A' [+] f(79-j, B', C', D') [+] X[i][r'(j)] 130 | [+] K'(j)) [+] E'; 131 | * A' := E'; E' := D'; D' := rol_10(C'); C' := B'; B' := T; 132 | * } 133 | * T := h1 [+] C [+] D'; h1 := h2 [+] D [+] E'; h2 := h3 [+] E [+] A'; 134 | * h3 := h4 [+] A [+] B'; h4 := h0 [+] B [+] C'; h0 := T; 135 | * } 136 | */ 137 | 138 | /* Some examples: 139 | * "" 9c1185a5c5e9fc54612808977ee8f548b2258d31 140 | * "a" 0bdc9d2d256b3ee9daae347be6f4dc835a467ffe 141 | * "abc" 8eb208f7e05d987a9b044a8e98c6b087f15a0bfc 142 | * "message digest" 5d0689ef49d2fae572b881b123a85ffa21595f36 143 | * "a...z" f71c27109c692c1b56bbdceb5b9d2865b3708dbc 144 | * "abcdbcde...nopq" 12a053384a9c0c88e405a06c27dcf49ada62eb2b 145 | * "A...Za...z0...9" b0e20b6e3116640286ed3a87a5713079b21f5189 146 | * 8 times "1234567890" 9b752e45573d4b39f4dbd3323cab82bf63326bfb 147 | * 1 million times "a" 52783243c1697bdbe16d37f97f68f08325dc1528 148 | */ 149 | 150 | Rmd160::Rmd160() : context( new RMD160_CONTEXT ) {} 151 | 152 | Rmd160::~Rmd160() { 153 | delete context; 154 | context = NULL; 155 | } 156 | 157 | void Rmd160::burn_stack( int bytes ) { 158 | char buf[150]; 159 | memset( buf, 0, sizeof buf ); 160 | bytes -= sizeof buf; 161 | if ( bytes > 0 ) 162 | burn_stack( bytes ); 163 | } 164 | 165 | void Rmd160::init() { 166 | context->h0 = 0x67452301; 167 | context->h1 = 0xEFCDAB89; 168 | context->h2 = 0x98BADCFE; 169 | context->h3 = 0x10325476; 170 | context->h4 = 0xC3D2E1F0; 171 | context->nblocks = 0; 172 | context->count = 0; 173 | } 174 | 175 | /**************** 176 | * Transform the message X which consists of 16 32-bit-words 177 | */ 178 | void Rmd160::transform( const byte* data ) { 179 | uint32_t a, b, c, d, e, aa, bb, cc, dd, ee, t; 180 | #ifdef BIG_ENDIAN_HOST 181 | uint32_t x[16]; 182 | { 183 | int i; 184 | byte* p2, *p1; 185 | for ( i = 0, p1 = data, p2 = ( byte* ) x; i < 16; i++, p2 += 4 ) { 186 | p2[3] = *p1++; 187 | p2[2] = *p1++; 188 | p2[1] = *p1++; 189 | p2[0] = *p1++; 190 | } 191 | } 192 | #else 193 | #if 0 194 | uint32_t* x = ( uint32_t* ) data; 195 | #else 196 | /* this version is better because it is always aligned; 197 | * The performance penalty on a 586-100 is about 6% which 198 | * is acceptable - because the data is more local it might 199 | * also be possible that this is faster on some machines. 200 | * This function (when compiled with -02 on gcc 2.7.2) 201 | * executes on a 586-100 (39.73 bogomips) at about 1900kb/sec; 202 | * [measured with a 4MB data and "gpgm --print-md rmd160"] */ 203 | uint32_t x[16]; 204 | memcpy( x, data, 64 ); 205 | #endif 206 | #endif 207 | 208 | #define K0 0x00000000 209 | #define K1 0x5A827999 210 | #define K2 0x6ED9EBA1 211 | #define K3 0x8F1BBCDC 212 | #define K4 0xA953FD4E 213 | #define KK0 0x50A28BE6 214 | #define KK1 0x5C4DD124 215 | #define KK2 0x6D703EF3 216 | #define KK3 0x7A6D76E9 217 | #define KK4 0x00000000 218 | #define RMD160_F0(x,y,z) ( (x) ^ (y) ^ (z) ) 219 | #define RMD160_F1(x,y,z) ( ((x) & (y)) | (~(x) & (z)) ) 220 | #define RMD160_F2(x,y,z) ( ((x) | ~(y)) ^ (z) ) 221 | #define RMD160_F3(x,y,z) ( ((x) & (z)) | ((y) & ~(z)) ) 222 | #define RMD160_F4(x,y,z) ( (x) ^ ((y) | ~(z)) ) 223 | #define R(a,b,c,d,e,f,k,r,s) do { t = a + f(b,c,d) + k + x[r]; \ 224 | a = rol(t,s) + e; \ 225 | c = rol(c,10); \ 226 | } while(0) 227 | 228 | /* left lane */ 229 | a = context->h0; 230 | b = context->h1; 231 | c = context->h2; 232 | d = context->h3; 233 | e = context->h4; 234 | R( a, b, c, d, e, RMD160_F0, K0, 0, 11 ); 235 | R( e, a, b, c, d, RMD160_F0, K0, 1, 14 ); 236 | R( d, e, a, b, c, RMD160_F0, K0, 2, 15 ); 237 | R( c, d, e, a, b, RMD160_F0, K0, 3, 12 ); 238 | R( b, c, d, e, a, RMD160_F0, K0, 4, 5 ); 239 | R( a, b, c, d, e, RMD160_F0, K0, 5, 8 ); 240 | R( e, a, b, c, d, RMD160_F0, K0, 6, 7 ); 241 | R( d, e, a, b, c, RMD160_F0, K0, 7, 9 ); 242 | R( c, d, e, a, b, RMD160_F0, K0, 8, 11 ); 243 | R( b, c, d, e, a, RMD160_F0, K0, 9, 13 ); 244 | R( a, b, c, d, e, RMD160_F0, K0, 10, 14 ); 245 | R( e, a, b, c, d, RMD160_F0, K0, 11, 15 ); 246 | R( d, e, a, b, c, RMD160_F0, K0, 12, 6 ); 247 | R( c, d, e, a, b, RMD160_F0, K0, 13, 7 ); 248 | R( b, c, d, e, a, RMD160_F0, K0, 14, 9 ); 249 | R( a, b, c, d, e, RMD160_F0, K0, 15, 8 ); 250 | R( e, a, b, c, d, RMD160_F1, K1, 7, 7 ); 251 | R( d, e, a, b, c, RMD160_F1, K1, 4, 6 ); 252 | R( c, d, e, a, b, RMD160_F1, K1, 13, 8 ); 253 | R( b, c, d, e, a, RMD160_F1, K1, 1, 13 ); 254 | R( a, b, c, d, e, RMD160_F1, K1, 10, 11 ); 255 | R( e, a, b, c, d, RMD160_F1, K1, 6, 9 ); 256 | R( d, e, a, b, c, RMD160_F1, K1, 15, 7 ); 257 | R( c, d, e, a, b, RMD160_F1, K1, 3, 15 ); 258 | R( b, c, d, e, a, RMD160_F1, K1, 12, 7 ); 259 | R( a, b, c, d, e, RMD160_F1, K1, 0, 12 ); 260 | R( e, a, b, c, d, RMD160_F1, K1, 9, 15 ); 261 | R( d, e, a, b, c, RMD160_F1, K1, 5, 9 ); 262 | R( c, d, e, a, b, RMD160_F1, K1, 2, 11 ); 263 | R( b, c, d, e, a, RMD160_F1, K1, 14, 7 ); 264 | R( a, b, c, d, e, RMD160_F1, K1, 11, 13 ); 265 | R( e, a, b, c, d, RMD160_F1, K1, 8, 12 ); 266 | R( d, e, a, b, c, RMD160_F2, K2, 3, 11 ); 267 | R( c, d, e, a, b, RMD160_F2, K2, 10, 13 ); 268 | R( b, c, d, e, a, RMD160_F2, K2, 14, 6 ); 269 | R( a, b, c, d, e, RMD160_F2, K2, 4, 7 ); 270 | R( e, a, b, c, d, RMD160_F2, K2, 9, 14 ); 271 | R( d, e, a, b, c, RMD160_F2, K2, 15, 9 ); 272 | R( c, d, e, a, b, RMD160_F2, K2, 8, 13 ); 273 | R( b, c, d, e, a, RMD160_F2, K2, 1, 15 ); 274 | R( a, b, c, d, e, RMD160_F2, K2, 2, 14 ); 275 | R( e, a, b, c, d, RMD160_F2, K2, 7, 8 ); 276 | R( d, e, a, b, c, RMD160_F2, K2, 0, 13 ); 277 | R( c, d, e, a, b, RMD160_F2, K2, 6, 6 ); 278 | R( b, c, d, e, a, RMD160_F2, K2, 13, 5 ); 279 | R( a, b, c, d, e, RMD160_F2, K2, 11, 12 ); 280 | R( e, a, b, c, d, RMD160_F2, K2, 5, 7 ); 281 | R( d, e, a, b, c, RMD160_F2, K2, 12, 5 ); 282 | R( c, d, e, a, b, RMD160_F3, K3, 1, 11 ); 283 | R( b, c, d, e, a, RMD160_F3, K3, 9, 12 ); 284 | R( a, b, c, d, e, RMD160_F3, K3, 11, 14 ); 285 | R( e, a, b, c, d, RMD160_F3, K3, 10, 15 ); 286 | R( d, e, a, b, c, RMD160_F3, K3, 0, 14 ); 287 | R( c, d, e, a, b, RMD160_F3, K3, 8, 15 ); 288 | R( b, c, d, e, a, RMD160_F3, K3, 12, 9 ); 289 | R( a, b, c, d, e, RMD160_F3, K3, 4, 8 ); 290 | R( e, a, b, c, d, RMD160_F3, K3, 13, 9 ); 291 | R( d, e, a, b, c, RMD160_F3, K3, 3, 14 ); 292 | R( c, d, e, a, b, RMD160_F3, K3, 7, 5 ); 293 | R( b, c, d, e, a, RMD160_F3, K3, 15, 6 ); 294 | R( a, b, c, d, e, RMD160_F3, K3, 14, 8 ); 295 | R( e, a, b, c, d, RMD160_F3, K3, 5, 6 ); 296 | R( d, e, a, b, c, RMD160_F3, K3, 6, 5 ); 297 | R( c, d, e, a, b, RMD160_F3, K3, 2, 12 ); 298 | R( b, c, d, e, a, RMD160_F4, K4, 4, 9 ); 299 | R( a, b, c, d, e, RMD160_F4, K4, 0, 15 ); 300 | R( e, a, b, c, d, RMD160_F4, K4, 5, 5 ); 301 | R( d, e, a, b, c, RMD160_F4, K4, 9, 11 ); 302 | R( c, d, e, a, b, RMD160_F4, K4, 7, 6 ); 303 | R( b, c, d, e, a, RMD160_F4, K4, 12, 8 ); 304 | R( a, b, c, d, e, RMD160_F4, K4, 2, 13 ); 305 | R( e, a, b, c, d, RMD160_F4, K4, 10, 12 ); 306 | R( d, e, a, b, c, RMD160_F4, K4, 14, 5 ); 307 | R( c, d, e, a, b, RMD160_F4, K4, 1, 12 ); 308 | R( b, c, d, e, a, RMD160_F4, K4, 3, 13 ); 309 | R( a, b, c, d, e, RMD160_F4, K4, 8, 14 ); 310 | R( e, a, b, c, d, RMD160_F4, K4, 11, 11 ); 311 | R( d, e, a, b, c, RMD160_F4, K4, 6, 8 ); 312 | R( c, d, e, a, b, RMD160_F4, K4, 15, 5 ); 313 | R( b, c, d, e, a, RMD160_F4, K4, 13, 6 ); 314 | 315 | aa = a; 316 | bb = b; 317 | cc = c; 318 | dd = d; 319 | ee = e; 320 | 321 | /* right lane */ 322 | a = context->h0; 323 | b = context->h1; 324 | c = context->h2; 325 | d = context->h3; 326 | e = context->h4; 327 | R( a, b, c, d, e, RMD160_F4, KK0, 5, 8 ); 328 | R( e, a, b, c, d, RMD160_F4, KK0, 14, 9 ); 329 | R( d, e, a, b, c, RMD160_F4, KK0, 7, 9 ); 330 | R( c, d, e, a, b, RMD160_F4, KK0, 0, 11 ); 331 | R( b, c, d, e, a, RMD160_F4, KK0, 9, 13 ); 332 | R( a, b, c, d, e, RMD160_F4, KK0, 2, 15 ); 333 | R( e, a, b, c, d, RMD160_F4, KK0, 11, 15 ); 334 | R( d, e, a, b, c, RMD160_F4, KK0, 4, 5 ); 335 | R( c, d, e, a, b, RMD160_F4, KK0, 13, 7 ); 336 | R( b, c, d, e, a, RMD160_F4, KK0, 6, 7 ); 337 | R( a, b, c, d, e, RMD160_F4, KK0, 15, 8 ); 338 | R( e, a, b, c, d, RMD160_F4, KK0, 8, 11 ); 339 | R( d, e, a, b, c, RMD160_F4, KK0, 1, 14 ); 340 | R( c, d, e, a, b, RMD160_F4, KK0, 10, 14 ); 341 | R( b, c, d, e, a, RMD160_F4, KK0, 3, 12 ); 342 | R( a, b, c, d, e, RMD160_F4, KK0, 12, 6 ); 343 | R( e, a, b, c, d, RMD160_F3, KK1, 6, 9 ); 344 | R( d, e, a, b, c, RMD160_F3, KK1, 11, 13 ); 345 | R( c, d, e, a, b, RMD160_F3, KK1, 3, 15 ); 346 | R( b, c, d, e, a, RMD160_F3, KK1, 7, 7 ); 347 | R( a, b, c, d, e, RMD160_F3, KK1, 0, 12 ); 348 | R( e, a, b, c, d, RMD160_F3, KK1, 13, 8 ); 349 | R( d, e, a, b, c, RMD160_F3, KK1, 5, 9 ); 350 | R( c, d, e, a, b, RMD160_F3, KK1, 10, 11 ); 351 | R( b, c, d, e, a, RMD160_F3, KK1, 14, 7 ); 352 | R( a, b, c, d, e, RMD160_F3, KK1, 15, 7 ); 353 | R( e, a, b, c, d, RMD160_F3, KK1, 8, 12 ); 354 | R( d, e, a, b, c, RMD160_F3, KK1, 12, 7 ); 355 | R( c, d, e, a, b, RMD160_F3, KK1, 4, 6 ); 356 | R( b, c, d, e, a, RMD160_F3, KK1, 9, 15 ); 357 | R( a, b, c, d, e, RMD160_F3, KK1, 1, 13 ); 358 | R( e, a, b, c, d, RMD160_F3, KK1, 2, 11 ); 359 | R( d, e, a, b, c, RMD160_F2, KK2, 15, 9 ); 360 | R( c, d, e, a, b, RMD160_F2, KK2, 5, 7 ); 361 | R( b, c, d, e, a, RMD160_F2, KK2, 1, 15 ); 362 | R( a, b, c, d, e, RMD160_F2, KK2, 3, 11 ); 363 | R( e, a, b, c, d, RMD160_F2, KK2, 7, 8 ); 364 | R( d, e, a, b, c, RMD160_F2, KK2, 14, 6 ); 365 | R( c, d, e, a, b, RMD160_F2, KK2, 6, 6 ); 366 | R( b, c, d, e, a, RMD160_F2, KK2, 9, 14 ); 367 | R( a, b, c, d, e, RMD160_F2, KK2, 11, 12 ); 368 | R( e, a, b, c, d, RMD160_F2, KK2, 8, 13 ); 369 | R( d, e, a, b, c, RMD160_F2, KK2, 12, 5 ); 370 | R( c, d, e, a, b, RMD160_F2, KK2, 2, 14 ); 371 | R( b, c, d, e, a, RMD160_F2, KK2, 10, 13 ); 372 | R( a, b, c, d, e, RMD160_F2, KK2, 0, 13 ); 373 | R( e, a, b, c, d, RMD160_F2, KK2, 4, 7 ); 374 | R( d, e, a, b, c, RMD160_F2, KK2, 13, 5 ); 375 | R( c, d, e, a, b, RMD160_F1, KK3, 8, 15 ); 376 | R( b, c, d, e, a, RMD160_F1, KK3, 6, 5 ); 377 | R( a, b, c, d, e, RMD160_F1, KK3, 4, 8 ); 378 | R( e, a, b, c, d, RMD160_F1, KK3, 1, 11 ); 379 | R( d, e, a, b, c, RMD160_F1, KK3, 3, 14 ); 380 | R( c, d, e, a, b, RMD160_F1, KK3, 11, 14 ); 381 | R( b, c, d, e, a, RMD160_F1, KK3, 15, 6 ); 382 | R( a, b, c, d, e, RMD160_F1, KK3, 0, 14 ); 383 | R( e, a, b, c, d, RMD160_F1, KK3, 5, 6 ); 384 | R( d, e, a, b, c, RMD160_F1, KK3, 12, 9 ); 385 | R( c, d, e, a, b, RMD160_F1, KK3, 2, 12 ); 386 | R( b, c, d, e, a, RMD160_F1, KK3, 13, 9 ); 387 | R( a, b, c, d, e, RMD160_F1, KK3, 9, 12 ); 388 | R( e, a, b, c, d, RMD160_F1, KK3, 7, 5 ); 389 | R( d, e, a, b, c, RMD160_F1, KK3, 10, 15 ); 390 | R( c, d, e, a, b, RMD160_F1, KK3, 14, 8 ); 391 | R( b, c, d, e, a, RMD160_F0, KK4, 12, 8 ); 392 | R( a, b, c, d, e, RMD160_F0, KK4, 15, 5 ); 393 | R( e, a, b, c, d, RMD160_F0, KK4, 10, 12 ); 394 | R( d, e, a, b, c, RMD160_F0, KK4, 4, 9 ); 395 | R( c, d, e, a, b, RMD160_F0, KK4, 1, 12 ); 396 | R( b, c, d, e, a, RMD160_F0, KK4, 5, 5 ); 397 | R( a, b, c, d, e, RMD160_F0, KK4, 8, 14 ); 398 | R( e, a, b, c, d, RMD160_F0, KK4, 7, 6 ); 399 | R( d, e, a, b, c, RMD160_F0, KK4, 6, 8 ); 400 | R( c, d, e, a, b, RMD160_F0, KK4, 2, 13 ); 401 | R( b, c, d, e, a, RMD160_F0, KK4, 13, 6 ); 402 | R( a, b, c, d, e, RMD160_F0, KK4, 14, 5 ); 403 | R( e, a, b, c, d, RMD160_F0, KK4, 0, 15 ); 404 | R( d, e, a, b, c, RMD160_F0, KK4, 3, 13 ); 405 | R( c, d, e, a, b, RMD160_F0, KK4, 9, 11 ); 406 | R( b, c, d, e, a, RMD160_F0, KK4, 11, 11 ); 407 | 408 | t = context->h1 + d + cc; 409 | context->h1 = context->h2 + e + dd; 410 | context->h2 = context->h3 + a + ee; 411 | context->h3 = context->h4 + b + aa; 412 | context->h4 = context->h0 + c + bb; 413 | context->h0 = t; 414 | } 415 | 416 | /* Update the message digest with the contents 417 | * of INBUF with length INLEN. 418 | */ 419 | void Rmd160::write( const byte* inbuf, int inlen ) { 420 | if ( context->count == 64 ) { /* flush the buffer */ 421 | transform( context->buf ); 422 | burn_stack( 108 + 5 * sizeof( void* ) ); 423 | context->count = 0; 424 | context->nblocks++; 425 | } 426 | if ( !inbuf ) 427 | return; 428 | if ( context->count ) { 429 | for ( ; inlen && context->count < 64; inlen-- ) 430 | context->buf[context->count++] = *inbuf++; 431 | write( NULL, 0 ); 432 | if ( !inlen ) 433 | return; 434 | } 435 | 436 | while ( inlen >= 64 ) { 437 | transform( inbuf ); 438 | context->count = 0; 439 | context->nblocks++; 440 | inlen -= 64; 441 | inbuf += 64; 442 | } 443 | burn_stack( 108 + 5 * sizeof( void* ) ); 444 | for ( ; inlen && context->count < 64; inlen-- ) 445 | context->buf[context->count++] = *inbuf++; 446 | } 447 | 448 | /* The routine terminates the computation 449 | */ 450 | byte* Rmd160::final() { 451 | uint32_t t, msb, lsb; 452 | byte* p; 453 | 454 | write( NULL, 0 ); 455 | 456 | t = context->nblocks; 457 | /* multiply by 64 to make a byte count */ 458 | lsb = t << 6; 459 | msb = t >> 26; 460 | /* add the count */ 461 | t = lsb; 462 | if ( ( lsb += context->count ) < t ) 463 | msb++; 464 | /* multiply by 8 to make a bit count */ 465 | t = lsb; 466 | lsb <<= 3; 467 | msb <<= 3; 468 | msb |= t >> 29; 469 | 470 | if ( context->count < 56 ) { /* enough room */ 471 | context->buf[context->count++] = 0x80; /* pad */ 472 | while ( context->count < 56 ) 473 | context->buf[context->count++] = 0; /* pad */ 474 | } else { /* need one extra block */ 475 | context->buf[context->count++] = 0x80; /* pad character */ 476 | while ( context->count < 64 ) 477 | context->buf[context->count++] = 0; 478 | write( NULL, 0 ); 479 | memset( context->buf, 0, 56 ); /* fill next block with zeroes */ 480 | } 481 | /* append the 64 bit count */ 482 | context->buf[56] = lsb; 483 | context->buf[57] = lsb >> 8; 484 | context->buf[58] = lsb >> 16; 485 | context->buf[59] = lsb >> 24; 486 | context->buf[60] = msb; 487 | context->buf[61] = msb >> 8; 488 | context->buf[62] = msb >> 16; 489 | context->buf[63] = msb >> 24; 490 | transform( context->buf ); 491 | burn_stack( 108 + 5 * sizeof( void* ) ); 492 | 493 | p = context->buf; 494 | #ifdef BIG_ENDIAN_HOST 495 | #define X(a) do { *p++ = context->h##a ; *p++ = context->h##a >> 8; \ 496 | *p++ = context->h##a >> 16; *p++ = context->h##a >> 24; } while(0) 497 | #else /* little endian */ 498 | #define X(a) do { *(uint32_t*)p = context->h##a ; p += 4; } while(0) 499 | #endif 500 | X( 0 ); 501 | X( 1 ); 502 | X( 2 ); 503 | X( 3 ); 504 | X( 4 ); 505 | #undef X 506 | return context->buf; 507 | } 508 | -------------------------------------------------------------------------------- /lib/src/tiger.cpp: -------------------------------------------------------------------------------- 1 | /* tiger.c - The TIGER hash function 2 | * Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc. 3 | * 4 | * This file is part of Libgcrypt. 5 | * 6 | * Libgcrypt is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation; either version 2.1 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Libgcrypt is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /* (C) 2002, 2003, 2004 Michael Buesch : 22 | * Modified/deleted/added some functions. 23 | */ 24 | 25 | /* (C) 2015 Riccardo Ostani 26 | * * Changed old C includes (i.e. ) to C++ equivalent (i.e. ) 27 | * * Now Tiger class implements the HashAlgorithm interface 28 | * * Removed "tiger_" prefix in methods name 29 | * - Removed selfTest method (see test sub-project) 30 | * - Removed calcTiger method (not needed, see QCryptoHash::hash) 31 | */ 32 | 33 | /* Okay, okay, this is not the fastest code - improvements are welcome. */ 34 | 35 | #include "tiger.hpp" 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | static uint64_t sbox1[256] = { 42 | 0x02aab17cf7e90c5eULL /* 0 */ , 0xac424b03e243a8ecULL /* 1 */ , 43 | 0x72cd5be30dd5fcd3ULL /* 2 */ , 0x6d019b93f6f97f3aULL /* 3 */ , 44 | 0xcd9978ffd21f9193ULL /* 4 */ , 0x7573a1c9708029e2ULL /* 5 */ , 45 | 0xb164326b922a83c3ULL /* 6 */ , 0x46883eee04915870ULL /* 7 */ , 46 | 0xeaace3057103ece6ULL /* 8 */ , 0xc54169b808a3535cULL /* 9 */ , 47 | 0x4ce754918ddec47cULL /* 10 */ , 0x0aa2f4dfdc0df40cULL /* 11 */ , 48 | 0x10b76f18a74dbefaULL /* 12 */ , 0xc6ccb6235ad1ab6aULL /* 13 */ , 49 | 0x13726121572fe2ffULL /* 14 */ , 0x1a488c6f199d921eULL /* 15 */ , 50 | 0x4bc9f9f4da0007caULL /* 16 */ , 0x26f5e6f6e85241c7ULL /* 17 */ , 51 | 0x859079dbea5947b6ULL /* 18 */ , 0x4f1885c5c99e8c92ULL /* 19 */ , 52 | 0xd78e761ea96f864bULL /* 20 */ , 0x8e36428c52b5c17dULL /* 21 */ , 53 | 0x69cf6827373063c1ULL /* 22 */ , 0xb607c93d9bb4c56eULL /* 23 */ , 54 | 0x7d820e760e76b5eaULL /* 24 */ , 0x645c9cc6f07fdc42ULL /* 25 */ , 55 | 0xbf38a078243342e0ULL /* 26 */ , 0x5f6b343c9d2e7d04ULL /* 27 */ , 56 | 0xf2c28aeb600b0ec6ULL /* 28 */ , 0x6c0ed85f7254bcacULL /* 29 */ , 57 | 0x71592281a4db4fe5ULL /* 30 */ , 0x1967fa69ce0fed9fULL /* 31 */ , 58 | 0xfd5293f8b96545dbULL /* 32 */ , 0xc879e9d7f2a7600bULL /* 33 */ , 59 | 0x860248920193194eULL /* 34 */ , 0xa4f9533b2d9cc0b3ULL /* 35 */ , 60 | 0x9053836c15957613ULL /* 36 */ , 0xdb6dcf8afc357bf1ULL /* 37 */ , 61 | 0x18beea7a7a370f57ULL /* 38 */ , 0x037117ca50b99066ULL /* 39 */ , 62 | 0x6ab30a9774424a35ULL /* 40 */ , 0xf4e92f02e325249bULL /* 41 */ , 63 | 0x7739db07061ccae1ULL /* 42 */ , 0xd8f3b49ceca42a05ULL /* 43 */ , 64 | 0xbd56be3f51382f73ULL /* 44 */ , 0x45faed5843b0bb28ULL /* 45 */ , 65 | 0x1c813d5c11bf1f83ULL /* 46 */ , 0x8af0e4b6d75fa169ULL /* 47 */ , 66 | 0x33ee18a487ad9999ULL /* 48 */ , 0x3c26e8eab1c94410ULL /* 49 */ , 67 | 0xb510102bc0a822f9ULL /* 50 */ , 0x141eef310ce6123bULL /* 51 */ , 68 | 0xfc65b90059ddb154ULL /* 52 */ , 0xe0158640c5e0e607ULL /* 53 */ , 69 | 0x884e079826c3a3cfULL /* 54 */ , 0x930d0d9523c535fdULL /* 55 */ , 70 | 0x35638d754e9a2b00ULL /* 56 */ , 0x4085fccf40469dd5ULL /* 57 */ , 71 | 0xc4b17ad28be23a4cULL /* 58 */ , 0xcab2f0fc6a3e6a2eULL /* 59 */ , 72 | 0x2860971a6b943fcdULL /* 60 */ , 0x3dde6ee212e30446ULL /* 61 */ , 73 | 0x6222f32ae01765aeULL /* 62 */ , 0x5d550bb5478308feULL /* 63 */ , 74 | 0xa9efa98da0eda22aULL /* 64 */ , 0xc351a71686c40da7ULL /* 65 */ , 75 | 0x1105586d9c867c84ULL /* 66 */ , 0xdcffee85fda22853ULL /* 67 */ , 76 | 0xccfbd0262c5eef76ULL /* 68 */ , 0xbaf294cb8990d201ULL /* 69 */ , 77 | 0xe69464f52afad975ULL /* 70 */ , 0x94b013afdf133e14ULL /* 71 */ , 78 | 0x06a7d1a32823c958ULL /* 72 */ , 0x6f95fe5130f61119ULL /* 73 */ , 79 | 0xd92ab34e462c06c0ULL /* 74 */ , 0xed7bde33887c71d2ULL /* 75 */ , 80 | 0x79746d6e6518393eULL /* 76 */ , 0x5ba419385d713329ULL /* 77 */ , 81 | 0x7c1ba6b948a97564ULL /* 78 */ , 0x31987c197bfdac67ULL /* 79 */ , 82 | 0xde6c23c44b053d02ULL /* 80 */ , 0x581c49fed002d64dULL /* 81 */ , 83 | 0xdd474d6338261571ULL /* 82 */ , 0xaa4546c3e473d062ULL /* 83 */ , 84 | 0x928fce349455f860ULL /* 84 */ , 0x48161bbacaab94d9ULL /* 85 */ , 85 | 0x63912430770e6f68ULL /* 86 */ , 0x6ec8a5e602c6641cULL /* 87 */ , 86 | 0x87282515337ddd2bULL /* 88 */ , 0x2cda6b42034b701bULL /* 89 */ , 87 | 0xb03d37c181cb096dULL /* 90 */ , 0xe108438266c71c6fULL /* 91 */ , 88 | 0x2b3180c7eb51b255ULL /* 92 */ , 0xdf92b82f96c08bbcULL /* 93 */ , 89 | 0x5c68c8c0a632f3baULL /* 94 */ , 0x5504cc861c3d0556ULL /* 95 */ , 90 | 0xabbfa4e55fb26b8fULL /* 96 */ , 0x41848b0ab3baceb4ULL /* 97 */ , 91 | 0xb334a273aa445d32ULL /* 98 */ , 0xbca696f0a85ad881ULL /* 99 */ , 92 | 0x24f6ec65b528d56cULL /* 100 */ , 0x0ce1512e90f4524aULL /* 101 */ , 93 | 0x4e9dd79d5506d35aULL /* 102 */ , 0x258905fac6ce9779ULL /* 103 */ , 94 | 0x2019295b3e109b33ULL /* 104 */ , 0xf8a9478b73a054ccULL /* 105 */ , 95 | 0x2924f2f934417eb0ULL /* 106 */ , 0x3993357d536d1bc4ULL /* 107 */ , 96 | 0x38a81ac21db6ff8bULL /* 108 */ , 0x47c4fbf17d6016bfULL /* 109 */ , 97 | 0x1e0faadd7667e3f5ULL /* 110 */ , 0x7abcff62938beb96ULL /* 111 */ , 98 | 0xa78dad948fc179c9ULL /* 112 */ , 0x8f1f98b72911e50dULL /* 113 */ , 99 | 0x61e48eae27121a91ULL /* 114 */ , 0x4d62f7ad31859808ULL /* 115 */ , 100 | 0xeceba345ef5ceaebULL /* 116 */ , 0xf5ceb25ebc9684ceULL /* 117 */ , 101 | 0xf633e20cb7f76221ULL /* 118 */ , 0xa32cdf06ab8293e4ULL /* 119 */ , 102 | 0x985a202ca5ee2ca4ULL /* 120 */ , 0xcf0b8447cc8a8fb1ULL /* 121 */ , 103 | 0x9f765244979859a3ULL /* 122 */ , 0xa8d516b1a1240017ULL /* 123 */ , 104 | 0x0bd7ba3ebb5dc726ULL /* 124 */ , 0xe54bca55b86adb39ULL /* 125 */ , 105 | 0x1d7a3afd6c478063ULL /* 126 */ , 0x519ec608e7669eddULL /* 127 */ , 106 | 0x0e5715a2d149aa23ULL /* 128 */ , 0x177d4571848ff194ULL /* 129 */ , 107 | 0xeeb55f3241014c22ULL /* 130 */ , 0x0f5e5ca13a6e2ec2ULL /* 131 */ , 108 | 0x8029927b75f5c361ULL /* 132 */ , 0xad139fabc3d6e436ULL /* 133 */ , 109 | 0x0d5df1a94ccf402fULL /* 134 */ , 0x3e8bd948bea5dfc8ULL /* 135 */ , 110 | 0xa5a0d357bd3ff77eULL /* 136 */ , 0xa2d12e251f74f645ULL /* 137 */ , 111 | 0x66fd9e525e81a082ULL /* 138 */ , 0x2e0c90ce7f687a49ULL /* 139 */ , 112 | 0xc2e8bcbeba973bc5ULL /* 140 */ , 0x000001bce509745fULL /* 141 */ , 113 | 0x423777bbe6dab3d6ULL /* 142 */ , 0xd1661c7eaef06eb5ULL /* 143 */ , 114 | 0xa1781f354daacfd8ULL /* 144 */ , 0x2d11284a2b16affcULL /* 145 */ , 115 | 0xf1fc4f67fa891d1fULL /* 146 */ , 0x73ecc25dcb920adaULL /* 147 */ , 116 | 0xae610c22c2a12651ULL /* 148 */ , 0x96e0a810d356b78aULL /* 149 */ , 117 | 0x5a9a381f2fe7870fULL /* 150 */ , 0xd5ad62ede94e5530ULL /* 151 */ , 118 | 0xd225e5e8368d1427ULL /* 152 */ , 0x65977b70c7af4631ULL /* 153 */ , 119 | 0x99f889b2de39d74fULL /* 154 */ , 0x233f30bf54e1d143ULL /* 155 */ , 120 | 0x9a9675d3d9a63c97ULL /* 156 */ , 0x5470554ff334f9a8ULL /* 157 */ , 121 | 0x166acb744a4f5688ULL /* 158 */ , 0x70c74caab2e4aeadULL /* 159 */ , 122 | 0xf0d091646f294d12ULL /* 160 */ , 0x57b82a89684031d1ULL /* 161 */ , 123 | 0xefd95a5a61be0b6bULL /* 162 */ , 0x2fbd12e969f2f29aULL /* 163 */ , 124 | 0x9bd37013feff9fe8ULL /* 164 */ , 0x3f9b0404d6085a06ULL /* 165 */ , 125 | 0x4940c1f3166cfe15ULL /* 166 */ , 0x09542c4dcdf3defbULL /* 167 */ , 126 | 0xb4c5218385cd5ce3ULL /* 168 */ , 0xc935b7dc4462a641ULL /* 169 */ , 127 | 0x3417f8a68ed3b63fULL /* 170 */ , 0xb80959295b215b40ULL /* 171 */ , 128 | 0xf99cdaef3b8c8572ULL /* 172 */ , 0x018c0614f8fcb95dULL /* 173 */ , 129 | 0x1b14accd1a3acdf3ULL /* 174 */ , 0x84d471f200bb732dULL /* 175 */ , 130 | 0xc1a3110e95e8da16ULL /* 176 */ , 0x430a7220bf1a82b8ULL /* 177 */ , 131 | 0xb77e090d39df210eULL /* 178 */ , 0x5ef4bd9f3cd05e9dULL /* 179 */ , 132 | 0x9d4ff6da7e57a444ULL /* 180 */ , 0xda1d60e183d4a5f8ULL /* 181 */ , 133 | 0xb287c38417998e47ULL /* 182 */ , 0xfe3edc121bb31886ULL /* 183 */ , 134 | 0xc7fe3ccc980ccbefULL /* 184 */ , 0xe46fb590189bfd03ULL /* 185 */ , 135 | 0x3732fd469a4c57dcULL /* 186 */ , 0x7ef700a07cf1ad65ULL /* 187 */ , 136 | 0x59c64468a31d8859ULL /* 188 */ , 0x762fb0b4d45b61f6ULL /* 189 */ , 137 | 0x155baed099047718ULL /* 190 */ , 0x68755e4c3d50baa6ULL /* 191 */ , 138 | 0xe9214e7f22d8b4dfULL /* 192 */ , 0x2addbf532eac95f4ULL /* 193 */ , 139 | 0x32ae3909b4bd0109ULL /* 194 */ , 0x834df537b08e3450ULL /* 195 */ , 140 | 0xfa209da84220728dULL /* 196 */ , 0x9e691d9b9efe23f7ULL /* 197 */ , 141 | 0x0446d288c4ae8d7fULL /* 198 */ , 0x7b4cc524e169785bULL /* 199 */ , 142 | 0x21d87f0135ca1385ULL /* 200 */ , 0xcebb400f137b8aa5ULL /* 201 */ , 143 | 0x272e2b66580796beULL /* 202 */ , 0x3612264125c2b0deULL /* 203 */ , 144 | 0x057702bdad1efbb2ULL /* 204 */ , 0xd4babb8eacf84be9ULL /* 205 */ , 145 | 0x91583139641bc67bULL /* 206 */ , 0x8bdc2de08036e024ULL /* 207 */ , 146 | 0x603c8156f49f68edULL /* 208 */ , 0xf7d236f7dbef5111ULL /* 209 */ , 147 | 0x9727c4598ad21e80ULL /* 210 */ , 0xa08a0896670a5fd7ULL /* 211 */ , 148 | 0xcb4a8f4309eba9cbULL /* 212 */ , 0x81af564b0f7036a1ULL /* 213 */ , 149 | 0xc0b99aa778199abdULL /* 214 */ , 0x959f1ec83fc8e952ULL /* 215 */ , 150 | 0x8c505077794a81b9ULL /* 216 */ , 0x3acaaf8f056338f0ULL /* 217 */ , 151 | 0x07b43f50627a6778ULL /* 218 */ , 0x4a44ab49f5eccc77ULL /* 219 */ , 152 | 0x3bc3d6e4b679ee98ULL /* 220 */ , 0x9cc0d4d1cf14108cULL /* 221 */ , 153 | 0x4406c00b206bc8a0ULL /* 222 */ , 0x82a18854c8d72d89ULL /* 223 */ , 154 | 0x67e366b35c3c432cULL /* 224 */ , 0xb923dd61102b37f2ULL /* 225 */ , 155 | 0x56ab2779d884271dULL /* 226 */ , 0xbe83e1b0ff1525afULL /* 227 */ , 156 | 0xfb7c65d4217e49a9ULL /* 228 */ , 0x6bdbe0e76d48e7d4ULL /* 229 */ , 157 | 0x08df828745d9179eULL /* 230 */ , 0x22ea6a9add53bd34ULL /* 231 */ , 158 | 0xe36e141c5622200aULL /* 232 */ , 0x7f805d1b8cb750eeULL /* 233 */ , 159 | 0xafe5c7a59f58e837ULL /* 234 */ , 0xe27f996a4fb1c23cULL /* 235 */ , 160 | 0xd3867dfb0775f0d0ULL /* 236 */ , 0xd0e673de6e88891aULL /* 237 */ , 161 | 0x123aeb9eafb86c25ULL /* 238 */ , 0x30f1d5d5c145b895ULL /* 239 */ , 162 | 0xbb434a2dee7269e7ULL /* 240 */ , 0x78cb67ecf931fa38ULL /* 241 */ , 163 | 0xf33b0372323bbf9cULL /* 242 */ , 0x52d66336fb279c74ULL /* 243 */ , 164 | 0x505f33ac0afb4eaaULL /* 244 */ , 0xe8a5cd99a2cce187ULL /* 245 */ , 165 | 0x534974801e2d30bbULL /* 246 */ , 0x8d2d5711d5876d90ULL /* 247 */ , 166 | 0x1f1a412891bc038eULL /* 248 */ , 0xd6e2e71d82e56648ULL /* 249 */ , 167 | 0x74036c3a497732b7ULL /* 250 */ , 0x89b67ed96361f5abULL /* 251 */ , 168 | 0xffed95d8f1ea02a2ULL /* 252 */ , 0xe72b3bd61464d43dULL /* 253 */ , 169 | 0xa6300f170bdc4820ULL /* 254 */ , 0xebc18760ed78a77aULL /* 255 */ 170 | }; 171 | static uint64_t sbox2[256] = { 172 | 0xe6a6be5a05a12138ULL /* 256 */ , 0xb5a122a5b4f87c98ULL /* 257 */ , 173 | 0x563c6089140b6990ULL /* 258 */ , 0x4c46cb2e391f5dd5ULL /* 259 */ , 174 | 0xd932addbc9b79434ULL /* 260 */ , 0x08ea70e42015aff5ULL /* 261 */ , 175 | 0xd765a6673e478cf1ULL /* 262 */ , 0xc4fb757eab278d99ULL /* 263 */ , 176 | 0xdf11c6862d6e0692ULL /* 264 */ , 0xddeb84f10d7f3b16ULL /* 265 */ , 177 | 0x6f2ef604a665ea04ULL /* 266 */ , 0x4a8e0f0ff0e0dfb3ULL /* 267 */ , 178 | 0xa5edeef83dbcba51ULL /* 268 */ , 0xfc4f0a2a0ea4371eULL /* 269 */ , 179 | 0xe83e1da85cb38429ULL /* 270 */ , 0xdc8ff882ba1b1ce2ULL /* 271 */ , 180 | 0xcd45505e8353e80dULL /* 272 */ , 0x18d19a00d4db0717ULL /* 273 */ , 181 | 0x34a0cfeda5f38101ULL /* 274 */ , 0x0be77e518887caf2ULL /* 275 */ , 182 | 0x1e341438b3c45136ULL /* 276 */ , 0xe05797f49089ccf9ULL /* 277 */ , 183 | 0xffd23f9df2591d14ULL /* 278 */ , 0x543dda228595c5cdULL /* 279 */ , 184 | 0x661f81fd99052a33ULL /* 280 */ , 0x8736e641db0f7b76ULL /* 281 */ , 185 | 0x15227725418e5307ULL /* 282 */ , 0xe25f7f46162eb2faULL /* 283 */ , 186 | 0x48a8b2126c13d9feULL /* 284 */ , 0xafdc541792e76eeaULL /* 285 */ , 187 | 0x03d912bfc6d1898fULL /* 286 */ , 0x31b1aafa1b83f51bULL /* 287 */ , 188 | 0xf1ac2796e42ab7d9ULL /* 288 */ , 0x40a3a7d7fcd2ebacULL /* 289 */ , 189 | 0x1056136d0afbbcc5ULL /* 290 */ , 0x7889e1dd9a6d0c85ULL /* 291 */ , 190 | 0xd33525782a7974aaULL /* 292 */ , 0xa7e25d09078ac09bULL /* 293 */ , 191 | 0xbd4138b3eac6edd0ULL /* 294 */ , 0x920abfbe71eb9e70ULL /* 295 */ , 192 | 0xa2a5d0f54fc2625cULL /* 296 */ , 0xc054e36b0b1290a3ULL /* 297 */ , 193 | 0xf6dd59ff62fe932bULL /* 298 */ , 0x3537354511a8ac7dULL /* 299 */ , 194 | 0xca845e9172fadcd4ULL /* 300 */ , 0x84f82b60329d20dcULL /* 301 */ , 195 | 0x79c62ce1cd672f18ULL /* 302 */ , 0x8b09a2add124642cULL /* 303 */ , 196 | 0xd0c1e96a19d9e726ULL /* 304 */ , 0x5a786a9b4ba9500cULL /* 305 */ , 197 | 0x0e020336634c43f3ULL /* 306 */ , 0xc17b474aeb66d822ULL /* 307 */ , 198 | 0x6a731ae3ec9baac2ULL /* 308 */ , 0x8226667ae0840258ULL /* 309 */ , 199 | 0x67d4567691caeca5ULL /* 310 */ , 0x1d94155c4875adb5ULL /* 311 */ , 200 | 0x6d00fd985b813fdfULL /* 312 */ , 0x51286efcb774cd06ULL /* 313 */ , 201 | 0x5e8834471fa744afULL /* 314 */ , 0xf72ca0aee761ae2eULL /* 315 */ , 202 | 0xbe40e4cdaee8e09aULL /* 316 */ , 0xe9970bbb5118f665ULL /* 317 */ , 203 | 0x726e4beb33df1964ULL /* 318 */ , 0x703b000729199762ULL /* 319 */ , 204 | 0x4631d816f5ef30a7ULL /* 320 */ , 0xb880b5b51504a6beULL /* 321 */ , 205 | 0x641793c37ed84b6cULL /* 322 */ , 0x7b21ed77f6e97d96ULL /* 323 */ , 206 | 0x776306312ef96b73ULL /* 324 */ , 0xae528948e86ff3f4ULL /* 325 */ , 207 | 0x53dbd7f286a3f8f8ULL /* 326 */ , 0x16cadce74cfc1063ULL /* 327 */ , 208 | 0x005c19bdfa52c6ddULL /* 328 */ , 0x68868f5d64d46ad3ULL /* 329 */ , 209 | 0x3a9d512ccf1e186aULL /* 330 */ , 0x367e62c2385660aeULL /* 331 */ , 210 | 0xe359e7ea77dcb1d7ULL /* 332 */ , 0x526c0773749abe6eULL /* 333 */ , 211 | 0x735ae5f9d09f734bULL /* 334 */ , 0x493fc7cc8a558ba8ULL /* 335 */ , 212 | 0xb0b9c1533041ab45ULL /* 336 */ , 0x321958ba470a59bdULL /* 337 */ , 213 | 0x852db00b5f46c393ULL /* 338 */ , 0x91209b2bd336b0e5ULL /* 339 */ , 214 | 0x6e604f7d659ef19fULL /* 340 */ , 0xb99a8ae2782ccb24ULL /* 341 */ , 215 | 0xccf52ab6c814c4c7ULL /* 342 */ , 0x4727d9afbe11727bULL /* 343 */ , 216 | 0x7e950d0c0121b34dULL /* 344 */ , 0x756f435670ad471fULL /* 345 */ , 217 | 0xf5add442615a6849ULL /* 346 */ , 0x4e87e09980b9957aULL /* 347 */ , 218 | 0x2acfa1df50aee355ULL /* 348 */ , 0xd898263afd2fd556ULL /* 349 */ , 219 | 0xc8f4924dd80c8fd6ULL /* 350 */ , 0xcf99ca3d754a173aULL /* 351 */ , 220 | 0xfe477bacaf91bf3cULL /* 352 */ , 0xed5371f6d690c12dULL /* 353 */ , 221 | 0x831a5c285e687094ULL /* 354 */ , 0xc5d3c90a3708a0a4ULL /* 355 */ , 222 | 0x0f7f903717d06580ULL /* 356 */ , 0x19f9bb13b8fdf27fULL /* 357 */ , 223 | 0xb1bd6f1b4d502843ULL /* 358 */ , 0x1c761ba38fff4012ULL /* 359 */ , 224 | 0x0d1530c4e2e21f3bULL /* 360 */ , 0x8943ce69a7372c8aULL /* 361 */ , 225 | 0xe5184e11feb5ce66ULL /* 362 */ , 0x618bdb80bd736621ULL /* 363 */ , 226 | 0x7d29bad68b574d0bULL /* 364 */ , 0x81bb613e25e6fe5bULL /* 365 */ , 227 | 0x071c9c10bc07913fULL /* 366 */ , 0xc7beeb7909ac2d97ULL /* 367 */ , 228 | 0xc3e58d353bc5d757ULL /* 368 */ , 0xeb017892f38f61e8ULL /* 369 */ , 229 | 0xd4effb9c9b1cc21aULL /* 370 */ , 0x99727d26f494f7abULL /* 371 */ , 230 | 0xa3e063a2956b3e03ULL /* 372 */ , 0x9d4a8b9a4aa09c30ULL /* 373 */ , 231 | 0x3f6ab7d500090fb4ULL /* 374 */ , 0x9cc0f2a057268ac0ULL /* 375 */ , 232 | 0x3dee9d2dedbf42d1ULL /* 376 */ , 0x330f49c87960a972ULL /* 377 */ , 233 | 0xc6b2720287421b41ULL /* 378 */ , 0x0ac59ec07c00369cULL /* 379 */ , 234 | 0xef4eac49cb353425ULL /* 380 */ , 0xf450244eef0129d8ULL /* 381 */ , 235 | 0x8acc46e5caf4deb6ULL /* 382 */ , 0x2ffeab63989263f7ULL /* 383 */ , 236 | 0x8f7cb9fe5d7a4578ULL /* 384 */ , 0x5bd8f7644e634635ULL /* 385 */ , 237 | 0x427a7315bf2dc900ULL /* 386 */ , 0x17d0c4aa2125261cULL /* 387 */ , 238 | 0x3992486c93518e50ULL /* 388 */ , 0xb4cbfee0a2d7d4c3ULL /* 389 */ , 239 | 0x7c75d6202c5ddd8dULL /* 390 */ , 0xdbc295d8e35b6c61ULL /* 391 */ , 240 | 0x60b369d302032b19ULL /* 392 */ , 0xce42685fdce44132ULL /* 393 */ , 241 | 0x06f3ddb9ddf65610ULL /* 394 */ , 0x8ea4d21db5e148f0ULL /* 395 */ , 242 | 0x20b0fce62fcd496fULL /* 396 */ , 0x2c1b912358b0ee31ULL /* 397 */ , 243 | 0xb28317b818f5a308ULL /* 398 */ , 0xa89c1e189ca6d2cfULL /* 399 */ , 244 | 0x0c6b18576aaadbc8ULL /* 400 */ , 0xb65deaa91299fae3ULL /* 401 */ , 245 | 0xfb2b794b7f1027e7ULL /* 402 */ , 0x04e4317f443b5bebULL /* 403 */ , 246 | 0x4b852d325939d0a6ULL /* 404 */ , 0xd5ae6beefb207ffcULL /* 405 */ , 247 | 0x309682b281c7d374ULL /* 406 */ , 0xbae309a194c3b475ULL /* 407 */ , 248 | 0x8cc3f97b13b49f05ULL /* 408 */ , 0x98a9422ff8293967ULL /* 409 */ , 249 | 0x244b16b01076ff7cULL /* 410 */ , 0xf8bf571c663d67eeULL /* 411 */ , 250 | 0x1f0d6758eee30da1ULL /* 412 */ , 0xc9b611d97adeb9b7ULL /* 413 */ , 251 | 0xb7afd5887b6c57a2ULL /* 414 */ , 0x6290ae846b984fe1ULL /* 415 */ , 252 | 0x94df4cdeacc1a5fdULL /* 416 */ , 0x058a5bd1c5483affULL /* 417 */ , 253 | 0x63166cc142ba3c37ULL /* 418 */ , 0x8db8526eb2f76f40ULL /* 419 */ , 254 | 0xe10880036f0d6d4eULL /* 420 */ , 0x9e0523c9971d311dULL /* 421 */ , 255 | 0x45ec2824cc7cd691ULL /* 422 */ , 0x575b8359e62382c9ULL /* 423 */ , 256 | 0xfa9e400dc4889995ULL /* 424 */ , 0xd1823ecb45721568ULL /* 425 */ , 257 | 0xdafd983b8206082fULL /* 426 */ , 0xaa7d29082386a8cbULL /* 427 */ , 258 | 0x269fcd4403b87588ULL /* 428 */ , 0x1b91f5f728bdd1e0ULL /* 429 */ , 259 | 0xe4669f39040201f6ULL /* 430 */ , 0x7a1d7c218cf04adeULL /* 431 */ , 260 | 0x65623c29d79ce5ceULL /* 432 */ , 0x2368449096c00bb1ULL /* 433 */ , 261 | 0xab9bf1879da503baULL /* 434 */ , 0xbc23ecb1a458058eULL /* 435 */ , 262 | 0x9a58df01bb401eccULL /* 436 */ , 0xa070e868a85f143dULL /* 437 */ , 263 | 0x4ff188307df2239eULL /* 438 */ , 0x14d565b41a641183ULL /* 439 */ , 264 | 0xee13337452701602ULL /* 440 */ , 0x950e3dcf3f285e09ULL /* 441 */ , 265 | 0x59930254b9c80953ULL /* 442 */ , 0x3bf299408930da6dULL /* 443 */ , 266 | 0xa955943f53691387ULL /* 444 */ , 0xa15edecaa9cb8784ULL /* 445 */ , 267 | 0x29142127352be9a0ULL /* 446 */ , 0x76f0371fff4e7afbULL /* 447 */ , 268 | 0x0239f450274f2228ULL /* 448 */ , 0xbb073af01d5e868bULL /* 449 */ , 269 | 0xbfc80571c10e96c1ULL /* 450 */ , 0xd267088568222e23ULL /* 451 */ , 270 | 0x9671a3d48e80b5b0ULL /* 452 */ , 0x55b5d38ae193bb81ULL /* 453 */ , 271 | 0x693ae2d0a18b04b8ULL /* 454 */ , 0x5c48b4ecadd5335fULL /* 455 */ , 272 | 0xfd743b194916a1caULL /* 456 */ , 0x2577018134be98c4ULL /* 457 */ , 273 | 0xe77987e83c54a4adULL /* 458 */ , 0x28e11014da33e1b9ULL /* 459 */ , 274 | 0x270cc59e226aa213ULL /* 460 */ , 0x71495f756d1a5f60ULL /* 461 */ , 275 | 0x9be853fb60afef77ULL /* 462 */ , 0xadc786a7f7443dbfULL /* 463 */ , 276 | 0x0904456173b29a82ULL /* 464 */ , 0x58bc7a66c232bd5eULL /* 465 */ , 277 | 0xf306558c673ac8b2ULL /* 466 */ , 0x41f639c6b6c9772aULL /* 467 */ , 278 | 0x216defe99fda35daULL /* 468 */ , 0x11640cc71c7be615ULL /* 469 */ , 279 | 0x93c43694565c5527ULL /* 470 */ , 0xea038e6246777839ULL /* 471 */ , 280 | 0xf9abf3ce5a3e2469ULL /* 472 */ , 0x741e768d0fd312d2ULL /* 473 */ , 281 | 0x0144b883ced652c6ULL /* 474 */ , 0xc20b5a5ba33f8552ULL /* 475 */ , 282 | 0x1ae69633c3435a9dULL /* 476 */ , 0x97a28ca4088cfdecULL /* 477 */ , 283 | 0x8824a43c1e96f420ULL /* 478 */ , 0x37612fa66eeea746ULL /* 479 */ , 284 | 0x6b4cb165f9cf0e5aULL /* 480 */ , 0x43aa1c06a0abfb4aULL /* 481 */ , 285 | 0x7f4dc26ff162796bULL /* 482 */ , 0x6cbacc8e54ed9b0fULL /* 483 */ , 286 | 0xa6b7ffefd2bb253eULL /* 484 */ , 0x2e25bc95b0a29d4fULL /* 485 */ , 287 | 0x86d6a58bdef1388cULL /* 486 */ , 0xded74ac576b6f054ULL /* 487 */ , 288 | 0x8030bdbc2b45805dULL /* 488 */ , 0x3c81af70e94d9289ULL /* 489 */ , 289 | 0x3eff6dda9e3100dbULL /* 490 */ , 0xb38dc39fdfcc8847ULL /* 491 */ , 290 | 0x123885528d17b87eULL /* 492 */ , 0xf2da0ed240b1b642ULL /* 493 */ , 291 | 0x44cefadcd54bf9a9ULL /* 494 */ , 0x1312200e433c7ee6ULL /* 495 */ , 292 | 0x9ffcc84f3a78c748ULL /* 496 */ , 0xf0cd1f72248576bbULL /* 497 */ , 293 | 0xec6974053638cfe4ULL /* 498 */ , 0x2ba7b67c0cec4e4cULL /* 499 */ , 294 | 0xac2f4df3e5ce32edULL /* 500 */ , 0xcb33d14326ea4c11ULL /* 501 */ , 295 | 0xa4e9044cc77e58bcULL /* 502 */ , 0x5f513293d934fcefULL /* 503 */ , 296 | 0x5dc9645506e55444ULL /* 504 */ , 0x50de418f317de40aULL /* 505 */ , 297 | 0x388cb31a69dde259ULL /* 506 */ , 0x2db4a83455820a86ULL /* 507 */ , 298 | 0x9010a91e84711ae9ULL /* 508 */ , 0x4df7f0b7b1498371ULL /* 509 */ , 299 | 0xd62a2eabc0977179ULL /* 510 */ , 0x22fac097aa8d5c0eULL /* 511 */ 300 | }; 301 | static uint64_t sbox3[256] = { 302 | 0xf49fcc2ff1daf39bULL /* 512 */ , 0x487fd5c66ff29281ULL /* 513 */ , 303 | 0xe8a30667fcdca83fULL /* 514 */ , 0x2c9b4be3d2fcce63ULL /* 515 */ , 304 | 0xda3ff74b93fbbbc2ULL /* 516 */ , 0x2fa165d2fe70ba66ULL /* 517 */ , 305 | 0xa103e279970e93d4ULL /* 518 */ , 0xbecdec77b0e45e71ULL /* 519 */ , 306 | 0xcfb41e723985e497ULL /* 520 */ , 0xb70aaa025ef75017ULL /* 521 */ , 307 | 0xd42309f03840b8e0ULL /* 522 */ , 0x8efc1ad035898579ULL /* 523 */ , 308 | 0x96c6920be2b2abc5ULL /* 524 */ , 0x66af4163375a9172ULL /* 525 */ , 309 | 0x2174abdcca7127fbULL /* 526 */ , 0xb33ccea64a72ff41ULL /* 527 */ , 310 | 0xf04a4933083066a5ULL /* 528 */ , 0x8d970acdd7289af5ULL /* 529 */ , 311 | 0x8f96e8e031c8c25eULL /* 530 */ , 0xf3fec02276875d47ULL /* 531 */ , 312 | 0xec7bf310056190ddULL /* 532 */ , 0xf5adb0aebb0f1491ULL /* 533 */ , 313 | 0x9b50f8850fd58892ULL /* 534 */ , 0x4975488358b74de8ULL /* 535 */ , 314 | 0xa3354ff691531c61ULL /* 536 */ , 0x0702bbe481d2c6eeULL /* 537 */ , 315 | 0x89fb24057deded98ULL /* 538 */ , 0xac3075138596e902ULL /* 539 */ , 316 | 0x1d2d3580172772edULL /* 540 */ , 0xeb738fc28e6bc30dULL /* 541 */ , 317 | 0x5854ef8f63044326ULL /* 542 */ , 0x9e5c52325add3bbeULL /* 543 */ , 318 | 0x90aa53cf325c4623ULL /* 544 */ , 0xc1d24d51349dd067ULL /* 545 */ , 319 | 0x2051cfeea69ea624ULL /* 546 */ , 0x13220f0a862e7e4fULL /* 547 */ , 320 | 0xce39399404e04864ULL /* 548 */ , 0xd9c42ca47086fcb7ULL /* 549 */ , 321 | 0x685ad2238a03e7ccULL /* 550 */ , 0x066484b2ab2ff1dbULL /* 551 */ , 322 | 0xfe9d5d70efbf79ecULL /* 552 */ , 0x5b13b9dd9c481854ULL /* 553 */ , 323 | 0x15f0d475ed1509adULL /* 554 */ , 0x0bebcd060ec79851ULL /* 555 */ , 324 | 0xd58c6791183ab7f8ULL /* 556 */ , 0xd1187c5052f3eee4ULL /* 557 */ , 325 | 0xc95d1192e54e82ffULL /* 558 */ , 0x86eea14cb9ac6ca2ULL /* 559 */ , 326 | 0x3485beb153677d5dULL /* 560 */ , 0xdd191d781f8c492aULL /* 561 */ , 327 | 0xf60866baa784ebf9ULL /* 562 */ , 0x518f643ba2d08c74ULL /* 563 */ , 328 | 0x8852e956e1087c22ULL /* 564 */ , 0xa768cb8dc410ae8dULL /* 565 */ , 329 | 0x38047726bfec8e1aULL /* 566 */ , 0xa67738b4cd3b45aaULL /* 567 */ , 330 | 0xad16691cec0dde19ULL /* 568 */ , 0xc6d4319380462e07ULL /* 569 */ , 331 | 0xc5a5876d0ba61938ULL /* 570 */ , 0x16b9fa1fa58fd840ULL /* 571 */ , 332 | 0x188ab1173ca74f18ULL /* 572 */ , 0xabda2f98c99c021fULL /* 573 */ , 333 | 0x3e0580ab134ae816ULL /* 574 */ , 0x5f3b05b773645abbULL /* 575 */ , 334 | 0x2501a2be5575f2f6ULL /* 576 */ , 0x1b2f74004e7e8ba9ULL /* 577 */ , 335 | 0x1cd7580371e8d953ULL /* 578 */ , 0x7f6ed89562764e30ULL /* 579 */ , 336 | 0xb15926ff596f003dULL /* 580 */ , 0x9f65293da8c5d6b9ULL /* 581 */ , 337 | 0x6ecef04dd690f84cULL /* 582 */ , 0x4782275fff33af88ULL /* 583 */ , 338 | 0xe41433083f820801ULL /* 584 */ , 0xfd0dfe409a1af9b5ULL /* 585 */ , 339 | 0x4325a3342cdb396bULL /* 586 */ , 0x8ae77e62b301b252ULL /* 587 */ , 340 | 0xc36f9e9f6655615aULL /* 588 */ , 0x85455a2d92d32c09ULL /* 589 */ , 341 | 0xf2c7dea949477485ULL /* 590 */ , 0x63cfb4c133a39ebaULL /* 591 */ , 342 | 0x83b040cc6ebc5462ULL /* 592 */ , 0x3b9454c8fdb326b0ULL /* 593 */ , 343 | 0x56f56a9e87ffd78cULL /* 594 */ , 0x2dc2940d99f42bc6ULL /* 595 */ , 344 | 0x98f7df096b096e2dULL /* 596 */ , 0x19a6e01e3ad852bfULL /* 597 */ , 345 | 0x42a99ccbdbd4b40bULL /* 598 */ , 0xa59998af45e9c559ULL /* 599 */ , 346 | 0x366295e807d93186ULL /* 600 */ , 0x6b48181bfaa1f773ULL /* 601 */ , 347 | 0x1fec57e2157a0a1dULL /* 602 */ , 0x4667446af6201ad5ULL /* 603 */ , 348 | 0xe615ebcacfb0f075ULL /* 604 */ , 0xb8f31f4f68290778ULL /* 605 */ , 349 | 0x22713ed6ce22d11eULL /* 606 */ , 0x3057c1a72ec3c93bULL /* 607 */ , 350 | 0xcb46acc37c3f1f2fULL /* 608 */ , 0xdbb893fd02aaf50eULL /* 609 */ , 351 | 0x331fd92e600b9fcfULL /* 610 */ , 0xa498f96148ea3ad6ULL /* 611 */ , 352 | 0xa8d8426e8b6a83eaULL /* 612 */ , 0xa089b274b7735cdcULL /* 613 */ , 353 | 0x87f6b3731e524a11ULL /* 614 */ , 0x118808e5cbc96749ULL /* 615 */ , 354 | 0x9906e4c7b19bd394ULL /* 616 */ , 0xafed7f7e9b24a20cULL /* 617 */ , 355 | 0x6509eadeeb3644a7ULL /* 618 */ , 0x6c1ef1d3e8ef0edeULL /* 619 */ , 356 | 0xb9c97d43e9798fb4ULL /* 620 */ , 0xa2f2d784740c28a3ULL /* 621 */ , 357 | 0x7b8496476197566fULL /* 622 */ , 0x7a5be3e6b65f069dULL /* 623 */ , 358 | 0xf96330ed78be6f10ULL /* 624 */ , 0xeee60de77a076a15ULL /* 625 */ , 359 | 0x2b4bee4aa08b9bd0ULL /* 626 */ , 0x6a56a63ec7b8894eULL /* 627 */ , 360 | 0x02121359ba34fef4ULL /* 628 */ , 0x4cbf99f8283703fcULL /* 629 */ , 361 | 0x398071350caf30c8ULL /* 630 */ , 0xd0a77a89f017687aULL /* 631 */ , 362 | 0xf1c1a9eb9e423569ULL /* 632 */ , 0x8c7976282dee8199ULL /* 633 */ , 363 | 0x5d1737a5dd1f7abdULL /* 634 */ , 0x4f53433c09a9fa80ULL /* 635 */ , 364 | 0xfa8b0c53df7ca1d9ULL /* 636 */ , 0x3fd9dcbc886ccb77ULL /* 637 */ , 365 | 0xc040917ca91b4720ULL /* 638 */ , 0x7dd00142f9d1dcdfULL /* 639 */ , 366 | 0x8476fc1d4f387b58ULL /* 640 */ , 0x23f8e7c5f3316503ULL /* 641 */ , 367 | 0x032a2244e7e37339ULL /* 642 */ , 0x5c87a5d750f5a74bULL /* 643 */ , 368 | 0x082b4cc43698992eULL /* 644 */ , 0xdf917becb858f63cULL /* 645 */ , 369 | 0x3270b8fc5bf86ddaULL /* 646 */ , 0x10ae72bb29b5dd76ULL /* 647 */ , 370 | 0x576ac94e7700362bULL /* 648 */ , 0x1ad112dac61efb8fULL /* 649 */ , 371 | 0x691bc30ec5faa427ULL /* 650 */ , 0xff246311cc327143ULL /* 651 */ , 372 | 0x3142368e30e53206ULL /* 652 */ , 0x71380e31e02ca396ULL /* 653 */ , 373 | 0x958d5c960aad76f1ULL /* 654 */ , 0xf8d6f430c16da536ULL /* 655 */ , 374 | 0xc8ffd13f1be7e1d2ULL /* 656 */ , 0x7578ae66004ddbe1ULL /* 657 */ , 375 | 0x05833f01067be646ULL /* 658 */ , 0xbb34b5ad3bfe586dULL /* 659 */ , 376 | 0x095f34c9a12b97f0ULL /* 660 */ , 0x247ab64525d60ca8ULL /* 661 */ , 377 | 0xdcdbc6f3017477d1ULL /* 662 */ , 0x4a2e14d4decad24dULL /* 663 */ , 378 | 0xbdb5e6d9be0a1eebULL /* 664 */ , 0x2a7e70f7794301abULL /* 665 */ , 379 | 0xdef42d8a270540fdULL /* 666 */ , 0x01078ec0a34c22c1ULL /* 667 */ , 380 | 0xe5de511af4c16387ULL /* 668 */ , 0x7ebb3a52bd9a330aULL /* 669 */ , 381 | 0x77697857aa7d6435ULL /* 670 */ , 0x004e831603ae4c32ULL /* 671 */ , 382 | 0xe7a21020ad78e312ULL /* 672 */ , 0x9d41a70c6ab420f2ULL /* 673 */ , 383 | 0x28e06c18ea1141e6ULL /* 674 */ , 0xd2b28cbd984f6b28ULL /* 675 */ , 384 | 0x26b75f6c446e9d83ULL /* 676 */ , 0xba47568c4d418d7fULL /* 677 */ , 385 | 0xd80badbfe6183d8eULL /* 678 */ , 0x0e206d7f5f166044ULL /* 679 */ , 386 | 0xe258a43911cbca3eULL /* 680 */ , 0x723a1746b21dc0bcULL /* 681 */ , 387 | 0xc7caa854f5d7cdd3ULL /* 682 */ , 0x7cac32883d261d9cULL /* 683 */ , 388 | 0x7690c26423ba942cULL /* 684 */ , 0x17e55524478042b8ULL /* 685 */ , 389 | 0xe0be477656a2389fULL /* 686 */ , 0x4d289b5e67ab2da0ULL /* 687 */ , 390 | 0x44862b9c8fbbfd31ULL /* 688 */ , 0xb47cc8049d141365ULL /* 689 */ , 391 | 0x822c1b362b91c793ULL /* 690 */ , 0x4eb14655fb13dfd8ULL /* 691 */ , 392 | 0x1ecbba0714e2a97bULL /* 692 */ , 0x6143459d5cde5f14ULL /* 693 */ , 393 | 0x53a8fbf1d5f0ac89ULL /* 694 */ , 0x97ea04d81c5e5b00ULL /* 695 */ , 394 | 0x622181a8d4fdb3f3ULL /* 696 */ , 0xe9bcd341572a1208ULL /* 697 */ , 395 | 0x1411258643cce58aULL /* 698 */ , 0x9144c5fea4c6e0a4ULL /* 699 */ , 396 | 0x0d33d06565cf620fULL /* 700 */ , 0x54a48d489f219ca1ULL /* 701 */ , 397 | 0xc43e5eac6d63c821ULL /* 702 */ , 0xa9728b3a72770dafULL /* 703 */ , 398 | 0xd7934e7b20df87efULL /* 704 */ , 0xe35503b61a3e86e5ULL /* 705 */ , 399 | 0xcae321fbc819d504ULL /* 706 */ , 0x129a50b3ac60bfa6ULL /* 707 */ , 400 | 0xcd5e68ea7e9fb6c3ULL /* 708 */ , 0xb01c90199483b1c7ULL /* 709 */ , 401 | 0x3de93cd5c295376cULL /* 710 */ , 0xaed52edf2ab9ad13ULL /* 711 */ , 402 | 0x2e60f512c0a07884ULL /* 712 */ , 0xbc3d86a3e36210c9ULL /* 713 */ , 403 | 0x35269d9b163951ceULL /* 714 */ , 0x0c7d6e2ad0cdb5faULL /* 715 */ , 404 | 0x59e86297d87f5733ULL /* 716 */ , 0x298ef221898db0e7ULL /* 717 */ , 405 | 0x55000029d1a5aa7eULL /* 718 */ , 0x8bc08ae1b5061b45ULL /* 719 */ , 406 | 0xc2c31c2b6c92703aULL /* 720 */ , 0x94cc596baf25ef42ULL /* 721 */ , 407 | 0x0a1d73db22540456ULL /* 722 */ , 0x04b6a0f9d9c4179aULL /* 723 */ , 408 | 0xeffdafa2ae3d3c60ULL /* 724 */ , 0xf7c8075bb49496c4ULL /* 725 */ , 409 | 0x9cc5c7141d1cd4e3ULL /* 726 */ , 0x78bd1638218e5534ULL /* 727 */ , 410 | 0xb2f11568f850246aULL /* 728 */ , 0xedfabcfa9502bc29ULL /* 729 */ , 411 | 0x796ce5f2da23051bULL /* 730 */ , 0xaae128b0dc93537cULL /* 731 */ , 412 | 0x3a493da0ee4b29aeULL /* 732 */ , 0xb5df6b2c416895d7ULL /* 733 */ , 413 | 0xfcabbd25122d7f37ULL /* 734 */ , 0x70810b58105dc4b1ULL /* 735 */ , 414 | 0xe10fdd37f7882a90ULL /* 736 */ , 0x524dcab5518a3f5cULL /* 737 */ , 415 | 0x3c9e85878451255bULL /* 738 */ , 0x4029828119bd34e2ULL /* 739 */ , 416 | 0x74a05b6f5d3ceccbULL /* 740 */ , 0xb610021542e13ecaULL /* 741 */ , 417 | 0x0ff979d12f59e2acULL /* 742 */ , 0x6037da27e4f9cc50ULL /* 743 */ , 418 | 0x5e92975a0df1847dULL /* 744 */ , 0xd66de190d3e623feULL /* 745 */ , 419 | 0x5032d6b87b568048ULL /* 746 */ , 0x9a36b7ce8235216eULL /* 747 */ , 420 | 0x80272a7a24f64b4aULL /* 748 */ , 0x93efed8b8c6916f7ULL /* 749 */ , 421 | 0x37ddbff44cce1555ULL /* 750 */ , 0x4b95db5d4b99bd25ULL /* 751 */ , 422 | 0x92d3fda169812fc0ULL /* 752 */ , 0xfb1a4a9a90660bb6ULL /* 753 */ , 423 | 0x730c196946a4b9b2ULL /* 754 */ , 0x81e289aa7f49da68ULL /* 755 */ , 424 | 0x64669a0f83b1a05fULL /* 756 */ , 0x27b3ff7d9644f48bULL /* 757 */ , 425 | 0xcc6b615c8db675b3ULL /* 758 */ , 0x674f20b9bcebbe95ULL /* 759 */ , 426 | 0x6f31238275655982ULL /* 760 */ , 0x5ae488713e45cf05ULL /* 761 */ , 427 | 0xbf619f9954c21157ULL /* 762 */ , 0xeabac46040a8eae9ULL /* 763 */ , 428 | 0x454c6fe9f2c0c1cdULL /* 764 */ , 0x419cf6496412691cULL /* 765 */ , 429 | 0xd3dc3bef265b0f70ULL /* 766 */ , 0x6d0e60f5c3578a9eULL /* 767 */ 430 | }; 431 | static uint64_t sbox4[256] = { 432 | 0x5b0e608526323c55ULL /* 768 */ , 0x1a46c1a9fa1b59f5ULL /* 769 */ , 433 | 0xa9e245a17c4c8ffaULL /* 770 */ , 0x65ca5159db2955d7ULL /* 771 */ , 434 | 0x05db0a76ce35afc2ULL /* 772 */ , 0x81eac77ea9113d45ULL /* 773 */ , 435 | 0x528ef88ab6ac0a0dULL /* 774 */ , 0xa09ea253597be3ffULL /* 775 */ , 436 | 0x430ddfb3ac48cd56ULL /* 776 */ , 0xc4b3a67af45ce46fULL /* 777 */ , 437 | 0x4ececfd8fbe2d05eULL /* 778 */ , 0x3ef56f10b39935f0ULL /* 779 */ , 438 | 0x0b22d6829cd619c6ULL /* 780 */ , 0x17fd460a74df2069ULL /* 781 */ , 439 | 0x6cf8cc8e8510ed40ULL /* 782 */ , 0xd6c824bf3a6ecaa7ULL /* 783 */ , 440 | 0x61243d581a817049ULL /* 784 */ , 0x048bacb6bbc163a2ULL /* 785 */ , 441 | 0xd9a38ac27d44cc32ULL /* 786 */ , 0x7fddff5baaf410abULL /* 787 */ , 442 | 0xad6d495aa804824bULL /* 788 */ , 0xe1a6a74f2d8c9f94ULL /* 789 */ , 443 | 0xd4f7851235dee8e3ULL /* 790 */ , 0xfd4b7f886540d893ULL /* 791 */ , 444 | 0x247c20042aa4bfdaULL /* 792 */ , 0x096ea1c517d1327cULL /* 793 */ , 445 | 0xd56966b4361a6685ULL /* 794 */ , 0x277da5c31221057dULL /* 795 */ , 446 | 0x94d59893a43acff7ULL /* 796 */ , 0x64f0c51ccdc02281ULL /* 797 */ , 447 | 0x3d33bcc4ff6189dbULL /* 798 */ , 0xe005cb184ce66af1ULL /* 799 */ , 448 | 0xff5ccd1d1db99beaULL /* 800 */ , 0xb0b854a7fe42980fULL /* 801 */ , 449 | 0x7bd46a6a718d4b9fULL /* 802 */ , 0xd10fa8cc22a5fd8cULL /* 803 */ , 450 | 0xd31484952be4bd31ULL /* 804 */ , 0xc7fa975fcb243847ULL /* 805 */ , 451 | 0x4886ed1e5846c407ULL /* 806 */ , 0x28cddb791eb70b04ULL /* 807 */ , 452 | 0xc2b00be2f573417fULL /* 808 */ , 0x5c9590452180f877ULL /* 809 */ , 453 | 0x7a6bddfff370eb00ULL /* 810 */ , 0xce509e38d6d9d6a4ULL /* 811 */ , 454 | 0xebeb0f00647fa702ULL /* 812 */ , 0x1dcc06cf76606f06ULL /* 813 */ , 455 | 0xe4d9f28ba286ff0aULL /* 814 */ , 0xd85a305dc918c262ULL /* 815 */ , 456 | 0x475b1d8732225f54ULL /* 816 */ , 0x2d4fb51668ccb5feULL /* 817 */ , 457 | 0xa679b9d9d72bba20ULL /* 818 */ , 0x53841c0d912d43a5ULL /* 819 */ , 458 | 0x3b7eaa48bf12a4e8ULL /* 820 */ , 0x781e0e47f22f1ddfULL /* 821 */ , 459 | 0xeff20ce60ab50973ULL /* 822 */ , 0x20d261d19dffb742ULL /* 823 */ , 460 | 0x16a12b03062a2e39ULL /* 824 */ , 0x1960eb2239650495ULL /* 825 */ , 461 | 0x251c16fed50eb8b8ULL /* 826 */ , 0x9ac0c330f826016eULL /* 827 */ , 462 | 0xed152665953e7671ULL /* 828 */ , 0x02d63194a6369570ULL /* 829 */ , 463 | 0x5074f08394b1c987ULL /* 830 */ , 0x70ba598c90b25ce1ULL /* 831 */ , 464 | 0x794a15810b9742f6ULL /* 832 */ , 0x0d5925e9fcaf8c6cULL /* 833 */ , 465 | 0x3067716cd868744eULL /* 834 */ , 0x910ab077e8d7731bULL /* 835 */ , 466 | 0x6a61bbdb5ac42f61ULL /* 836 */ , 0x93513efbf0851567ULL /* 837 */ , 467 | 0xf494724b9e83e9d5ULL /* 838 */ , 0xe887e1985c09648dULL /* 839 */ , 468 | 0x34b1d3c675370cfdULL /* 840 */ , 0xdc35e433bc0d255dULL /* 841 */ , 469 | 0xd0aab84234131be0ULL /* 842 */ , 0x08042a50b48b7eafULL /* 843 */ , 470 | 0x9997c4ee44a3ab35ULL /* 844 */ , 0x829a7b49201799d0ULL /* 845 */ , 471 | 0x263b8307b7c54441ULL /* 846 */ , 0x752f95f4fd6a6ca6ULL /* 847 */ , 472 | 0x927217402c08c6e5ULL /* 848 */ , 0x2a8ab754a795d9eeULL /* 849 */ , 473 | 0xa442f7552f72943dULL /* 850 */ , 0x2c31334e19781208ULL /* 851 */ , 474 | 0x4fa98d7ceaee6291ULL /* 852 */ , 0x55c3862f665db309ULL /* 853 */ , 475 | 0xbd0610175d53b1f3ULL /* 854 */ , 0x46fe6cb840413f27ULL /* 855 */ , 476 | 0x3fe03792df0cfa59ULL /* 856 */ , 0xcfe700372eb85e8fULL /* 857 */ , 477 | 0xa7be29e7adbce118ULL /* 858 */ , 0xe544ee5cde8431ddULL /* 859 */ , 478 | 0x8a781b1b41f1873eULL /* 860 */ , 0xa5c94c78a0d2f0e7ULL /* 861 */ , 479 | 0x39412e2877b60728ULL /* 862 */ , 0xa1265ef3afc9a62cULL /* 863 */ , 480 | 0xbcc2770c6a2506c5ULL /* 864 */ , 0x3ab66dd5dce1ce12ULL /* 865 */ , 481 | 0xe65499d04a675b37ULL /* 866 */ , 0x7d8f523481bfd216ULL /* 867 */ , 482 | 0x0f6f64fcec15f389ULL /* 868 */ , 0x74efbe618b5b13c8ULL /* 869 */ , 483 | 0xacdc82b714273e1dULL /* 870 */ , 0xdd40bfe003199d17ULL /* 871 */ , 484 | 0x37e99257e7e061f8ULL /* 872 */ , 0xfa52626904775aaaULL /* 873 */ , 485 | 0x8bbbf63a463d56f9ULL /* 874 */ , 0xf0013f1543a26e64ULL /* 875 */ , 486 | 0xa8307e9f879ec898ULL /* 876 */ , 0xcc4c27a4150177ccULL /* 877 */ , 487 | 0x1b432f2cca1d3348ULL /* 878 */ , 0xde1d1f8f9f6fa013ULL /* 879 */ , 488 | 0x606602a047a7ddd6ULL /* 880 */ , 0xd237ab64cc1cb2c7ULL /* 881 */ , 489 | 0x9b938e7225fcd1d3ULL /* 882 */ , 0xec4e03708e0ff476ULL /* 883 */ , 490 | 0xfeb2fbda3d03c12dULL /* 884 */ , 0xae0bced2ee43889aULL /* 885 */ , 491 | 0x22cb8923ebfb4f43ULL /* 886 */ , 0x69360d013cf7396dULL /* 887 */ , 492 | 0x855e3602d2d4e022ULL /* 888 */ , 0x073805bad01f784cULL /* 889 */ , 493 | 0x33e17a133852f546ULL /* 890 */ , 0xdf4874058ac7b638ULL /* 891 */ , 494 | 0xba92b29c678aa14aULL /* 892 */ , 0x0ce89fc76cfaadcdULL /* 893 */ , 495 | 0x5f9d4e0908339e34ULL /* 894 */ , 0xf1afe9291f5923b9ULL /* 895 */ , 496 | 0x6e3480f60f4a265fULL /* 896 */ , 0xeebf3a2ab29b841cULL /* 897 */ , 497 | 0xe21938a88f91b4adULL /* 898 */ , 0x57dfeff845c6d3c3ULL /* 899 */ , 498 | 0x2f006b0bf62caaf2ULL /* 900 */ , 0x62f479ef6f75ee78ULL /* 901 */ , 499 | 0x11a55ad41c8916a9ULL /* 902 */ , 0xf229d29084fed453ULL /* 903 */ , 500 | 0x42f1c27b16b000e6ULL /* 904 */ , 0x2b1f76749823c074ULL /* 905 */ , 501 | 0x4b76eca3c2745360ULL /* 906 */ , 0x8c98f463b91691bdULL /* 907 */ , 502 | 0x14bcc93cf1ade66aULL /* 908 */ , 0x8885213e6d458397ULL /* 909 */ , 503 | 0x8e177df0274d4711ULL /* 910 */ , 0xb49b73b5503f2951ULL /* 911 */ , 504 | 0x10168168c3f96b6bULL /* 912 */ , 0x0e3d963b63cab0aeULL /* 913 */ , 505 | 0x8dfc4b5655a1db14ULL /* 914 */ , 0xf789f1356e14de5cULL /* 915 */ , 506 | 0x683e68af4e51dac1ULL /* 916 */ , 0xc9a84f9d8d4b0fd9ULL /* 917 */ , 507 | 0x3691e03f52a0f9d1ULL /* 918 */ , 0x5ed86e46e1878e80ULL /* 919 */ , 508 | 0x3c711a0e99d07150ULL /* 920 */ , 0x5a0865b20c4e9310ULL /* 921 */ , 509 | 0x56fbfc1fe4f0682eULL /* 922 */ , 0xea8d5de3105edf9bULL /* 923 */ , 510 | 0x71abfdb12379187aULL /* 924 */ , 0x2eb99de1bee77b9cULL /* 925 */ , 511 | 0x21ecc0ea33cf4523ULL /* 926 */ , 0x59a4d7521805c7a1ULL /* 927 */ , 512 | 0x3896f5eb56ae7c72ULL /* 928 */ , 0xaa638f3db18f75dcULL /* 929 */ , 513 | 0x9f39358dabe9808eULL /* 930 */ , 0xb7defa91c00b72acULL /* 931 */ , 514 | 0x6b5541fd62492d92ULL /* 932 */ , 0x6dc6dee8f92e4d5bULL /* 933 */ , 515 | 0x353f57abc4beea7eULL /* 934 */ , 0x735769d6da5690ceULL /* 935 */ , 516 | 0x0a234aa642391484ULL /* 936 */ , 0xf6f9508028f80d9dULL /* 937 */ , 517 | 0xb8e319a27ab3f215ULL /* 938 */ , 0x31ad9c1151341a4dULL /* 939 */ , 518 | 0x773c22a57bef5805ULL /* 940 */ , 0x45c7561a07968633ULL /* 941 */ , 519 | 0xf913da9e249dbe36ULL /* 942 */ , 0xda652d9b78a64c68ULL /* 943 */ , 520 | 0x4c27a97f3bc334efULL /* 944 */ , 0x76621220e66b17f4ULL /* 945 */ , 521 | 0x967743899acd7d0bULL /* 946 */ , 0xf3ee5bcae0ed6782ULL /* 947 */ , 522 | 0x409f753600c879fcULL /* 948 */ , 0x06d09a39b5926db6ULL /* 949 */ , 523 | 0x6f83aeb0317ac588ULL /* 950 */ , 0x01e6ca4a86381f21ULL /* 951 */ , 524 | 0x66ff3462d19f3025ULL /* 952 */ , 0x72207c24ddfd3bfbULL /* 953 */ , 525 | 0x4af6b6d3e2ece2ebULL /* 954 */ , 0x9c994dbec7ea08deULL /* 955 */ , 526 | 0x49ace597b09a8bc4ULL /* 956 */ , 0xb38c4766cf0797baULL /* 957 */ , 527 | 0x131b9373c57c2a75ULL /* 958 */ , 0xb1822cce61931e58ULL /* 959 */ , 528 | 0x9d7555b909ba1c0cULL /* 960 */ , 0x127fafdd937d11d2ULL /* 961 */ , 529 | 0x29da3badc66d92e4ULL /* 962 */ , 0xa2c1d57154c2ecbcULL /* 963 */ , 530 | 0x58c5134d82f6fe24ULL /* 964 */ , 0x1c3ae3515b62274fULL /* 965 */ , 531 | 0xe907c82e01cb8126ULL /* 966 */ , 0xf8ed091913e37fcbULL /* 967 */ , 532 | 0x3249d8f9c80046c9ULL /* 968 */ , 0x80cf9bede388fb63ULL /* 969 */ , 533 | 0x1881539a116cf19eULL /* 970 */ , 0x5103f3f76bd52457ULL /* 971 */ , 534 | 0x15b7e6f5ae47f7a8ULL /* 972 */ , 0xdbd7c6ded47e9ccfULL /* 973 */ , 535 | 0x44e55c410228bb1aULL /* 974 */ , 0xb647d4255edb4e99ULL /* 975 */ , 536 | 0x5d11882bb8aafc30ULL /* 976 */ , 0xf5098bbb29d3212aULL /* 977 */ , 537 | 0x8fb5ea14e90296b3ULL /* 978 */ , 0x677b942157dd025aULL /* 979 */ , 538 | 0xfb58e7c0a390acb5ULL /* 980 */ , 0x89d3674c83bd4a01ULL /* 981 */ , 539 | 0x9e2da4df4bf3b93bULL /* 982 */ , 0xfcc41e328cab4829ULL /* 983 */ , 540 | 0x03f38c96ba582c52ULL /* 984 */ , 0xcad1bdbd7fd85db2ULL /* 985 */ , 541 | 0xbbb442c16082ae83ULL /* 986 */ , 0xb95fe86ba5da9ab0ULL /* 987 */ , 542 | 0xb22e04673771a93fULL /* 988 */ , 0x845358c9493152d8ULL /* 989 */ , 543 | 0xbe2a488697b4541eULL /* 990 */ , 0x95a2dc2dd38e6966ULL /* 991 */ , 544 | 0xc02c11ac923c852bULL /* 992 */ , 0x2388b1990df2a87bULL /* 993 */ , 545 | 0x7c8008fa1b4f37beULL /* 994 */ , 0x1f70d0c84d54e503ULL /* 995 */ , 546 | 0x5490adec7ece57d4ULL /* 996 */ , 0x002b3c27d9063a3aULL /* 997 */ , 547 | 0x7eaea3848030a2bfULL /* 998 */ , 0xc602326ded2003c0ULL /* 999 */ , 548 | 0x83a7287d69a94086ULL /* 1000 */ , 0xc57a5fcb30f57a8aULL /* 1001 */ , 549 | 0xb56844e479ebe779ULL /* 1002 */ , 0xa373b40f05dcbce9ULL /* 1003 */ , 550 | 0xd71a786e88570ee2ULL /* 1004 */ , 0x879cbacdbde8f6a0ULL /* 1005 */ , 551 | 0x976ad1bcc164a32fULL /* 1006 */ , 0xab21e25e9666d78bULL /* 1007 */ , 552 | 0x901063aae5e5c33cULL /* 1008 */ , 0x9818b34448698d90ULL /* 1009 */ , 553 | 0xe36487ae3e1e8abbULL /* 1010 */ , 0xafbdf931893bdcb4ULL /* 1011 */ , 554 | 0x6345a0dc5fbbd519ULL /* 1012 */ , 0x8628fe269b9465caULL /* 1013 */ , 555 | 0x1e5d01603f9c51ecULL /* 1014 */ , 0x4de44006a15049b7ULL /* 1015 */ , 556 | 0xbf6c70e5f776cbb1ULL /* 1016 */ , 0x411218f2ef552bedULL /* 1017 */ , 557 | 0xcb0c0708705a36a3ULL /* 1018 */ , 0xe74d14754f986044ULL /* 1019 */ , 558 | 0xcd56d9430ea8280eULL /* 1020 */ , 0xc12591d7535f5065ULL /* 1021 */ , 559 | 0xc83223f1720aef96ULL /* 1022 */ , 0xc3a0396f7363a51fULL /* 1023 */ 560 | }; 561 | 562 | Tiger::Tiger() : context( new TIGER_CONTEXT ) {} 563 | 564 | Tiger::~Tiger() { 565 | delete context; 566 | context = NULL; 567 | } 568 | 569 | void Tiger::burn_stack( int bytes ) { 570 | char buf[256]; 571 | memset( buf, 0, sizeof buf ); 572 | bytes -= sizeof buf; 573 | if ( bytes > 0 ) 574 | burn_stack( bytes ); 575 | } 576 | 577 | void Tiger::init() { 578 | context->a = 0x0123456789abcdefLL; 579 | context->b = 0xfedcba9876543210LL; 580 | context->c = 0xf096a5b4c3b2e187LL; 581 | context->nblocks = 0; 582 | context->count = 0; 583 | } 584 | 585 | void Tiger::round( uint64_t* ra, uint64_t* rb, uint64_t* rc, uint64_t x, int mul ) { 586 | uint64_t a = *ra; 587 | uint64_t b = *rb; 588 | uint64_t c = *rc; 589 | 590 | c ^= x; 591 | a -= sbox1[c & 0xff] ^ sbox2[( c >> 16 ) & 0xff] 592 | ^ sbox3[( c >> 32 ) & 0xff] ^ sbox4[( c >> 48 ) & 0xff]; 593 | b += sbox4[( c >> 8 ) & 0xff] ^ sbox3[( c >> 24 ) & 0xff] 594 | ^ sbox2[( c >> 40 ) & 0xff] ^ sbox1[( c >> 56 ) & 0xff]; 595 | b *= mul; 596 | 597 | *ra = a; 598 | *rb = b; 599 | *rc = c; 600 | } 601 | 602 | void Tiger::pass( uint64_t* ra, uint64_t* rb, uint64_t* rc, uint64_t* x, int mul ) { 603 | uint64_t a = *ra; 604 | uint64_t b = *rb; 605 | uint64_t c = *rc; 606 | 607 | round( &a, &b, &c, x[0], mul ); 608 | round( &b, &c, &a, x[1], mul ); 609 | round( &c, &a, &b, x[2], mul ); 610 | round( &a, &b, &c, x[3], mul ); 611 | round( &b, &c, &a, x[4], mul ); 612 | round( &c, &a, &b, x[5], mul ); 613 | round( &a, &b, &c, x[6], mul ); 614 | round( &b, &c, &a, x[7], mul ); 615 | 616 | *ra = a; 617 | *rb = b; 618 | *rc = c; 619 | } 620 | 621 | void Tiger::key_schedule( uint64_t* x ) { 622 | x[0] -= x[7] ^ 0xa5a5a5a5a5a5a5a5LL; 623 | x[1] ^= x[0]; 624 | x[2] += x[1]; 625 | x[3] -= x[2] ^ ( ( ~x[1] ) << 19 ); 626 | x[4] ^= x[3]; 627 | x[5] += x[4]; 628 | x[6] -= x[5] ^ ( ( ~x[4] ) >> 23 ); 629 | x[7] ^= x[6]; 630 | x[0] += x[7]; 631 | x[1] -= x[0] ^ ( ( ~x[7] ) << 19 ); 632 | x[2] ^= x[1]; 633 | x[3] += x[2]; 634 | x[4] -= x[3] ^ ( ( ~x[2] ) >> 23 ); 635 | x[5] ^= x[4]; 636 | x[6] += x[5]; 637 | x[7] -= x[6] ^ 0x0123456789abcdefLL; 638 | } 639 | 640 | /**************** 641 | * Transform the message DATA which consists of 512 bytes (8 words) 642 | */ 643 | void Tiger::transform( const byte* data ) { 644 | uint64_t a, b, c, aa, bb, cc; 645 | uint64_t x[8]; 646 | #ifdef BIG_ENDIAN_HOST 647 | #define MKWORD(d,n) \ 648 | ( ((uint64_t)(d)[8*(n)+7]) << 56 | ((uint64_t)(d)[8*(n)+6]) << 48 \ 649 | | ((uint64_t)(d)[8*(n)+5]) << 40 | ((uint64_t)(d)[8*(n)+4]) << 32 \ 650 | | ((uint64_t)(d)[8*(n)+3]) << 24 | ((uint64_t)(d)[8*(n)+2]) << 16 \ 651 | | ((uint64_t)(d)[8*(n)+1]) << 8 | ((uint64_t)(d)[8*(n) ]) ) 652 | x[0] = MKWORD( data, 0 ); 653 | x[1] = MKWORD( data, 1 ); 654 | x[2] = MKWORD( data, 2 ); 655 | x[3] = MKWORD( data, 3 ); 656 | x[4] = MKWORD( data, 4 ); 657 | x[5] = MKWORD( data, 5 ); 658 | x[6] = MKWORD( data, 6 ); 659 | x[7] = MKWORD( data, 7 ); 660 | #undef MKWORD 661 | #else 662 | memcpy( &x[0], data, 64 ); 663 | #endif 664 | 665 | /* save */ 666 | a = aa = context->a; 667 | b = bb = context->b; 668 | c = cc = context->c; 669 | 670 | pass( &a, &b, &c, x, 5 ); 671 | key_schedule( x ); 672 | pass( &c, &a, &b, x, 7 ); 673 | key_schedule( x ); 674 | pass( &b, &c, &a, x, 9 ); 675 | 676 | /* feedforward */ 677 | a ^= aa; 678 | b -= bb; 679 | c += cc; 680 | /* store */ 681 | context->a = a; 682 | context->b = b; 683 | context->c = c; 684 | } 685 | 686 | /* Update the message digest with the contents 687 | * of INBUF with length INLEN. 688 | */ 689 | void Tiger::write( const byte* inbuf, int inlen ) { 690 | if ( context->count == 64 ) { /* flush the buffer */ 691 | transform( context->buf ); 692 | burn_stack( 21 * 8 + 11 * sizeof( void* ) ); 693 | context->count = 0; 694 | context->nblocks++; 695 | } 696 | if ( !inbuf ) 697 | return; 698 | if ( context->count ) { 699 | for ( ; inlen && context->count < 64; inlen-- ) 700 | context->buf[context->count++] = *inbuf++; 701 | write( NULL, 0 ); 702 | if ( !inlen ) 703 | return; 704 | } 705 | 706 | while ( inlen >= 64 ) { 707 | transform( inbuf ); 708 | context->count = 0; 709 | context->nblocks++; 710 | inlen -= 64; 711 | inbuf += 64; 712 | } 713 | burn_stack( 21 * 8 + 11 * sizeof( void* ) ); 714 | for ( ; inlen && context->count < 64; inlen-- ) 715 | context->buf[context->count++] = *inbuf++; 716 | } 717 | 718 | /* The routine terminates the computation 719 | */ 720 | byte* Tiger::final() { 721 | uint32_t t, msb, lsb; 722 | byte* p; 723 | 724 | write( NULL, 0 ); /* flush */ 725 | 726 | t = context->nblocks; 727 | /* multiply by 64 to make a byte count */ 728 | lsb = t << 6; 729 | msb = t >> 26; 730 | /* add the count */ 731 | t = lsb; 732 | if ( ( lsb += context->count ) < t ) 733 | msb++; 734 | /* multiply by 8 to make a bit count */ 735 | t = lsb; 736 | lsb <<= 3; 737 | msb <<= 3; 738 | msb |= t >> 29; 739 | 740 | if ( context->count < 56 ) { /* enough room */ 741 | context->buf[context->count++] = 0x01; /* pad */ 742 | while ( context->count < 56 ) 743 | context->buf[context->count++] = 0; /* pad */ 744 | } else { /* need one extra block */ 745 | context->buf[context->count++] = 0x01; /* pad character */ 746 | while ( context->count < 64 ) 747 | context->buf[context->count++] = 0; 748 | write( NULL, 0 ); /* flush */ 749 | memset( context->buf, 0, 56 ); /* fill next block with zeroes */ 750 | } 751 | /* append the 64 bit count */ 752 | context->buf[56] = lsb; 753 | context->buf[57] = lsb >> 8; 754 | context->buf[58] = lsb >> 16; 755 | context->buf[59] = lsb >> 24; 756 | context->buf[60] = msb; 757 | context->buf[61] = msb >> 8; 758 | context->buf[62] = msb >> 16; 759 | context->buf[63] = msb >> 24; 760 | transform( context->buf ); 761 | burn_stack( 21 * 8 + 11 * sizeof( void* ) ); 762 | 763 | p = context->buf; 764 | #ifdef BIG_ENDIAN_HOST 765 | #define X(a) do { *(uint64_t*)p = context->a ; p += 8; } while(0) 766 | #else /* little endian */ 767 | #define X(a) do { *p++ = context->a >> 56; *p++ = context->a >> 48; \ 768 | *p++ = context->a >> 40; *p++ = context->a >> 32; \ 769 | *p++ = context->a >> 24; *p++ = context->a >> 16; \ 770 | *p++ = context->a >> 8; *p++ = context->a; } while(0) 771 | #endif 772 | X( a ); 773 | X( b ); 774 | X( c ); 775 | #undef X 776 | return context->buf; 777 | } 778 | -------------------------------------------------------------------------------- /lib/src/whirlpool.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * The Whirlpool hashing function. 3 | * 4 | *

5 | * References 6 | * 7 | *

8 | * The Whirlpool algorithm was developed by 9 | * Paulo S. L. M. Barreto and 10 | * Vincent Rijmen. 11 | * 12 | * See 13 | * P.S.L.M. Barreto, V. Rijmen, 14 | * ``The Whirlpool hashing function,'' 15 | * NESSIE submission, 2000 (tweaked version, 2001), 16 | * 17 | * 18 | * @author Paulo S.L.M. Barreto 19 | * @author Vincent Rijmen. 20 | * 21 | * @version 3.0 (2003.03.12) 22 | * 23 | * ============================================================================= 24 | * 25 | * Differences from version 2.1: 26 | * 27 | * - Suboptimal diffusion matrix replaced by cir(1, 1, 4, 1, 8, 5, 2, 9). 28 | * 29 | * ============================================================================= 30 | * 31 | * Differences from version 2.0: 32 | * 33 | * - Generation of ISO/IEC 10118-3 test vectors. 34 | * - Bug fix: nonzero carry was ignored when tallying the data length 35 | * (this bug apparently only manifested itself when feeding data 36 | * in pieces rather than in a single chunk at once). 37 | * - Support for MS Visual C++ 64-bit integer arithmetic. 38 | * 39 | * Differences from version 1.0: 40 | * 41 | * - Original S-box replaced by the tweaked, hardware-efficient version. 42 | * 43 | * ============================================================================= 44 | * 45 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS 46 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 47 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 49 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 50 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 51 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 52 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 53 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 54 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 55 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 56 | * 57 | */ 58 | 59 | /* (C) 2015 Riccardo Ostani 60 | * Conversion from C to C++ of reference implementation of Whirlpool algorithm 61 | * 62 | * Main Changes: 63 | * + New Whirlpool class implementing HashAlgorithm 64 | * * Changed old C includes (i.e. ) to C++ equivalent (i.e. ) 65 | * * All functions moved to Whirlpool class 66 | * * Changed custom fixed-width integer types with the equivalent types of standard C++ 67 | * - Removed usages of LL macro: using ULL suffix 68 | * - Removed test functions 69 | */ 70 | 71 | #include "whirlpool.hpp" 72 | 73 | #include 74 | #include 75 | #include 76 | #include 77 | 78 | // The number of rounds of the internal dedicated block cipher. 79 | #define R 10 80 | 81 | /* 82 | * Though Whirlpool is endianness-neutral, the encryption tables are listed 83 | * in BIG-ENDIAN format, which is adopted throughout this implementation 84 | * (but little-endian notation would be equally suitable if consistently 85 | * employed). 86 | */ 87 | 88 | static const uint64_t C0[256] = { 89 | 0x18186018c07830d8ULL, 0x23238c2305af4626ULL, 0xc6c63fc67ef991b8ULL, 0xe8e887e8136fcdfbULL, 90 | 0x878726874ca113cbULL, 0xb8b8dab8a9626d11ULL, 0x0101040108050209ULL, 0x4f4f214f426e9e0dULL, 91 | 0x3636d836adee6c9bULL, 0xa6a6a2a6590451ffULL, 0xd2d26fd2debdb90cULL, 0xf5f5f3f5fb06f70eULL, 92 | 0x7979f979ef80f296ULL, 0x6f6fa16f5fcede30ULL, 0x91917e91fcef3f6dULL, 0x52525552aa07a4f8ULL, 93 | 0x60609d6027fdc047ULL, 0xbcbccabc89766535ULL, 0x9b9b569baccd2b37ULL, 0x8e8e028e048c018aULL, 94 | 0xa3a3b6a371155bd2ULL, 0x0c0c300c603c186cULL, 0x7b7bf17bff8af684ULL, 0x3535d435b5e16a80ULL, 95 | 0x1d1d741de8693af5ULL, 0xe0e0a7e05347ddb3ULL, 0xd7d77bd7f6acb321ULL, 0xc2c22fc25eed999cULL, 96 | 0x2e2eb82e6d965c43ULL, 0x4b4b314b627a9629ULL, 0xfefedffea321e15dULL, 0x575741578216aed5ULL, 97 | 0x15155415a8412abdULL, 0x7777c1779fb6eee8ULL, 0x3737dc37a5eb6e92ULL, 0xe5e5b3e57b56d79eULL, 98 | 0x9f9f469f8cd92313ULL, 0xf0f0e7f0d317fd23ULL, 0x4a4a354a6a7f9420ULL, 0xdada4fda9e95a944ULL, 99 | 0x58587d58fa25b0a2ULL, 0xc9c903c906ca8fcfULL, 0x2929a429558d527cULL, 0x0a0a280a5022145aULL, 100 | 0xb1b1feb1e14f7f50ULL, 0xa0a0baa0691a5dc9ULL, 0x6b6bb16b7fdad614ULL, 0x85852e855cab17d9ULL, 101 | 0xbdbdcebd8173673cULL, 0x5d5d695dd234ba8fULL, 0x1010401080502090ULL, 0xf4f4f7f4f303f507ULL, 102 | 0xcbcb0bcb16c08bddULL, 0x3e3ef83eedc67cd3ULL, 0x0505140528110a2dULL, 0x676781671fe6ce78ULL, 103 | 0xe4e4b7e47353d597ULL, 0x27279c2725bb4e02ULL, 0x4141194132588273ULL, 0x8b8b168b2c9d0ba7ULL, 104 | 0xa7a7a6a7510153f6ULL, 0x7d7de97dcf94fab2ULL, 0x95956e95dcfb3749ULL, 0xd8d847d88e9fad56ULL, 105 | 0xfbfbcbfb8b30eb70ULL, 0xeeee9fee2371c1cdULL, 0x7c7ced7cc791f8bbULL, 0x6666856617e3cc71ULL, 106 | 0xdddd53dda68ea77bULL, 0x17175c17b84b2eafULL, 0x4747014702468e45ULL, 0x9e9e429e84dc211aULL, 107 | 0xcaca0fca1ec589d4ULL, 0x2d2db42d75995a58ULL, 0xbfbfc6bf9179632eULL, 0x07071c07381b0e3fULL, 108 | 0xadad8ead012347acULL, 0x5a5a755aea2fb4b0ULL, 0x838336836cb51befULL, 0x3333cc3385ff66b6ULL, 109 | 0x636391633ff2c65cULL, 0x02020802100a0412ULL, 0xaaaa92aa39384993ULL, 0x7171d971afa8e2deULL, 110 | 0xc8c807c80ecf8dc6ULL, 0x19196419c87d32d1ULL, 0x494939497270923bULL, 0xd9d943d9869aaf5fULL, 111 | 0xf2f2eff2c31df931ULL, 0xe3e3abe34b48dba8ULL, 0x5b5b715be22ab6b9ULL, 0x88881a8834920dbcULL, 112 | 0x9a9a529aa4c8293eULL, 0x262698262dbe4c0bULL, 0x3232c8328dfa64bfULL, 0xb0b0fab0e94a7d59ULL, 113 | 0xe9e983e91b6acff2ULL, 0x0f0f3c0f78331e77ULL, 0xd5d573d5e6a6b733ULL, 0x80803a8074ba1df4ULL, 114 | 0xbebec2be997c6127ULL, 0xcdcd13cd26de87ebULL, 0x3434d034bde46889ULL, 0x48483d487a759032ULL, 115 | 0xffffdbffab24e354ULL, 0x7a7af57af78ff48dULL, 0x90907a90f4ea3d64ULL, 0x5f5f615fc23ebe9dULL, 116 | 0x202080201da0403dULL, 0x6868bd6867d5d00fULL, 0x1a1a681ad07234caULL, 0xaeae82ae192c41b7ULL, 117 | 0xb4b4eab4c95e757dULL, 0x54544d549a19a8ceULL, 0x93937693ece53b7fULL, 0x222288220daa442fULL, 118 | 0x64648d6407e9c863ULL, 0xf1f1e3f1db12ff2aULL, 0x7373d173bfa2e6ccULL, 0x12124812905a2482ULL, 119 | 0x40401d403a5d807aULL, 0x0808200840281048ULL, 0xc3c32bc356e89b95ULL, 0xecec97ec337bc5dfULL, 120 | 0xdbdb4bdb9690ab4dULL, 0xa1a1bea1611f5fc0ULL, 0x8d8d0e8d1c830791ULL, 0x3d3df43df5c97ac8ULL, 121 | 0x97976697ccf1335bULL, 0x0000000000000000ULL, 0xcfcf1bcf36d483f9ULL, 0x2b2bac2b4587566eULL, 122 | 0x7676c57697b3ece1ULL, 0x8282328264b019e6ULL, 0xd6d67fd6fea9b128ULL, 0x1b1b6c1bd87736c3ULL, 123 | 0xb5b5eeb5c15b7774ULL, 0xafaf86af112943beULL, 0x6a6ab56a77dfd41dULL, 0x50505d50ba0da0eaULL, 124 | 0x45450945124c8a57ULL, 0xf3f3ebf3cb18fb38ULL, 0x3030c0309df060adULL, 0xefef9bef2b74c3c4ULL, 125 | 0x3f3ffc3fe5c37edaULL, 0x55554955921caac7ULL, 0xa2a2b2a2791059dbULL, 0xeaea8fea0365c9e9ULL, 126 | 0x656589650fecca6aULL, 0xbabad2bab9686903ULL, 0x2f2fbc2f65935e4aULL, 0xc0c027c04ee79d8eULL, 127 | 0xdede5fdebe81a160ULL, 0x1c1c701ce06c38fcULL, 0xfdfdd3fdbb2ee746ULL, 0x4d4d294d52649a1fULL, 128 | 0x92927292e4e03976ULL, 0x7575c9758fbceafaULL, 0x06061806301e0c36ULL, 0x8a8a128a249809aeULL, 129 | 0xb2b2f2b2f940794bULL, 0xe6e6bfe66359d185ULL, 0x0e0e380e70361c7eULL, 0x1f1f7c1ff8633ee7ULL, 130 | 0x6262956237f7c455ULL, 0xd4d477d4eea3b53aULL, 0xa8a89aa829324d81ULL, 0x96966296c4f43152ULL, 131 | 0xf9f9c3f99b3aef62ULL, 0xc5c533c566f697a3ULL, 0x2525942535b14a10ULL, 0x59597959f220b2abULL, 132 | 0x84842a8454ae15d0ULL, 0x7272d572b7a7e4c5ULL, 0x3939e439d5dd72ecULL, 0x4c4c2d4c5a619816ULL, 133 | 0x5e5e655eca3bbc94ULL, 0x7878fd78e785f09fULL, 0x3838e038ddd870e5ULL, 0x8c8c0a8c14860598ULL, 134 | 0xd1d163d1c6b2bf17ULL, 0xa5a5aea5410b57e4ULL, 0xe2e2afe2434dd9a1ULL, 0x616199612ff8c24eULL, 135 | 0xb3b3f6b3f1457b42ULL, 0x2121842115a54234ULL, 0x9c9c4a9c94d62508ULL, 0x1e1e781ef0663ceeULL, 136 | 0x4343114322528661ULL, 0xc7c73bc776fc93b1ULL, 0xfcfcd7fcb32be54fULL, 0x0404100420140824ULL, 137 | 0x51515951b208a2e3ULL, 0x99995e99bcc72f25ULL, 0x6d6da96d4fc4da22ULL, 0x0d0d340d68391a65ULL, 138 | 0xfafacffa8335e979ULL, 0xdfdf5bdfb684a369ULL, 0x7e7ee57ed79bfca9ULL, 0x242490243db44819ULL, 139 | 0x3b3bec3bc5d776feULL, 0xabab96ab313d4b9aULL, 0xcece1fce3ed181f0ULL, 0x1111441188552299ULL, 140 | 0x8f8f068f0c890383ULL, 0x4e4e254e4a6b9c04ULL, 0xb7b7e6b7d1517366ULL, 0xebeb8beb0b60cbe0ULL, 141 | 0x3c3cf03cfdcc78c1ULL, 0x81813e817cbf1ffdULL, 0x94946a94d4fe3540ULL, 0xf7f7fbf7eb0cf31cULL, 142 | 0xb9b9deb9a1676f18ULL, 0x13134c13985f268bULL, 0x2c2cb02c7d9c5851ULL, 0xd3d36bd3d6b8bb05ULL, 143 | 0xe7e7bbe76b5cd38cULL, 0x6e6ea56e57cbdc39ULL, 0xc4c437c46ef395aaULL, 0x03030c03180f061bULL, 144 | 0x565645568a13acdcULL, 0x44440d441a49885eULL, 0x7f7fe17fdf9efea0ULL, 0xa9a99ea921374f88ULL, 145 | 0x2a2aa82a4d825467ULL, 0xbbbbd6bbb16d6b0aULL, 0xc1c123c146e29f87ULL, 0x53535153a202a6f1ULL, 146 | 0xdcdc57dcae8ba572ULL, 0x0b0b2c0b58271653ULL, 0x9d9d4e9d9cd32701ULL, 0x6c6cad6c47c1d82bULL, 147 | 0x3131c43195f562a4ULL, 0x7474cd7487b9e8f3ULL, 0xf6f6fff6e309f115ULL, 0x464605460a438c4cULL, 148 | 0xacac8aac092645a5ULL, 0x89891e893c970fb5ULL, 0x14145014a04428b4ULL, 0xe1e1a3e15b42dfbaULL, 149 | 0x16165816b04e2ca6ULL, 0x3a3ae83acdd274f7ULL, 0x6969b9696fd0d206ULL, 0x09092409482d1241ULL, 150 | 0x7070dd70a7ade0d7ULL, 0xb6b6e2b6d954716fULL, 0xd0d067d0ceb7bd1eULL, 0xeded93ed3b7ec7d6ULL, 151 | 0xcccc17cc2edb85e2ULL, 0x424215422a578468ULL, 0x98985a98b4c22d2cULL, 0xa4a4aaa4490e55edULL, 152 | 0x2828a0285d885075ULL, 0x5c5c6d5cda31b886ULL, 0xf8f8c7f8933fed6bULL, 0x8686228644a411c2ULL, 153 | }; 154 | 155 | static const uint64_t C1[256] = { 156 | 0xd818186018c07830ULL, 0x2623238c2305af46ULL, 0xb8c6c63fc67ef991ULL, 0xfbe8e887e8136fcdULL, 157 | 0xcb878726874ca113ULL, 0x11b8b8dab8a9626dULL, 0x0901010401080502ULL, 0x0d4f4f214f426e9eULL, 158 | 0x9b3636d836adee6cULL, 0xffa6a6a2a6590451ULL, 0x0cd2d26fd2debdb9ULL, 0x0ef5f5f3f5fb06f7ULL, 159 | 0x967979f979ef80f2ULL, 0x306f6fa16f5fcedeULL, 0x6d91917e91fcef3fULL, 0xf852525552aa07a4ULL, 160 | 0x4760609d6027fdc0ULL, 0x35bcbccabc897665ULL, 0x379b9b569baccd2bULL, 0x8a8e8e028e048c01ULL, 161 | 0xd2a3a3b6a371155bULL, 0x6c0c0c300c603c18ULL, 0x847b7bf17bff8af6ULL, 0x803535d435b5e16aULL, 162 | 0xf51d1d741de8693aULL, 0xb3e0e0a7e05347ddULL, 0x21d7d77bd7f6acb3ULL, 0x9cc2c22fc25eed99ULL, 163 | 0x432e2eb82e6d965cULL, 0x294b4b314b627a96ULL, 0x5dfefedffea321e1ULL, 0xd5575741578216aeULL, 164 | 0xbd15155415a8412aULL, 0xe87777c1779fb6eeULL, 0x923737dc37a5eb6eULL, 0x9ee5e5b3e57b56d7ULL, 165 | 0x139f9f469f8cd923ULL, 0x23f0f0e7f0d317fdULL, 0x204a4a354a6a7f94ULL, 0x44dada4fda9e95a9ULL, 166 | 0xa258587d58fa25b0ULL, 0xcfc9c903c906ca8fULL, 0x7c2929a429558d52ULL, 0x5a0a0a280a502214ULL, 167 | 0x50b1b1feb1e14f7fULL, 0xc9a0a0baa0691a5dULL, 0x146b6bb16b7fdad6ULL, 0xd985852e855cab17ULL, 168 | 0x3cbdbdcebd817367ULL, 0x8f5d5d695dd234baULL, 0x9010104010805020ULL, 0x07f4f4f7f4f303f5ULL, 169 | 0xddcbcb0bcb16c08bULL, 0xd33e3ef83eedc67cULL, 0x2d0505140528110aULL, 0x78676781671fe6ceULL, 170 | 0x97e4e4b7e47353d5ULL, 0x0227279c2725bb4eULL, 0x7341411941325882ULL, 0xa78b8b168b2c9d0bULL, 171 | 0xf6a7a7a6a7510153ULL, 0xb27d7de97dcf94faULL, 0x4995956e95dcfb37ULL, 0x56d8d847d88e9fadULL, 172 | 0x70fbfbcbfb8b30ebULL, 0xcdeeee9fee2371c1ULL, 0xbb7c7ced7cc791f8ULL, 0x716666856617e3ccULL, 173 | 0x7bdddd53dda68ea7ULL, 0xaf17175c17b84b2eULL, 0x454747014702468eULL, 0x1a9e9e429e84dc21ULL, 174 | 0xd4caca0fca1ec589ULL, 0x582d2db42d75995aULL, 0x2ebfbfc6bf917963ULL, 0x3f07071c07381b0eULL, 175 | 0xacadad8ead012347ULL, 0xb05a5a755aea2fb4ULL, 0xef838336836cb51bULL, 0xb63333cc3385ff66ULL, 176 | 0x5c636391633ff2c6ULL, 0x1202020802100a04ULL, 0x93aaaa92aa393849ULL, 0xde7171d971afa8e2ULL, 177 | 0xc6c8c807c80ecf8dULL, 0xd119196419c87d32ULL, 0x3b49493949727092ULL, 0x5fd9d943d9869aafULL, 178 | 0x31f2f2eff2c31df9ULL, 0xa8e3e3abe34b48dbULL, 0xb95b5b715be22ab6ULL, 0xbc88881a8834920dULL, 179 | 0x3e9a9a529aa4c829ULL, 0x0b262698262dbe4cULL, 0xbf3232c8328dfa64ULL, 0x59b0b0fab0e94a7dULL, 180 | 0xf2e9e983e91b6acfULL, 0x770f0f3c0f78331eULL, 0x33d5d573d5e6a6b7ULL, 0xf480803a8074ba1dULL, 181 | 0x27bebec2be997c61ULL, 0xebcdcd13cd26de87ULL, 0x893434d034bde468ULL, 0x3248483d487a7590ULL, 182 | 0x54ffffdbffab24e3ULL, 0x8d7a7af57af78ff4ULL, 0x6490907a90f4ea3dULL, 0x9d5f5f615fc23ebeULL, 183 | 0x3d202080201da040ULL, 0x0f6868bd6867d5d0ULL, 0xca1a1a681ad07234ULL, 0xb7aeae82ae192c41ULL, 184 | 0x7db4b4eab4c95e75ULL, 0xce54544d549a19a8ULL, 0x7f93937693ece53bULL, 0x2f222288220daa44ULL, 185 | 0x6364648d6407e9c8ULL, 0x2af1f1e3f1db12ffULL, 0xcc7373d173bfa2e6ULL, 0x8212124812905a24ULL, 186 | 0x7a40401d403a5d80ULL, 0x4808082008402810ULL, 0x95c3c32bc356e89bULL, 0xdfecec97ec337bc5ULL, 187 | 0x4ddbdb4bdb9690abULL, 0xc0a1a1bea1611f5fULL, 0x918d8d0e8d1c8307ULL, 0xc83d3df43df5c97aULL, 188 | 0x5b97976697ccf133ULL, 0x0000000000000000ULL, 0xf9cfcf1bcf36d483ULL, 0x6e2b2bac2b458756ULL, 189 | 0xe17676c57697b3ecULL, 0xe68282328264b019ULL, 0x28d6d67fd6fea9b1ULL, 0xc31b1b6c1bd87736ULL, 190 | 0x74b5b5eeb5c15b77ULL, 0xbeafaf86af112943ULL, 0x1d6a6ab56a77dfd4ULL, 0xea50505d50ba0da0ULL, 191 | 0x5745450945124c8aULL, 0x38f3f3ebf3cb18fbULL, 0xad3030c0309df060ULL, 0xc4efef9bef2b74c3ULL, 192 | 0xda3f3ffc3fe5c37eULL, 0xc755554955921caaULL, 0xdba2a2b2a2791059ULL, 0xe9eaea8fea0365c9ULL, 193 | 0x6a656589650feccaULL, 0x03babad2bab96869ULL, 0x4a2f2fbc2f65935eULL, 0x8ec0c027c04ee79dULL, 194 | 0x60dede5fdebe81a1ULL, 0xfc1c1c701ce06c38ULL, 0x46fdfdd3fdbb2ee7ULL, 0x1f4d4d294d52649aULL, 195 | 0x7692927292e4e039ULL, 0xfa7575c9758fbceaULL, 0x3606061806301e0cULL, 0xae8a8a128a249809ULL, 196 | 0x4bb2b2f2b2f94079ULL, 0x85e6e6bfe66359d1ULL, 0x7e0e0e380e70361cULL, 0xe71f1f7c1ff8633eULL, 197 | 0x556262956237f7c4ULL, 0x3ad4d477d4eea3b5ULL, 0x81a8a89aa829324dULL, 0x5296966296c4f431ULL, 198 | 0x62f9f9c3f99b3aefULL, 0xa3c5c533c566f697ULL, 0x102525942535b14aULL, 0xab59597959f220b2ULL, 199 | 0xd084842a8454ae15ULL, 0xc57272d572b7a7e4ULL, 0xec3939e439d5dd72ULL, 0x164c4c2d4c5a6198ULL, 200 | 0x945e5e655eca3bbcULL, 0x9f7878fd78e785f0ULL, 0xe53838e038ddd870ULL, 0x988c8c0a8c148605ULL, 201 | 0x17d1d163d1c6b2bfULL, 0xe4a5a5aea5410b57ULL, 0xa1e2e2afe2434dd9ULL, 0x4e616199612ff8c2ULL, 202 | 0x42b3b3f6b3f1457bULL, 0x342121842115a542ULL, 0x089c9c4a9c94d625ULL, 0xee1e1e781ef0663cULL, 203 | 0x6143431143225286ULL, 0xb1c7c73bc776fc93ULL, 0x4ffcfcd7fcb32be5ULL, 0x2404041004201408ULL, 204 | 0xe351515951b208a2ULL, 0x2599995e99bcc72fULL, 0x226d6da96d4fc4daULL, 0x650d0d340d68391aULL, 205 | 0x79fafacffa8335e9ULL, 0x69dfdf5bdfb684a3ULL, 0xa97e7ee57ed79bfcULL, 0x19242490243db448ULL, 206 | 0xfe3b3bec3bc5d776ULL, 0x9aabab96ab313d4bULL, 0xf0cece1fce3ed181ULL, 0x9911114411885522ULL, 207 | 0x838f8f068f0c8903ULL, 0x044e4e254e4a6b9cULL, 0x66b7b7e6b7d15173ULL, 0xe0ebeb8beb0b60cbULL, 208 | 0xc13c3cf03cfdcc78ULL, 0xfd81813e817cbf1fULL, 0x4094946a94d4fe35ULL, 0x1cf7f7fbf7eb0cf3ULL, 209 | 0x18b9b9deb9a1676fULL, 0x8b13134c13985f26ULL, 0x512c2cb02c7d9c58ULL, 0x05d3d36bd3d6b8bbULL, 210 | 0x8ce7e7bbe76b5cd3ULL, 0x396e6ea56e57cbdcULL, 0xaac4c437c46ef395ULL, 0x1b03030c03180f06ULL, 211 | 0xdc565645568a13acULL, 0x5e44440d441a4988ULL, 0xa07f7fe17fdf9efeULL, 0x88a9a99ea921374fULL, 212 | 0x672a2aa82a4d8254ULL, 0x0abbbbd6bbb16d6bULL, 0x87c1c123c146e29fULL, 0xf153535153a202a6ULL, 213 | 0x72dcdc57dcae8ba5ULL, 0x530b0b2c0b582716ULL, 0x019d9d4e9d9cd327ULL, 0x2b6c6cad6c47c1d8ULL, 214 | 0xa43131c43195f562ULL, 0xf37474cd7487b9e8ULL, 0x15f6f6fff6e309f1ULL, 0x4c464605460a438cULL, 215 | 0xa5acac8aac092645ULL, 0xb589891e893c970fULL, 0xb414145014a04428ULL, 0xbae1e1a3e15b42dfULL, 216 | 0xa616165816b04e2cULL, 0xf73a3ae83acdd274ULL, 0x066969b9696fd0d2ULL, 0x4109092409482d12ULL, 217 | 0xd77070dd70a7ade0ULL, 0x6fb6b6e2b6d95471ULL, 0x1ed0d067d0ceb7bdULL, 0xd6eded93ed3b7ec7ULL, 218 | 0xe2cccc17cc2edb85ULL, 0x68424215422a5784ULL, 0x2c98985a98b4c22dULL, 0xeda4a4aaa4490e55ULL, 219 | 0x752828a0285d8850ULL, 0x865c5c6d5cda31b8ULL, 0x6bf8f8c7f8933fedULL, 0xc28686228644a411ULL, 220 | }; 221 | 222 | static const uint64_t C2[256] = { 223 | 0x30d818186018c078ULL, 0x462623238c2305afULL, 0x91b8c6c63fc67ef9ULL, 0xcdfbe8e887e8136fULL, 224 | 0x13cb878726874ca1ULL, 0x6d11b8b8dab8a962ULL, 0x0209010104010805ULL, 0x9e0d4f4f214f426eULL, 225 | 0x6c9b3636d836adeeULL, 0x51ffa6a6a2a65904ULL, 0xb90cd2d26fd2debdULL, 0xf70ef5f5f3f5fb06ULL, 226 | 0xf2967979f979ef80ULL, 0xde306f6fa16f5fceULL, 0x3f6d91917e91fcefULL, 0xa4f852525552aa07ULL, 227 | 0xc04760609d6027fdULL, 0x6535bcbccabc8976ULL, 0x2b379b9b569baccdULL, 0x018a8e8e028e048cULL, 228 | 0x5bd2a3a3b6a37115ULL, 0x186c0c0c300c603cULL, 0xf6847b7bf17bff8aULL, 0x6a803535d435b5e1ULL, 229 | 0x3af51d1d741de869ULL, 0xddb3e0e0a7e05347ULL, 0xb321d7d77bd7f6acULL, 0x999cc2c22fc25eedULL, 230 | 0x5c432e2eb82e6d96ULL, 0x96294b4b314b627aULL, 0xe15dfefedffea321ULL, 0xaed5575741578216ULL, 231 | 0x2abd15155415a841ULL, 0xeee87777c1779fb6ULL, 0x6e923737dc37a5ebULL, 0xd79ee5e5b3e57b56ULL, 232 | 0x23139f9f469f8cd9ULL, 0xfd23f0f0e7f0d317ULL, 0x94204a4a354a6a7fULL, 0xa944dada4fda9e95ULL, 233 | 0xb0a258587d58fa25ULL, 0x8fcfc9c903c906caULL, 0x527c2929a429558dULL, 0x145a0a0a280a5022ULL, 234 | 0x7f50b1b1feb1e14fULL, 0x5dc9a0a0baa0691aULL, 0xd6146b6bb16b7fdaULL, 0x17d985852e855cabULL, 235 | 0x673cbdbdcebd8173ULL, 0xba8f5d5d695dd234ULL, 0x2090101040108050ULL, 0xf507f4f4f7f4f303ULL, 236 | 0x8bddcbcb0bcb16c0ULL, 0x7cd33e3ef83eedc6ULL, 0x0a2d050514052811ULL, 0xce78676781671fe6ULL, 237 | 0xd597e4e4b7e47353ULL, 0x4e0227279c2725bbULL, 0x8273414119413258ULL, 0x0ba78b8b168b2c9dULL, 238 | 0x53f6a7a7a6a75101ULL, 0xfab27d7de97dcf94ULL, 0x374995956e95dcfbULL, 0xad56d8d847d88e9fULL, 239 | 0xeb70fbfbcbfb8b30ULL, 0xc1cdeeee9fee2371ULL, 0xf8bb7c7ced7cc791ULL, 0xcc716666856617e3ULL, 240 | 0xa77bdddd53dda68eULL, 0x2eaf17175c17b84bULL, 0x8e45474701470246ULL, 0x211a9e9e429e84dcULL, 241 | 0x89d4caca0fca1ec5ULL, 0x5a582d2db42d7599ULL, 0x632ebfbfc6bf9179ULL, 0x0e3f07071c07381bULL, 242 | 0x47acadad8ead0123ULL, 0xb4b05a5a755aea2fULL, 0x1bef838336836cb5ULL, 0x66b63333cc3385ffULL, 243 | 0xc65c636391633ff2ULL, 0x041202020802100aULL, 0x4993aaaa92aa3938ULL, 0xe2de7171d971afa8ULL, 244 | 0x8dc6c8c807c80ecfULL, 0x32d119196419c87dULL, 0x923b494939497270ULL, 0xaf5fd9d943d9869aULL, 245 | 0xf931f2f2eff2c31dULL, 0xdba8e3e3abe34b48ULL, 0xb6b95b5b715be22aULL, 0x0dbc88881a883492ULL, 246 | 0x293e9a9a529aa4c8ULL, 0x4c0b262698262dbeULL, 0x64bf3232c8328dfaULL, 0x7d59b0b0fab0e94aULL, 247 | 0xcff2e9e983e91b6aULL, 0x1e770f0f3c0f7833ULL, 0xb733d5d573d5e6a6ULL, 0x1df480803a8074baULL, 248 | 0x6127bebec2be997cULL, 0x87ebcdcd13cd26deULL, 0x68893434d034bde4ULL, 0x903248483d487a75ULL, 249 | 0xe354ffffdbffab24ULL, 0xf48d7a7af57af78fULL, 0x3d6490907a90f4eaULL, 0xbe9d5f5f615fc23eULL, 250 | 0x403d202080201da0ULL, 0xd00f6868bd6867d5ULL, 0x34ca1a1a681ad072ULL, 0x41b7aeae82ae192cULL, 251 | 0x757db4b4eab4c95eULL, 0xa8ce54544d549a19ULL, 0x3b7f93937693ece5ULL, 0x442f222288220daaULL, 252 | 0xc86364648d6407e9ULL, 0xff2af1f1e3f1db12ULL, 0xe6cc7373d173bfa2ULL, 0x248212124812905aULL, 253 | 0x807a40401d403a5dULL, 0x1048080820084028ULL, 0x9b95c3c32bc356e8ULL, 0xc5dfecec97ec337bULL, 254 | 0xab4ddbdb4bdb9690ULL, 0x5fc0a1a1bea1611fULL, 0x07918d8d0e8d1c83ULL, 0x7ac83d3df43df5c9ULL, 255 | 0x335b97976697ccf1ULL, 0x0000000000000000ULL, 0x83f9cfcf1bcf36d4ULL, 0x566e2b2bac2b4587ULL, 256 | 0xece17676c57697b3ULL, 0x19e68282328264b0ULL, 0xb128d6d67fd6fea9ULL, 0x36c31b1b6c1bd877ULL, 257 | 0x7774b5b5eeb5c15bULL, 0x43beafaf86af1129ULL, 0xd41d6a6ab56a77dfULL, 0xa0ea50505d50ba0dULL, 258 | 0x8a5745450945124cULL, 0xfb38f3f3ebf3cb18ULL, 0x60ad3030c0309df0ULL, 0xc3c4efef9bef2b74ULL, 259 | 0x7eda3f3ffc3fe5c3ULL, 0xaac755554955921cULL, 0x59dba2a2b2a27910ULL, 0xc9e9eaea8fea0365ULL, 260 | 0xca6a656589650fecULL, 0x6903babad2bab968ULL, 0x5e4a2f2fbc2f6593ULL, 0x9d8ec0c027c04ee7ULL, 261 | 0xa160dede5fdebe81ULL, 0x38fc1c1c701ce06cULL, 0xe746fdfdd3fdbb2eULL, 0x9a1f4d4d294d5264ULL, 262 | 0x397692927292e4e0ULL, 0xeafa7575c9758fbcULL, 0x0c3606061806301eULL, 0x09ae8a8a128a2498ULL, 263 | 0x794bb2b2f2b2f940ULL, 0xd185e6e6bfe66359ULL, 0x1c7e0e0e380e7036ULL, 0x3ee71f1f7c1ff863ULL, 264 | 0xc4556262956237f7ULL, 0xb53ad4d477d4eea3ULL, 0x4d81a8a89aa82932ULL, 0x315296966296c4f4ULL, 265 | 0xef62f9f9c3f99b3aULL, 0x97a3c5c533c566f6ULL, 0x4a102525942535b1ULL, 0xb2ab59597959f220ULL, 266 | 0x15d084842a8454aeULL, 0xe4c57272d572b7a7ULL, 0x72ec3939e439d5ddULL, 0x98164c4c2d4c5a61ULL, 267 | 0xbc945e5e655eca3bULL, 0xf09f7878fd78e785ULL, 0x70e53838e038ddd8ULL, 0x05988c8c0a8c1486ULL, 268 | 0xbf17d1d163d1c6b2ULL, 0x57e4a5a5aea5410bULL, 0xd9a1e2e2afe2434dULL, 0xc24e616199612ff8ULL, 269 | 0x7b42b3b3f6b3f145ULL, 0x42342121842115a5ULL, 0x25089c9c4a9c94d6ULL, 0x3cee1e1e781ef066ULL, 270 | 0x8661434311432252ULL, 0x93b1c7c73bc776fcULL, 0xe54ffcfcd7fcb32bULL, 0x0824040410042014ULL, 271 | 0xa2e351515951b208ULL, 0x2f2599995e99bcc7ULL, 0xda226d6da96d4fc4ULL, 0x1a650d0d340d6839ULL, 272 | 0xe979fafacffa8335ULL, 0xa369dfdf5bdfb684ULL, 0xfca97e7ee57ed79bULL, 0x4819242490243db4ULL, 273 | 0x76fe3b3bec3bc5d7ULL, 0x4b9aabab96ab313dULL, 0x81f0cece1fce3ed1ULL, 0x2299111144118855ULL, 274 | 0x03838f8f068f0c89ULL, 0x9c044e4e254e4a6bULL, 0x7366b7b7e6b7d151ULL, 0xcbe0ebeb8beb0b60ULL, 275 | 0x78c13c3cf03cfdccULL, 0x1ffd81813e817cbfULL, 0x354094946a94d4feULL, 0xf31cf7f7fbf7eb0cULL, 276 | 0x6f18b9b9deb9a167ULL, 0x268b13134c13985fULL, 0x58512c2cb02c7d9cULL, 0xbb05d3d36bd3d6b8ULL, 277 | 0xd38ce7e7bbe76b5cULL, 0xdc396e6ea56e57cbULL, 0x95aac4c437c46ef3ULL, 0x061b03030c03180fULL, 278 | 0xacdc565645568a13ULL, 0x885e44440d441a49ULL, 0xfea07f7fe17fdf9eULL, 0x4f88a9a99ea92137ULL, 279 | 0x54672a2aa82a4d82ULL, 0x6b0abbbbd6bbb16dULL, 0x9f87c1c123c146e2ULL, 0xa6f153535153a202ULL, 280 | 0xa572dcdc57dcae8bULL, 0x16530b0b2c0b5827ULL, 0x27019d9d4e9d9cd3ULL, 0xd82b6c6cad6c47c1ULL, 281 | 0x62a43131c43195f5ULL, 0xe8f37474cd7487b9ULL, 0xf115f6f6fff6e309ULL, 0x8c4c464605460a43ULL, 282 | 0x45a5acac8aac0926ULL, 0x0fb589891e893c97ULL, 0x28b414145014a044ULL, 0xdfbae1e1a3e15b42ULL, 283 | 0x2ca616165816b04eULL, 0x74f73a3ae83acdd2ULL, 0xd2066969b9696fd0ULL, 0x124109092409482dULL, 284 | 0xe0d77070dd70a7adULL, 0x716fb6b6e2b6d954ULL, 0xbd1ed0d067d0ceb7ULL, 0xc7d6eded93ed3b7eULL, 285 | 0x85e2cccc17cc2edbULL, 0x8468424215422a57ULL, 0x2d2c98985a98b4c2ULL, 0x55eda4a4aaa4490eULL, 286 | 0x50752828a0285d88ULL, 0xb8865c5c6d5cda31ULL, 0xed6bf8f8c7f8933fULL, 0x11c28686228644a4ULL, 287 | }; 288 | 289 | static const uint64_t C3[256] = { 290 | 0x7830d818186018c0ULL, 0xaf462623238c2305ULL, 0xf991b8c6c63fc67eULL, 0x6fcdfbe8e887e813ULL, 291 | 0xa113cb878726874cULL, 0x626d11b8b8dab8a9ULL, 0x0502090101040108ULL, 0x6e9e0d4f4f214f42ULL, 292 | 0xee6c9b3636d836adULL, 0x0451ffa6a6a2a659ULL, 0xbdb90cd2d26fd2deULL, 0x06f70ef5f5f3f5fbULL, 293 | 0x80f2967979f979efULL, 0xcede306f6fa16f5fULL, 0xef3f6d91917e91fcULL, 0x07a4f852525552aaULL, 294 | 0xfdc04760609d6027ULL, 0x766535bcbccabc89ULL, 0xcd2b379b9b569bacULL, 0x8c018a8e8e028e04ULL, 295 | 0x155bd2a3a3b6a371ULL, 0x3c186c0c0c300c60ULL, 0x8af6847b7bf17bffULL, 0xe16a803535d435b5ULL, 296 | 0x693af51d1d741de8ULL, 0x47ddb3e0e0a7e053ULL, 0xacb321d7d77bd7f6ULL, 0xed999cc2c22fc25eULL, 297 | 0x965c432e2eb82e6dULL, 0x7a96294b4b314b62ULL, 0x21e15dfefedffea3ULL, 0x16aed55757415782ULL, 298 | 0x412abd15155415a8ULL, 0xb6eee87777c1779fULL, 0xeb6e923737dc37a5ULL, 0x56d79ee5e5b3e57bULL, 299 | 0xd923139f9f469f8cULL, 0x17fd23f0f0e7f0d3ULL, 0x7f94204a4a354a6aULL, 0x95a944dada4fda9eULL, 300 | 0x25b0a258587d58faULL, 0xca8fcfc9c903c906ULL, 0x8d527c2929a42955ULL, 0x22145a0a0a280a50ULL, 301 | 0x4f7f50b1b1feb1e1ULL, 0x1a5dc9a0a0baa069ULL, 0xdad6146b6bb16b7fULL, 0xab17d985852e855cULL, 302 | 0x73673cbdbdcebd81ULL, 0x34ba8f5d5d695dd2ULL, 0x5020901010401080ULL, 0x03f507f4f4f7f4f3ULL, 303 | 0xc08bddcbcb0bcb16ULL, 0xc67cd33e3ef83eedULL, 0x110a2d0505140528ULL, 0xe6ce78676781671fULL, 304 | 0x53d597e4e4b7e473ULL, 0xbb4e0227279c2725ULL, 0x5882734141194132ULL, 0x9d0ba78b8b168b2cULL, 305 | 0x0153f6a7a7a6a751ULL, 0x94fab27d7de97dcfULL, 0xfb374995956e95dcULL, 0x9fad56d8d847d88eULL, 306 | 0x30eb70fbfbcbfb8bULL, 0x71c1cdeeee9fee23ULL, 0x91f8bb7c7ced7cc7ULL, 0xe3cc716666856617ULL, 307 | 0x8ea77bdddd53dda6ULL, 0x4b2eaf17175c17b8ULL, 0x468e454747014702ULL, 0xdc211a9e9e429e84ULL, 308 | 0xc589d4caca0fca1eULL, 0x995a582d2db42d75ULL, 0x79632ebfbfc6bf91ULL, 0x1b0e3f07071c0738ULL, 309 | 0x2347acadad8ead01ULL, 0x2fb4b05a5a755aeaULL, 0xb51bef838336836cULL, 0xff66b63333cc3385ULL, 310 | 0xf2c65c636391633fULL, 0x0a04120202080210ULL, 0x384993aaaa92aa39ULL, 0xa8e2de7171d971afULL, 311 | 0xcf8dc6c8c807c80eULL, 0x7d32d119196419c8ULL, 0x70923b4949394972ULL, 0x9aaf5fd9d943d986ULL, 312 | 0x1df931f2f2eff2c3ULL, 0x48dba8e3e3abe34bULL, 0x2ab6b95b5b715be2ULL, 0x920dbc88881a8834ULL, 313 | 0xc8293e9a9a529aa4ULL, 0xbe4c0b262698262dULL, 0xfa64bf3232c8328dULL, 0x4a7d59b0b0fab0e9ULL, 314 | 0x6acff2e9e983e91bULL, 0x331e770f0f3c0f78ULL, 0xa6b733d5d573d5e6ULL, 0xba1df480803a8074ULL, 315 | 0x7c6127bebec2be99ULL, 0xde87ebcdcd13cd26ULL, 0xe468893434d034bdULL, 0x75903248483d487aULL, 316 | 0x24e354ffffdbffabULL, 0x8ff48d7a7af57af7ULL, 0xea3d6490907a90f4ULL, 0x3ebe9d5f5f615fc2ULL, 317 | 0xa0403d202080201dULL, 0xd5d00f6868bd6867ULL, 0x7234ca1a1a681ad0ULL, 0x2c41b7aeae82ae19ULL, 318 | 0x5e757db4b4eab4c9ULL, 0x19a8ce54544d549aULL, 0xe53b7f93937693ecULL, 0xaa442f222288220dULL, 319 | 0xe9c86364648d6407ULL, 0x12ff2af1f1e3f1dbULL, 0xa2e6cc7373d173bfULL, 0x5a24821212481290ULL, 320 | 0x5d807a40401d403aULL, 0x2810480808200840ULL, 0xe89b95c3c32bc356ULL, 0x7bc5dfecec97ec33ULL, 321 | 0x90ab4ddbdb4bdb96ULL, 0x1f5fc0a1a1bea161ULL, 0x8307918d8d0e8d1cULL, 0xc97ac83d3df43df5ULL, 322 | 0xf1335b97976697ccULL, 0x0000000000000000ULL, 0xd483f9cfcf1bcf36ULL, 0x87566e2b2bac2b45ULL, 323 | 0xb3ece17676c57697ULL, 0xb019e68282328264ULL, 0xa9b128d6d67fd6feULL, 0x7736c31b1b6c1bd8ULL, 324 | 0x5b7774b5b5eeb5c1ULL, 0x2943beafaf86af11ULL, 0xdfd41d6a6ab56a77ULL, 0x0da0ea50505d50baULL, 325 | 0x4c8a574545094512ULL, 0x18fb38f3f3ebf3cbULL, 0xf060ad3030c0309dULL, 0x74c3c4efef9bef2bULL, 326 | 0xc37eda3f3ffc3fe5ULL, 0x1caac75555495592ULL, 0x1059dba2a2b2a279ULL, 0x65c9e9eaea8fea03ULL, 327 | 0xecca6a656589650fULL, 0x686903babad2bab9ULL, 0x935e4a2f2fbc2f65ULL, 0xe79d8ec0c027c04eULL, 328 | 0x81a160dede5fdebeULL, 0x6c38fc1c1c701ce0ULL, 0x2ee746fdfdd3fdbbULL, 0x649a1f4d4d294d52ULL, 329 | 0xe0397692927292e4ULL, 0xbceafa7575c9758fULL, 0x1e0c360606180630ULL, 0x9809ae8a8a128a24ULL, 330 | 0x40794bb2b2f2b2f9ULL, 0x59d185e6e6bfe663ULL, 0x361c7e0e0e380e70ULL, 0x633ee71f1f7c1ff8ULL, 331 | 0xf7c4556262956237ULL, 0xa3b53ad4d477d4eeULL, 0x324d81a8a89aa829ULL, 0xf4315296966296c4ULL, 332 | 0x3aef62f9f9c3f99bULL, 0xf697a3c5c533c566ULL, 0xb14a102525942535ULL, 0x20b2ab59597959f2ULL, 333 | 0xae15d084842a8454ULL, 0xa7e4c57272d572b7ULL, 0xdd72ec3939e439d5ULL, 0x6198164c4c2d4c5aULL, 334 | 0x3bbc945e5e655ecaULL, 0x85f09f7878fd78e7ULL, 0xd870e53838e038ddULL, 0x8605988c8c0a8c14ULL, 335 | 0xb2bf17d1d163d1c6ULL, 0x0b57e4a5a5aea541ULL, 0x4dd9a1e2e2afe243ULL, 0xf8c24e616199612fULL, 336 | 0x457b42b3b3f6b3f1ULL, 0xa542342121842115ULL, 0xd625089c9c4a9c94ULL, 0x663cee1e1e781ef0ULL, 337 | 0x5286614343114322ULL, 0xfc93b1c7c73bc776ULL, 0x2be54ffcfcd7fcb3ULL, 0x1408240404100420ULL, 338 | 0x08a2e351515951b2ULL, 0xc72f2599995e99bcULL, 0xc4da226d6da96d4fULL, 0x391a650d0d340d68ULL, 339 | 0x35e979fafacffa83ULL, 0x84a369dfdf5bdfb6ULL, 0x9bfca97e7ee57ed7ULL, 0xb44819242490243dULL, 340 | 0xd776fe3b3bec3bc5ULL, 0x3d4b9aabab96ab31ULL, 0xd181f0cece1fce3eULL, 0x5522991111441188ULL, 341 | 0x8903838f8f068f0cULL, 0x6b9c044e4e254e4aULL, 0x517366b7b7e6b7d1ULL, 0x60cbe0ebeb8beb0bULL, 342 | 0xcc78c13c3cf03cfdULL, 0xbf1ffd81813e817cULL, 0xfe354094946a94d4ULL, 0x0cf31cf7f7fbf7ebULL, 343 | 0x676f18b9b9deb9a1ULL, 0x5f268b13134c1398ULL, 0x9c58512c2cb02c7dULL, 0xb8bb05d3d36bd3d6ULL, 344 | 0x5cd38ce7e7bbe76bULL, 0xcbdc396e6ea56e57ULL, 0xf395aac4c437c46eULL, 0x0f061b03030c0318ULL, 345 | 0x13acdc565645568aULL, 0x49885e44440d441aULL, 0x9efea07f7fe17fdfULL, 0x374f88a9a99ea921ULL, 346 | 0x8254672a2aa82a4dULL, 0x6d6b0abbbbd6bbb1ULL, 0xe29f87c1c123c146ULL, 0x02a6f153535153a2ULL, 347 | 0x8ba572dcdc57dcaeULL, 0x2716530b0b2c0b58ULL, 0xd327019d9d4e9d9cULL, 0xc1d82b6c6cad6c47ULL, 348 | 0xf562a43131c43195ULL, 0xb9e8f37474cd7487ULL, 0x09f115f6f6fff6e3ULL, 0x438c4c464605460aULL, 349 | 0x2645a5acac8aac09ULL, 0x970fb589891e893cULL, 0x4428b414145014a0ULL, 0x42dfbae1e1a3e15bULL, 350 | 0x4e2ca616165816b0ULL, 0xd274f73a3ae83acdULL, 0xd0d2066969b9696fULL, 0x2d12410909240948ULL, 351 | 0xade0d77070dd70a7ULL, 0x54716fb6b6e2b6d9ULL, 0xb7bd1ed0d067d0ceULL, 0x7ec7d6eded93ed3bULL, 352 | 0xdb85e2cccc17cc2eULL, 0x578468424215422aULL, 0xc22d2c98985a98b4ULL, 0x0e55eda4a4aaa449ULL, 353 | 0x8850752828a0285dULL, 0x31b8865c5c6d5cdaULL, 0x3fed6bf8f8c7f893ULL, 0xa411c28686228644ULL, 354 | }; 355 | 356 | static const uint64_t C4[256] = { 357 | 0xc07830d818186018ULL, 0x05af462623238c23ULL, 0x7ef991b8c6c63fc6ULL, 0x136fcdfbe8e887e8ULL, 358 | 0x4ca113cb87872687ULL, 0xa9626d11b8b8dab8ULL, 0x0805020901010401ULL, 0x426e9e0d4f4f214fULL, 359 | 0xadee6c9b3636d836ULL, 0x590451ffa6a6a2a6ULL, 0xdebdb90cd2d26fd2ULL, 0xfb06f70ef5f5f3f5ULL, 360 | 0xef80f2967979f979ULL, 0x5fcede306f6fa16fULL, 0xfcef3f6d91917e91ULL, 0xaa07a4f852525552ULL, 361 | 0x27fdc04760609d60ULL, 0x89766535bcbccabcULL, 0xaccd2b379b9b569bULL, 0x048c018a8e8e028eULL, 362 | 0x71155bd2a3a3b6a3ULL, 0x603c186c0c0c300cULL, 0xff8af6847b7bf17bULL, 0xb5e16a803535d435ULL, 363 | 0xe8693af51d1d741dULL, 0x5347ddb3e0e0a7e0ULL, 0xf6acb321d7d77bd7ULL, 0x5eed999cc2c22fc2ULL, 364 | 0x6d965c432e2eb82eULL, 0x627a96294b4b314bULL, 0xa321e15dfefedffeULL, 0x8216aed557574157ULL, 365 | 0xa8412abd15155415ULL, 0x9fb6eee87777c177ULL, 0xa5eb6e923737dc37ULL, 0x7b56d79ee5e5b3e5ULL, 366 | 0x8cd923139f9f469fULL, 0xd317fd23f0f0e7f0ULL, 0x6a7f94204a4a354aULL, 0x9e95a944dada4fdaULL, 367 | 0xfa25b0a258587d58ULL, 0x06ca8fcfc9c903c9ULL, 0x558d527c2929a429ULL, 0x5022145a0a0a280aULL, 368 | 0xe14f7f50b1b1feb1ULL, 0x691a5dc9a0a0baa0ULL, 0x7fdad6146b6bb16bULL, 0x5cab17d985852e85ULL, 369 | 0x8173673cbdbdcebdULL, 0xd234ba8f5d5d695dULL, 0x8050209010104010ULL, 0xf303f507f4f4f7f4ULL, 370 | 0x16c08bddcbcb0bcbULL, 0xedc67cd33e3ef83eULL, 0x28110a2d05051405ULL, 0x1fe6ce7867678167ULL, 371 | 0x7353d597e4e4b7e4ULL, 0x25bb4e0227279c27ULL, 0x3258827341411941ULL, 0x2c9d0ba78b8b168bULL, 372 | 0x510153f6a7a7a6a7ULL, 0xcf94fab27d7de97dULL, 0xdcfb374995956e95ULL, 0x8e9fad56d8d847d8ULL, 373 | 0x8b30eb70fbfbcbfbULL, 0x2371c1cdeeee9feeULL, 0xc791f8bb7c7ced7cULL, 0x17e3cc7166668566ULL, 374 | 0xa68ea77bdddd53ddULL, 0xb84b2eaf17175c17ULL, 0x02468e4547470147ULL, 0x84dc211a9e9e429eULL, 375 | 0x1ec589d4caca0fcaULL, 0x75995a582d2db42dULL, 0x9179632ebfbfc6bfULL, 0x381b0e3f07071c07ULL, 376 | 0x012347acadad8eadULL, 0xea2fb4b05a5a755aULL, 0x6cb51bef83833683ULL, 0x85ff66b63333cc33ULL, 377 | 0x3ff2c65c63639163ULL, 0x100a041202020802ULL, 0x39384993aaaa92aaULL, 0xafa8e2de7171d971ULL, 378 | 0x0ecf8dc6c8c807c8ULL, 0xc87d32d119196419ULL, 0x7270923b49493949ULL, 0x869aaf5fd9d943d9ULL, 379 | 0xc31df931f2f2eff2ULL, 0x4b48dba8e3e3abe3ULL, 0xe22ab6b95b5b715bULL, 0x34920dbc88881a88ULL, 380 | 0xa4c8293e9a9a529aULL, 0x2dbe4c0b26269826ULL, 0x8dfa64bf3232c832ULL, 0xe94a7d59b0b0fab0ULL, 381 | 0x1b6acff2e9e983e9ULL, 0x78331e770f0f3c0fULL, 0xe6a6b733d5d573d5ULL, 0x74ba1df480803a80ULL, 382 | 0x997c6127bebec2beULL, 0x26de87ebcdcd13cdULL, 0xbde468893434d034ULL, 0x7a75903248483d48ULL, 383 | 0xab24e354ffffdbffULL, 0xf78ff48d7a7af57aULL, 0xf4ea3d6490907a90ULL, 0xc23ebe9d5f5f615fULL, 384 | 0x1da0403d20208020ULL, 0x67d5d00f6868bd68ULL, 0xd07234ca1a1a681aULL, 0x192c41b7aeae82aeULL, 385 | 0xc95e757db4b4eab4ULL, 0x9a19a8ce54544d54ULL, 0xece53b7f93937693ULL, 0x0daa442f22228822ULL, 386 | 0x07e9c86364648d64ULL, 0xdb12ff2af1f1e3f1ULL, 0xbfa2e6cc7373d173ULL, 0x905a248212124812ULL, 387 | 0x3a5d807a40401d40ULL, 0x4028104808082008ULL, 0x56e89b95c3c32bc3ULL, 0x337bc5dfecec97ecULL, 388 | 0x9690ab4ddbdb4bdbULL, 0x611f5fc0a1a1bea1ULL, 0x1c8307918d8d0e8dULL, 0xf5c97ac83d3df43dULL, 389 | 0xccf1335b97976697ULL, 0x0000000000000000ULL, 0x36d483f9cfcf1bcfULL, 0x4587566e2b2bac2bULL, 390 | 0x97b3ece17676c576ULL, 0x64b019e682823282ULL, 0xfea9b128d6d67fd6ULL, 0xd87736c31b1b6c1bULL, 391 | 0xc15b7774b5b5eeb5ULL, 0x112943beafaf86afULL, 0x77dfd41d6a6ab56aULL, 0xba0da0ea50505d50ULL, 392 | 0x124c8a5745450945ULL, 0xcb18fb38f3f3ebf3ULL, 0x9df060ad3030c030ULL, 0x2b74c3c4efef9befULL, 393 | 0xe5c37eda3f3ffc3fULL, 0x921caac755554955ULL, 0x791059dba2a2b2a2ULL, 0x0365c9e9eaea8feaULL, 394 | 0x0fecca6a65658965ULL, 0xb9686903babad2baULL, 0x65935e4a2f2fbc2fULL, 0x4ee79d8ec0c027c0ULL, 395 | 0xbe81a160dede5fdeULL, 0xe06c38fc1c1c701cULL, 0xbb2ee746fdfdd3fdULL, 0x52649a1f4d4d294dULL, 396 | 0xe4e0397692927292ULL, 0x8fbceafa7575c975ULL, 0x301e0c3606061806ULL, 0x249809ae8a8a128aULL, 397 | 0xf940794bb2b2f2b2ULL, 0x6359d185e6e6bfe6ULL, 0x70361c7e0e0e380eULL, 0xf8633ee71f1f7c1fULL, 398 | 0x37f7c45562629562ULL, 0xeea3b53ad4d477d4ULL, 0x29324d81a8a89aa8ULL, 0xc4f4315296966296ULL, 399 | 0x9b3aef62f9f9c3f9ULL, 0x66f697a3c5c533c5ULL, 0x35b14a1025259425ULL, 0xf220b2ab59597959ULL, 400 | 0x54ae15d084842a84ULL, 0xb7a7e4c57272d572ULL, 0xd5dd72ec3939e439ULL, 0x5a6198164c4c2d4cULL, 401 | 0xca3bbc945e5e655eULL, 0xe785f09f7878fd78ULL, 0xddd870e53838e038ULL, 0x148605988c8c0a8cULL, 402 | 0xc6b2bf17d1d163d1ULL, 0x410b57e4a5a5aea5ULL, 0x434dd9a1e2e2afe2ULL, 0x2ff8c24e61619961ULL, 403 | 0xf1457b42b3b3f6b3ULL, 0x15a5423421218421ULL, 0x94d625089c9c4a9cULL, 0xf0663cee1e1e781eULL, 404 | 0x2252866143431143ULL, 0x76fc93b1c7c73bc7ULL, 0xb32be54ffcfcd7fcULL, 0x2014082404041004ULL, 405 | 0xb208a2e351515951ULL, 0xbcc72f2599995e99ULL, 0x4fc4da226d6da96dULL, 0x68391a650d0d340dULL, 406 | 0x8335e979fafacffaULL, 0xb684a369dfdf5bdfULL, 0xd79bfca97e7ee57eULL, 0x3db4481924249024ULL, 407 | 0xc5d776fe3b3bec3bULL, 0x313d4b9aabab96abULL, 0x3ed181f0cece1fceULL, 0x8855229911114411ULL, 408 | 0x0c8903838f8f068fULL, 0x4a6b9c044e4e254eULL, 0xd1517366b7b7e6b7ULL, 0x0b60cbe0ebeb8bebULL, 409 | 0xfdcc78c13c3cf03cULL, 0x7cbf1ffd81813e81ULL, 0xd4fe354094946a94ULL, 0xeb0cf31cf7f7fbf7ULL, 410 | 0xa1676f18b9b9deb9ULL, 0x985f268b13134c13ULL, 0x7d9c58512c2cb02cULL, 0xd6b8bb05d3d36bd3ULL, 411 | 0x6b5cd38ce7e7bbe7ULL, 0x57cbdc396e6ea56eULL, 0x6ef395aac4c437c4ULL, 0x180f061b03030c03ULL, 412 | 0x8a13acdc56564556ULL, 0x1a49885e44440d44ULL, 0xdf9efea07f7fe17fULL, 0x21374f88a9a99ea9ULL, 413 | 0x4d8254672a2aa82aULL, 0xb16d6b0abbbbd6bbULL, 0x46e29f87c1c123c1ULL, 0xa202a6f153535153ULL, 414 | 0xae8ba572dcdc57dcULL, 0x582716530b0b2c0bULL, 0x9cd327019d9d4e9dULL, 0x47c1d82b6c6cad6cULL, 415 | 0x95f562a43131c431ULL, 0x87b9e8f37474cd74ULL, 0xe309f115f6f6fff6ULL, 0x0a438c4c46460546ULL, 416 | 0x092645a5acac8aacULL, 0x3c970fb589891e89ULL, 0xa04428b414145014ULL, 0x5b42dfbae1e1a3e1ULL, 417 | 0xb04e2ca616165816ULL, 0xcdd274f73a3ae83aULL, 0x6fd0d2066969b969ULL, 0x482d124109092409ULL, 418 | 0xa7ade0d77070dd70ULL, 0xd954716fb6b6e2b6ULL, 0xceb7bd1ed0d067d0ULL, 0x3b7ec7d6eded93edULL, 419 | 0x2edb85e2cccc17ccULL, 0x2a57846842421542ULL, 0xb4c22d2c98985a98ULL, 0x490e55eda4a4aaa4ULL, 420 | 0x5d8850752828a028ULL, 0xda31b8865c5c6d5cULL, 0x933fed6bf8f8c7f8ULL, 0x44a411c286862286ULL, 421 | }; 422 | 423 | static const uint64_t C5[256] = { 424 | 0x18c07830d8181860ULL, 0x2305af462623238cULL, 0xc67ef991b8c6c63fULL, 0xe8136fcdfbe8e887ULL, 425 | 0x874ca113cb878726ULL, 0xb8a9626d11b8b8daULL, 0x0108050209010104ULL, 0x4f426e9e0d4f4f21ULL, 426 | 0x36adee6c9b3636d8ULL, 0xa6590451ffa6a6a2ULL, 0xd2debdb90cd2d26fULL, 0xf5fb06f70ef5f5f3ULL, 427 | 0x79ef80f2967979f9ULL, 0x6f5fcede306f6fa1ULL, 0x91fcef3f6d91917eULL, 0x52aa07a4f8525255ULL, 428 | 0x6027fdc04760609dULL, 0xbc89766535bcbccaULL, 0x9baccd2b379b9b56ULL, 0x8e048c018a8e8e02ULL, 429 | 0xa371155bd2a3a3b6ULL, 0x0c603c186c0c0c30ULL, 0x7bff8af6847b7bf1ULL, 0x35b5e16a803535d4ULL, 430 | 0x1de8693af51d1d74ULL, 0xe05347ddb3e0e0a7ULL, 0xd7f6acb321d7d77bULL, 0xc25eed999cc2c22fULL, 431 | 0x2e6d965c432e2eb8ULL, 0x4b627a96294b4b31ULL, 0xfea321e15dfefedfULL, 0x578216aed5575741ULL, 432 | 0x15a8412abd151554ULL, 0x779fb6eee87777c1ULL, 0x37a5eb6e923737dcULL, 0xe57b56d79ee5e5b3ULL, 433 | 0x9f8cd923139f9f46ULL, 0xf0d317fd23f0f0e7ULL, 0x4a6a7f94204a4a35ULL, 0xda9e95a944dada4fULL, 434 | 0x58fa25b0a258587dULL, 0xc906ca8fcfc9c903ULL, 0x29558d527c2929a4ULL, 0x0a5022145a0a0a28ULL, 435 | 0xb1e14f7f50b1b1feULL, 0xa0691a5dc9a0a0baULL, 0x6b7fdad6146b6bb1ULL, 0x855cab17d985852eULL, 436 | 0xbd8173673cbdbdceULL, 0x5dd234ba8f5d5d69ULL, 0x1080502090101040ULL, 0xf4f303f507f4f4f7ULL, 437 | 0xcb16c08bddcbcb0bULL, 0x3eedc67cd33e3ef8ULL, 0x0528110a2d050514ULL, 0x671fe6ce78676781ULL, 438 | 0xe47353d597e4e4b7ULL, 0x2725bb4e0227279cULL, 0x4132588273414119ULL, 0x8b2c9d0ba78b8b16ULL, 439 | 0xa7510153f6a7a7a6ULL, 0x7dcf94fab27d7de9ULL, 0x95dcfb374995956eULL, 0xd88e9fad56d8d847ULL, 440 | 0xfb8b30eb70fbfbcbULL, 0xee2371c1cdeeee9fULL, 0x7cc791f8bb7c7cedULL, 0x6617e3cc71666685ULL, 441 | 0xdda68ea77bdddd53ULL, 0x17b84b2eaf17175cULL, 0x4702468e45474701ULL, 0x9e84dc211a9e9e42ULL, 442 | 0xca1ec589d4caca0fULL, 0x2d75995a582d2db4ULL, 0xbf9179632ebfbfc6ULL, 0x07381b0e3f07071cULL, 443 | 0xad012347acadad8eULL, 0x5aea2fb4b05a5a75ULL, 0x836cb51bef838336ULL, 0x3385ff66b63333ccULL, 444 | 0x633ff2c65c636391ULL, 0x02100a0412020208ULL, 0xaa39384993aaaa92ULL, 0x71afa8e2de7171d9ULL, 445 | 0xc80ecf8dc6c8c807ULL, 0x19c87d32d1191964ULL, 0x497270923b494939ULL, 0xd9869aaf5fd9d943ULL, 446 | 0xf2c31df931f2f2efULL, 0xe34b48dba8e3e3abULL, 0x5be22ab6b95b5b71ULL, 0x8834920dbc88881aULL, 447 | 0x9aa4c8293e9a9a52ULL, 0x262dbe4c0b262698ULL, 0x328dfa64bf3232c8ULL, 0xb0e94a7d59b0b0faULL, 448 | 0xe91b6acff2e9e983ULL, 0x0f78331e770f0f3cULL, 0xd5e6a6b733d5d573ULL, 0x8074ba1df480803aULL, 449 | 0xbe997c6127bebec2ULL, 0xcd26de87ebcdcd13ULL, 0x34bde468893434d0ULL, 0x487a75903248483dULL, 450 | 0xffab24e354ffffdbULL, 0x7af78ff48d7a7af5ULL, 0x90f4ea3d6490907aULL, 0x5fc23ebe9d5f5f61ULL, 451 | 0x201da0403d202080ULL, 0x6867d5d00f6868bdULL, 0x1ad07234ca1a1a68ULL, 0xae192c41b7aeae82ULL, 452 | 0xb4c95e757db4b4eaULL, 0x549a19a8ce54544dULL, 0x93ece53b7f939376ULL, 0x220daa442f222288ULL, 453 | 0x6407e9c86364648dULL, 0xf1db12ff2af1f1e3ULL, 0x73bfa2e6cc7373d1ULL, 0x12905a2482121248ULL, 454 | 0x403a5d807a40401dULL, 0x0840281048080820ULL, 0xc356e89b95c3c32bULL, 0xec337bc5dfecec97ULL, 455 | 0xdb9690ab4ddbdb4bULL, 0xa1611f5fc0a1a1beULL, 0x8d1c8307918d8d0eULL, 0x3df5c97ac83d3df4ULL, 456 | 0x97ccf1335b979766ULL, 0x0000000000000000ULL, 0xcf36d483f9cfcf1bULL, 0x2b4587566e2b2bacULL, 457 | 0x7697b3ece17676c5ULL, 0x8264b019e6828232ULL, 0xd6fea9b128d6d67fULL, 0x1bd87736c31b1b6cULL, 458 | 0xb5c15b7774b5b5eeULL, 0xaf112943beafaf86ULL, 0x6a77dfd41d6a6ab5ULL, 0x50ba0da0ea50505dULL, 459 | 0x45124c8a57454509ULL, 0xf3cb18fb38f3f3ebULL, 0x309df060ad3030c0ULL, 0xef2b74c3c4efef9bULL, 460 | 0x3fe5c37eda3f3ffcULL, 0x55921caac7555549ULL, 0xa2791059dba2a2b2ULL, 0xea0365c9e9eaea8fULL, 461 | 0x650fecca6a656589ULL, 0xbab9686903babad2ULL, 0x2f65935e4a2f2fbcULL, 0xc04ee79d8ec0c027ULL, 462 | 0xdebe81a160dede5fULL, 0x1ce06c38fc1c1c70ULL, 0xfdbb2ee746fdfdd3ULL, 0x4d52649a1f4d4d29ULL, 463 | 0x92e4e03976929272ULL, 0x758fbceafa7575c9ULL, 0x06301e0c36060618ULL, 0x8a249809ae8a8a12ULL, 464 | 0xb2f940794bb2b2f2ULL, 0xe66359d185e6e6bfULL, 0x0e70361c7e0e0e38ULL, 0x1ff8633ee71f1f7cULL, 465 | 0x6237f7c455626295ULL, 0xd4eea3b53ad4d477ULL, 0xa829324d81a8a89aULL, 0x96c4f43152969662ULL, 466 | 0xf99b3aef62f9f9c3ULL, 0xc566f697a3c5c533ULL, 0x2535b14a10252594ULL, 0x59f220b2ab595979ULL, 467 | 0x8454ae15d084842aULL, 0x72b7a7e4c57272d5ULL, 0x39d5dd72ec3939e4ULL, 0x4c5a6198164c4c2dULL, 468 | 0x5eca3bbc945e5e65ULL, 0x78e785f09f7878fdULL, 0x38ddd870e53838e0ULL, 0x8c148605988c8c0aULL, 469 | 0xd1c6b2bf17d1d163ULL, 0xa5410b57e4a5a5aeULL, 0xe2434dd9a1e2e2afULL, 0x612ff8c24e616199ULL, 470 | 0xb3f1457b42b3b3f6ULL, 0x2115a54234212184ULL, 0x9c94d625089c9c4aULL, 0x1ef0663cee1e1e78ULL, 471 | 0x4322528661434311ULL, 0xc776fc93b1c7c73bULL, 0xfcb32be54ffcfcd7ULL, 0x0420140824040410ULL, 472 | 0x51b208a2e3515159ULL, 0x99bcc72f2599995eULL, 0x6d4fc4da226d6da9ULL, 0x0d68391a650d0d34ULL, 473 | 0xfa8335e979fafacfULL, 0xdfb684a369dfdf5bULL, 0x7ed79bfca97e7ee5ULL, 0x243db44819242490ULL, 474 | 0x3bc5d776fe3b3becULL, 0xab313d4b9aabab96ULL, 0xce3ed181f0cece1fULL, 0x1188552299111144ULL, 475 | 0x8f0c8903838f8f06ULL, 0x4e4a6b9c044e4e25ULL, 0xb7d1517366b7b7e6ULL, 0xeb0b60cbe0ebeb8bULL, 476 | 0x3cfdcc78c13c3cf0ULL, 0x817cbf1ffd81813eULL, 0x94d4fe354094946aULL, 0xf7eb0cf31cf7f7fbULL, 477 | 0xb9a1676f18b9b9deULL, 0x13985f268b13134cULL, 0x2c7d9c58512c2cb0ULL, 0xd3d6b8bb05d3d36bULL, 478 | 0xe76b5cd38ce7e7bbULL, 0x6e57cbdc396e6ea5ULL, 0xc46ef395aac4c437ULL, 0x03180f061b03030cULL, 479 | 0x568a13acdc565645ULL, 0x441a49885e44440dULL, 0x7fdf9efea07f7fe1ULL, 0xa921374f88a9a99eULL, 480 | 0x2a4d8254672a2aa8ULL, 0xbbb16d6b0abbbbd6ULL, 0xc146e29f87c1c123ULL, 0x53a202a6f1535351ULL, 481 | 0xdcae8ba572dcdc57ULL, 0x0b582716530b0b2cULL, 0x9d9cd327019d9d4eULL, 0x6c47c1d82b6c6cadULL, 482 | 0x3195f562a43131c4ULL, 0x7487b9e8f37474cdULL, 0xf6e309f115f6f6ffULL, 0x460a438c4c464605ULL, 483 | 0xac092645a5acac8aULL, 0x893c970fb589891eULL, 0x14a04428b4141450ULL, 0xe15b42dfbae1e1a3ULL, 484 | 0x16b04e2ca6161658ULL, 0x3acdd274f73a3ae8ULL, 0x696fd0d2066969b9ULL, 0x09482d1241090924ULL, 485 | 0x70a7ade0d77070ddULL, 0xb6d954716fb6b6e2ULL, 0xd0ceb7bd1ed0d067ULL, 0xed3b7ec7d6eded93ULL, 486 | 0xcc2edb85e2cccc17ULL, 0x422a578468424215ULL, 0x98b4c22d2c98985aULL, 0xa4490e55eda4a4aaULL, 487 | 0x285d8850752828a0ULL, 0x5cda31b8865c5c6dULL, 0xf8933fed6bf8f8c7ULL, 0x8644a411c2868622ULL, 488 | }; 489 | 490 | static const uint64_t C6[256] = { 491 | 0x6018c07830d81818ULL, 0x8c2305af46262323ULL, 0x3fc67ef991b8c6c6ULL, 0x87e8136fcdfbe8e8ULL, 492 | 0x26874ca113cb8787ULL, 0xdab8a9626d11b8b8ULL, 0x0401080502090101ULL, 0x214f426e9e0d4f4fULL, 493 | 0xd836adee6c9b3636ULL, 0xa2a6590451ffa6a6ULL, 0x6fd2debdb90cd2d2ULL, 0xf3f5fb06f70ef5f5ULL, 494 | 0xf979ef80f2967979ULL, 0xa16f5fcede306f6fULL, 0x7e91fcef3f6d9191ULL, 0x5552aa07a4f85252ULL, 495 | 0x9d6027fdc0476060ULL, 0xcabc89766535bcbcULL, 0x569baccd2b379b9bULL, 0x028e048c018a8e8eULL, 496 | 0xb6a371155bd2a3a3ULL, 0x300c603c186c0c0cULL, 0xf17bff8af6847b7bULL, 0xd435b5e16a803535ULL, 497 | 0x741de8693af51d1dULL, 0xa7e05347ddb3e0e0ULL, 0x7bd7f6acb321d7d7ULL, 0x2fc25eed999cc2c2ULL, 498 | 0xb82e6d965c432e2eULL, 0x314b627a96294b4bULL, 0xdffea321e15dfefeULL, 0x41578216aed55757ULL, 499 | 0x5415a8412abd1515ULL, 0xc1779fb6eee87777ULL, 0xdc37a5eb6e923737ULL, 0xb3e57b56d79ee5e5ULL, 500 | 0x469f8cd923139f9fULL, 0xe7f0d317fd23f0f0ULL, 0x354a6a7f94204a4aULL, 0x4fda9e95a944dadaULL, 501 | 0x7d58fa25b0a25858ULL, 0x03c906ca8fcfc9c9ULL, 0xa429558d527c2929ULL, 0x280a5022145a0a0aULL, 502 | 0xfeb1e14f7f50b1b1ULL, 0xbaa0691a5dc9a0a0ULL, 0xb16b7fdad6146b6bULL, 0x2e855cab17d98585ULL, 503 | 0xcebd8173673cbdbdULL, 0x695dd234ba8f5d5dULL, 0x4010805020901010ULL, 0xf7f4f303f507f4f4ULL, 504 | 0x0bcb16c08bddcbcbULL, 0xf83eedc67cd33e3eULL, 0x140528110a2d0505ULL, 0x81671fe6ce786767ULL, 505 | 0xb7e47353d597e4e4ULL, 0x9c2725bb4e022727ULL, 0x1941325882734141ULL, 0x168b2c9d0ba78b8bULL, 506 | 0xa6a7510153f6a7a7ULL, 0xe97dcf94fab27d7dULL, 0x6e95dcfb37499595ULL, 0x47d88e9fad56d8d8ULL, 507 | 0xcbfb8b30eb70fbfbULL, 0x9fee2371c1cdeeeeULL, 0xed7cc791f8bb7c7cULL, 0x856617e3cc716666ULL, 508 | 0x53dda68ea77bddddULL, 0x5c17b84b2eaf1717ULL, 0x014702468e454747ULL, 0x429e84dc211a9e9eULL, 509 | 0x0fca1ec589d4cacaULL, 0xb42d75995a582d2dULL, 0xc6bf9179632ebfbfULL, 0x1c07381b0e3f0707ULL, 510 | 0x8ead012347acadadULL, 0x755aea2fb4b05a5aULL, 0x36836cb51bef8383ULL, 0xcc3385ff66b63333ULL, 511 | 0x91633ff2c65c6363ULL, 0x0802100a04120202ULL, 0x92aa39384993aaaaULL, 0xd971afa8e2de7171ULL, 512 | 0x07c80ecf8dc6c8c8ULL, 0x6419c87d32d11919ULL, 0x39497270923b4949ULL, 0x43d9869aaf5fd9d9ULL, 513 | 0xeff2c31df931f2f2ULL, 0xabe34b48dba8e3e3ULL, 0x715be22ab6b95b5bULL, 0x1a8834920dbc8888ULL, 514 | 0x529aa4c8293e9a9aULL, 0x98262dbe4c0b2626ULL, 0xc8328dfa64bf3232ULL, 0xfab0e94a7d59b0b0ULL, 515 | 0x83e91b6acff2e9e9ULL, 0x3c0f78331e770f0fULL, 0x73d5e6a6b733d5d5ULL, 0x3a8074ba1df48080ULL, 516 | 0xc2be997c6127bebeULL, 0x13cd26de87ebcdcdULL, 0xd034bde468893434ULL, 0x3d487a7590324848ULL, 517 | 0xdbffab24e354ffffULL, 0xf57af78ff48d7a7aULL, 0x7a90f4ea3d649090ULL, 0x615fc23ebe9d5f5fULL, 518 | 0x80201da0403d2020ULL, 0xbd6867d5d00f6868ULL, 0x681ad07234ca1a1aULL, 0x82ae192c41b7aeaeULL, 519 | 0xeab4c95e757db4b4ULL, 0x4d549a19a8ce5454ULL, 0x7693ece53b7f9393ULL, 0x88220daa442f2222ULL, 520 | 0x8d6407e9c8636464ULL, 0xe3f1db12ff2af1f1ULL, 0xd173bfa2e6cc7373ULL, 0x4812905a24821212ULL, 521 | 0x1d403a5d807a4040ULL, 0x2008402810480808ULL, 0x2bc356e89b95c3c3ULL, 0x97ec337bc5dfececULL, 522 | 0x4bdb9690ab4ddbdbULL, 0xbea1611f5fc0a1a1ULL, 0x0e8d1c8307918d8dULL, 0xf43df5c97ac83d3dULL, 523 | 0x6697ccf1335b9797ULL, 0x0000000000000000ULL, 0x1bcf36d483f9cfcfULL, 0xac2b4587566e2b2bULL, 524 | 0xc57697b3ece17676ULL, 0x328264b019e68282ULL, 0x7fd6fea9b128d6d6ULL, 0x6c1bd87736c31b1bULL, 525 | 0xeeb5c15b7774b5b5ULL, 0x86af112943beafafULL, 0xb56a77dfd41d6a6aULL, 0x5d50ba0da0ea5050ULL, 526 | 0x0945124c8a574545ULL, 0xebf3cb18fb38f3f3ULL, 0xc0309df060ad3030ULL, 0x9bef2b74c3c4efefULL, 527 | 0xfc3fe5c37eda3f3fULL, 0x4955921caac75555ULL, 0xb2a2791059dba2a2ULL, 0x8fea0365c9e9eaeaULL, 528 | 0x89650fecca6a6565ULL, 0xd2bab9686903babaULL, 0xbc2f65935e4a2f2fULL, 0x27c04ee79d8ec0c0ULL, 529 | 0x5fdebe81a160dedeULL, 0x701ce06c38fc1c1cULL, 0xd3fdbb2ee746fdfdULL, 0x294d52649a1f4d4dULL, 530 | 0x7292e4e039769292ULL, 0xc9758fbceafa7575ULL, 0x1806301e0c360606ULL, 0x128a249809ae8a8aULL, 531 | 0xf2b2f940794bb2b2ULL, 0xbfe66359d185e6e6ULL, 0x380e70361c7e0e0eULL, 0x7c1ff8633ee71f1fULL, 532 | 0x956237f7c4556262ULL, 0x77d4eea3b53ad4d4ULL, 0x9aa829324d81a8a8ULL, 0x6296c4f431529696ULL, 533 | 0xc3f99b3aef62f9f9ULL, 0x33c566f697a3c5c5ULL, 0x942535b14a102525ULL, 0x7959f220b2ab5959ULL, 534 | 0x2a8454ae15d08484ULL, 0xd572b7a7e4c57272ULL, 0xe439d5dd72ec3939ULL, 0x2d4c5a6198164c4cULL, 535 | 0x655eca3bbc945e5eULL, 0xfd78e785f09f7878ULL, 0xe038ddd870e53838ULL, 0x0a8c148605988c8cULL, 536 | 0x63d1c6b2bf17d1d1ULL, 0xaea5410b57e4a5a5ULL, 0xafe2434dd9a1e2e2ULL, 0x99612ff8c24e6161ULL, 537 | 0xf6b3f1457b42b3b3ULL, 0x842115a542342121ULL, 0x4a9c94d625089c9cULL, 0x781ef0663cee1e1eULL, 538 | 0x1143225286614343ULL, 0x3bc776fc93b1c7c7ULL, 0xd7fcb32be54ffcfcULL, 0x1004201408240404ULL, 539 | 0x5951b208a2e35151ULL, 0x5e99bcc72f259999ULL, 0xa96d4fc4da226d6dULL, 0x340d68391a650d0dULL, 540 | 0xcffa8335e979fafaULL, 0x5bdfb684a369dfdfULL, 0xe57ed79bfca97e7eULL, 0x90243db448192424ULL, 541 | 0xec3bc5d776fe3b3bULL, 0x96ab313d4b9aababULL, 0x1fce3ed181f0ceceULL, 0x4411885522991111ULL, 542 | 0x068f0c8903838f8fULL, 0x254e4a6b9c044e4eULL, 0xe6b7d1517366b7b7ULL, 0x8beb0b60cbe0ebebULL, 543 | 0xf03cfdcc78c13c3cULL, 0x3e817cbf1ffd8181ULL, 0x6a94d4fe35409494ULL, 0xfbf7eb0cf31cf7f7ULL, 544 | 0xdeb9a1676f18b9b9ULL, 0x4c13985f268b1313ULL, 0xb02c7d9c58512c2cULL, 0x6bd3d6b8bb05d3d3ULL, 545 | 0xbbe76b5cd38ce7e7ULL, 0xa56e57cbdc396e6eULL, 0x37c46ef395aac4c4ULL, 0x0c03180f061b0303ULL, 546 | 0x45568a13acdc5656ULL, 0x0d441a49885e4444ULL, 0xe17fdf9efea07f7fULL, 0x9ea921374f88a9a9ULL, 547 | 0xa82a4d8254672a2aULL, 0xd6bbb16d6b0abbbbULL, 0x23c146e29f87c1c1ULL, 0x5153a202a6f15353ULL, 548 | 0x57dcae8ba572dcdcULL, 0x2c0b582716530b0bULL, 0x4e9d9cd327019d9dULL, 0xad6c47c1d82b6c6cULL, 549 | 0xc43195f562a43131ULL, 0xcd7487b9e8f37474ULL, 0xfff6e309f115f6f6ULL, 0x05460a438c4c4646ULL, 550 | 0x8aac092645a5acacULL, 0x1e893c970fb58989ULL, 0x5014a04428b41414ULL, 0xa3e15b42dfbae1e1ULL, 551 | 0x5816b04e2ca61616ULL, 0xe83acdd274f73a3aULL, 0xb9696fd0d2066969ULL, 0x2409482d12410909ULL, 552 | 0xdd70a7ade0d77070ULL, 0xe2b6d954716fb6b6ULL, 0x67d0ceb7bd1ed0d0ULL, 0x93ed3b7ec7d6ededULL, 553 | 0x17cc2edb85e2ccccULL, 0x15422a5784684242ULL, 0x5a98b4c22d2c9898ULL, 0xaaa4490e55eda4a4ULL, 554 | 0xa0285d8850752828ULL, 0x6d5cda31b8865c5cULL, 0xc7f8933fed6bf8f8ULL, 0x228644a411c28686ULL, 555 | }; 556 | 557 | static const uint64_t C7[256] = { 558 | 0x186018c07830d818ULL, 0x238c2305af462623ULL, 0xc63fc67ef991b8c6ULL, 0xe887e8136fcdfbe8ULL, 559 | 0x8726874ca113cb87ULL, 0xb8dab8a9626d11b8ULL, 0x0104010805020901ULL, 0x4f214f426e9e0d4fULL, 560 | 0x36d836adee6c9b36ULL, 0xa6a2a6590451ffa6ULL, 0xd26fd2debdb90cd2ULL, 0xf5f3f5fb06f70ef5ULL, 561 | 0x79f979ef80f29679ULL, 0x6fa16f5fcede306fULL, 0x917e91fcef3f6d91ULL, 0x525552aa07a4f852ULL, 562 | 0x609d6027fdc04760ULL, 0xbccabc89766535bcULL, 0x9b569baccd2b379bULL, 0x8e028e048c018a8eULL, 563 | 0xa3b6a371155bd2a3ULL, 0x0c300c603c186c0cULL, 0x7bf17bff8af6847bULL, 0x35d435b5e16a8035ULL, 564 | 0x1d741de8693af51dULL, 0xe0a7e05347ddb3e0ULL, 0xd77bd7f6acb321d7ULL, 0xc22fc25eed999cc2ULL, 565 | 0x2eb82e6d965c432eULL, 0x4b314b627a96294bULL, 0xfedffea321e15dfeULL, 0x5741578216aed557ULL, 566 | 0x155415a8412abd15ULL, 0x77c1779fb6eee877ULL, 0x37dc37a5eb6e9237ULL, 0xe5b3e57b56d79ee5ULL, 567 | 0x9f469f8cd923139fULL, 0xf0e7f0d317fd23f0ULL, 0x4a354a6a7f94204aULL, 0xda4fda9e95a944daULL, 568 | 0x587d58fa25b0a258ULL, 0xc903c906ca8fcfc9ULL, 0x29a429558d527c29ULL, 0x0a280a5022145a0aULL, 569 | 0xb1feb1e14f7f50b1ULL, 0xa0baa0691a5dc9a0ULL, 0x6bb16b7fdad6146bULL, 0x852e855cab17d985ULL, 570 | 0xbdcebd8173673cbdULL, 0x5d695dd234ba8f5dULL, 0x1040108050209010ULL, 0xf4f7f4f303f507f4ULL, 571 | 0xcb0bcb16c08bddcbULL, 0x3ef83eedc67cd33eULL, 0x05140528110a2d05ULL, 0x6781671fe6ce7867ULL, 572 | 0xe4b7e47353d597e4ULL, 0x279c2725bb4e0227ULL, 0x4119413258827341ULL, 0x8b168b2c9d0ba78bULL, 573 | 0xa7a6a7510153f6a7ULL, 0x7de97dcf94fab27dULL, 0x956e95dcfb374995ULL, 0xd847d88e9fad56d8ULL, 574 | 0xfbcbfb8b30eb70fbULL, 0xee9fee2371c1cdeeULL, 0x7ced7cc791f8bb7cULL, 0x66856617e3cc7166ULL, 575 | 0xdd53dda68ea77bddULL, 0x175c17b84b2eaf17ULL, 0x47014702468e4547ULL, 0x9e429e84dc211a9eULL, 576 | 0xca0fca1ec589d4caULL, 0x2db42d75995a582dULL, 0xbfc6bf9179632ebfULL, 0x071c07381b0e3f07ULL, 577 | 0xad8ead012347acadULL, 0x5a755aea2fb4b05aULL, 0x8336836cb51bef83ULL, 0x33cc3385ff66b633ULL, 578 | 0x6391633ff2c65c63ULL, 0x020802100a041202ULL, 0xaa92aa39384993aaULL, 0x71d971afa8e2de71ULL, 579 | 0xc807c80ecf8dc6c8ULL, 0x196419c87d32d119ULL, 0x4939497270923b49ULL, 0xd943d9869aaf5fd9ULL, 580 | 0xf2eff2c31df931f2ULL, 0xe3abe34b48dba8e3ULL, 0x5b715be22ab6b95bULL, 0x881a8834920dbc88ULL, 581 | 0x9a529aa4c8293e9aULL, 0x2698262dbe4c0b26ULL, 0x32c8328dfa64bf32ULL, 0xb0fab0e94a7d59b0ULL, 582 | 0xe983e91b6acff2e9ULL, 0x0f3c0f78331e770fULL, 0xd573d5e6a6b733d5ULL, 0x803a8074ba1df480ULL, 583 | 0xbec2be997c6127beULL, 0xcd13cd26de87ebcdULL, 0x34d034bde4688934ULL, 0x483d487a75903248ULL, 584 | 0xffdbffab24e354ffULL, 0x7af57af78ff48d7aULL, 0x907a90f4ea3d6490ULL, 0x5f615fc23ebe9d5fULL, 585 | 0x2080201da0403d20ULL, 0x68bd6867d5d00f68ULL, 0x1a681ad07234ca1aULL, 0xae82ae192c41b7aeULL, 586 | 0xb4eab4c95e757db4ULL, 0x544d549a19a8ce54ULL, 0x937693ece53b7f93ULL, 0x2288220daa442f22ULL, 587 | 0x648d6407e9c86364ULL, 0xf1e3f1db12ff2af1ULL, 0x73d173bfa2e6cc73ULL, 0x124812905a248212ULL, 588 | 0x401d403a5d807a40ULL, 0x0820084028104808ULL, 0xc32bc356e89b95c3ULL, 0xec97ec337bc5dfecULL, 589 | 0xdb4bdb9690ab4ddbULL, 0xa1bea1611f5fc0a1ULL, 0x8d0e8d1c8307918dULL, 0x3df43df5c97ac83dULL, 590 | 0x976697ccf1335b97ULL, 0x0000000000000000ULL, 0xcf1bcf36d483f9cfULL, 0x2bac2b4587566e2bULL, 591 | 0x76c57697b3ece176ULL, 0x82328264b019e682ULL, 0xd67fd6fea9b128d6ULL, 0x1b6c1bd87736c31bULL, 592 | 0xb5eeb5c15b7774b5ULL, 0xaf86af112943beafULL, 0x6ab56a77dfd41d6aULL, 0x505d50ba0da0ea50ULL, 593 | 0x450945124c8a5745ULL, 0xf3ebf3cb18fb38f3ULL, 0x30c0309df060ad30ULL, 0xef9bef2b74c3c4efULL, 594 | 0x3ffc3fe5c37eda3fULL, 0x554955921caac755ULL, 0xa2b2a2791059dba2ULL, 0xea8fea0365c9e9eaULL, 595 | 0x6589650fecca6a65ULL, 0xbad2bab9686903baULL, 0x2fbc2f65935e4a2fULL, 0xc027c04ee79d8ec0ULL, 596 | 0xde5fdebe81a160deULL, 0x1c701ce06c38fc1cULL, 0xfdd3fdbb2ee746fdULL, 0x4d294d52649a1f4dULL, 597 | 0x927292e4e0397692ULL, 0x75c9758fbceafa75ULL, 0x061806301e0c3606ULL, 0x8a128a249809ae8aULL, 598 | 0xb2f2b2f940794bb2ULL, 0xe6bfe66359d185e6ULL, 0x0e380e70361c7e0eULL, 0x1f7c1ff8633ee71fULL, 599 | 0x62956237f7c45562ULL, 0xd477d4eea3b53ad4ULL, 0xa89aa829324d81a8ULL, 0x966296c4f4315296ULL, 600 | 0xf9c3f99b3aef62f9ULL, 0xc533c566f697a3c5ULL, 0x25942535b14a1025ULL, 0x597959f220b2ab59ULL, 601 | 0x842a8454ae15d084ULL, 0x72d572b7a7e4c572ULL, 0x39e439d5dd72ec39ULL, 0x4c2d4c5a6198164cULL, 602 | 0x5e655eca3bbc945eULL, 0x78fd78e785f09f78ULL, 0x38e038ddd870e538ULL, 0x8c0a8c148605988cULL, 603 | 0xd163d1c6b2bf17d1ULL, 0xa5aea5410b57e4a5ULL, 0xe2afe2434dd9a1e2ULL, 0x6199612ff8c24e61ULL, 604 | 0xb3f6b3f1457b42b3ULL, 0x21842115a5423421ULL, 0x9c4a9c94d625089cULL, 0x1e781ef0663cee1eULL, 605 | 0x4311432252866143ULL, 0xc73bc776fc93b1c7ULL, 0xfcd7fcb32be54ffcULL, 0x0410042014082404ULL, 606 | 0x515951b208a2e351ULL, 0x995e99bcc72f2599ULL, 0x6da96d4fc4da226dULL, 0x0d340d68391a650dULL, 607 | 0xfacffa8335e979faULL, 0xdf5bdfb684a369dfULL, 0x7ee57ed79bfca97eULL, 0x2490243db4481924ULL, 608 | 0x3bec3bc5d776fe3bULL, 0xab96ab313d4b9aabULL, 0xce1fce3ed181f0ceULL, 0x1144118855229911ULL, 609 | 0x8f068f0c8903838fULL, 0x4e254e4a6b9c044eULL, 0xb7e6b7d1517366b7ULL, 0xeb8beb0b60cbe0ebULL, 610 | 0x3cf03cfdcc78c13cULL, 0x813e817cbf1ffd81ULL, 0x946a94d4fe354094ULL, 0xf7fbf7eb0cf31cf7ULL, 611 | 0xb9deb9a1676f18b9ULL, 0x134c13985f268b13ULL, 0x2cb02c7d9c58512cULL, 0xd36bd3d6b8bb05d3ULL, 612 | 0xe7bbe76b5cd38ce7ULL, 0x6ea56e57cbdc396eULL, 0xc437c46ef395aac4ULL, 0x030c03180f061b03ULL, 613 | 0x5645568a13acdc56ULL, 0x440d441a49885e44ULL, 0x7fe17fdf9efea07fULL, 0xa99ea921374f88a9ULL, 614 | 0x2aa82a4d8254672aULL, 0xbbd6bbb16d6b0abbULL, 0xc123c146e29f87c1ULL, 0x535153a202a6f153ULL, 615 | 0xdc57dcae8ba572dcULL, 0x0b2c0b582716530bULL, 0x9d4e9d9cd327019dULL, 0x6cad6c47c1d82b6cULL, 616 | 0x31c43195f562a431ULL, 0x74cd7487b9e8f374ULL, 0xf6fff6e309f115f6ULL, 0x4605460a438c4c46ULL, 617 | 0xac8aac092645a5acULL, 0x891e893c970fb589ULL, 0x145014a04428b414ULL, 0xe1a3e15b42dfbae1ULL, 618 | 0x165816b04e2ca616ULL, 0x3ae83acdd274f73aULL, 0x69b9696fd0d20669ULL, 0x092409482d124109ULL, 619 | 0x70dd70a7ade0d770ULL, 0xb6e2b6d954716fb6ULL, 0xd067d0ceb7bd1ed0ULL, 0xed93ed3b7ec7d6edULL, 620 | 0xcc17cc2edb85e2ccULL, 0x4215422a57846842ULL, 0x985a98b4c22d2c98ULL, 0xa4aaa4490e55eda4ULL, 621 | 0x28a0285d88507528ULL, 0x5c6d5cda31b8865cULL, 0xf8c7f8933fed6bf8ULL, 0x86228644a411c286ULL, 622 | }; 623 | 624 | static const uint64_t rc[R + 1] = { 625 | 0x0000000000000000ULL, 626 | 0x1823c6e887b8014fULL, 627 | 0x36a6d2f5796f9152ULL, 628 | 0x60bc9b8ea30c7b35ULL, 629 | 0x1de0d7c22e4bfe57ULL, 630 | 0x157737e59ff04adaULL, 631 | 0x58c9290ab1a06b85ULL, 632 | 0xbd5d10f4cb3e0567ULL, 633 | 0xe427418ba77d95d8ULL, 634 | 0xfbee7c66dd17479eULL, 635 | 0xca2dbf07ad5a8333ULL, 636 | }; 637 | 638 | /** 639 | * The core Whirlpool transform. 640 | */ 641 | void Whirlpool::processBuffer() { 642 | int i, r; 643 | uint64_t K[8]; /* the round key */ 644 | uint64_t block[8]; /* mu(buffer) */ 645 | uint64_t state[8]; /* the cipher state */ 646 | uint64_t L[8]; 647 | uint8_t* buffer = context->buffer; 648 | 649 | // map the buffer to a block: 650 | for ( i = 0; i < 8; i++, buffer += 8 ) { 651 | block[i] = 652 | ( ( ( uint64_t )buffer[0] ) << 56 ) ^ 653 | ( ( ( uint64_t )buffer[1] & 0xffL ) << 48 ) ^ 654 | ( ( ( uint64_t )buffer[2] & 0xffL ) << 40 ) ^ 655 | ( ( ( uint64_t )buffer[3] & 0xffL ) << 32 ) ^ 656 | ( ( ( uint64_t )buffer[4] & 0xffL ) << 24 ) ^ 657 | ( ( ( uint64_t )buffer[5] & 0xffL ) << 16 ) ^ 658 | ( ( ( uint64_t )buffer[6] & 0xffL ) << 8 ) ^ 659 | ( ( ( uint64_t )buffer[7] & 0xffL ) ); 660 | } 661 | // compute and apply K^0 to the cipher state: 662 | state[0] = block[0] ^ ( K[0] = context->hash[0] ); 663 | state[1] = block[1] ^ ( K[1] = context->hash[1] ); 664 | state[2] = block[2] ^ ( K[2] = context->hash[2] ); 665 | state[3] = block[3] ^ ( K[3] = context->hash[3] ); 666 | state[4] = block[4] ^ ( K[4] = context->hash[4] ); 667 | state[5] = block[5] ^ ( K[5] = context->hash[5] ); 668 | state[6] = block[6] ^ ( K[6] = context->hash[6] ); 669 | state[7] = block[7] ^ ( K[7] = context->hash[7] ); 670 | // iterate over all rounds: 671 | for ( r = 1; r <= R; r++ ) { 672 | // compute K^r from K^{r-1}: 673 | L[0] = 674 | C0[( int )( K[0] >> 56 ) ] ^ 675 | C1[( int )( K[7] >> 48 ) & 0xff] ^ 676 | C2[( int )( K[6] >> 40 ) & 0xff] ^ 677 | C3[( int )( K[5] >> 32 ) & 0xff] ^ 678 | C4[( int )( K[4] >> 24 ) & 0xff] ^ 679 | C5[( int )( K[3] >> 16 ) & 0xff] ^ 680 | C6[( int )( K[2] >> 8 ) & 0xff] ^ 681 | C7[( int )( K[1] ) & 0xff] ^ 682 | rc[r]; 683 | L[1] = 684 | C0[( int )( K[1] >> 56 ) ] ^ 685 | C1[( int )( K[0] >> 48 ) & 0xff] ^ 686 | C2[( int )( K[7] >> 40 ) & 0xff] ^ 687 | C3[( int )( K[6] >> 32 ) & 0xff] ^ 688 | C4[( int )( K[5] >> 24 ) & 0xff] ^ 689 | C5[( int )( K[4] >> 16 ) & 0xff] ^ 690 | C6[( int )( K[3] >> 8 ) & 0xff] ^ 691 | C7[( int )( K[2] ) & 0xff]; 692 | L[2] = 693 | C0[( int )( K[2] >> 56 ) ] ^ 694 | C1[( int )( K[1] >> 48 ) & 0xff] ^ 695 | C2[( int )( K[0] >> 40 ) & 0xff] ^ 696 | C3[( int )( K[7] >> 32 ) & 0xff] ^ 697 | C4[( int )( K[6] >> 24 ) & 0xff] ^ 698 | C5[( int )( K[5] >> 16 ) & 0xff] ^ 699 | C6[( int )( K[4] >> 8 ) & 0xff] ^ 700 | C7[( int )( K[3] ) & 0xff]; 701 | L[3] = 702 | C0[( int )( K[3] >> 56 ) ] ^ 703 | C1[( int )( K[2] >> 48 ) & 0xff] ^ 704 | C2[( int )( K[1] >> 40 ) & 0xff] ^ 705 | C3[( int )( K[0] >> 32 ) & 0xff] ^ 706 | C4[( int )( K[7] >> 24 ) & 0xff] ^ 707 | C5[( int )( K[6] >> 16 ) & 0xff] ^ 708 | C6[( int )( K[5] >> 8 ) & 0xff] ^ 709 | C7[( int )( K[4] ) & 0xff]; 710 | L[4] = 711 | C0[( int )( K[4] >> 56 ) ] ^ 712 | C1[( int )( K[3] >> 48 ) & 0xff] ^ 713 | C2[( int )( K[2] >> 40 ) & 0xff] ^ 714 | C3[( int )( K[1] >> 32 ) & 0xff] ^ 715 | C4[( int )( K[0] >> 24 ) & 0xff] ^ 716 | C5[( int )( K[7] >> 16 ) & 0xff] ^ 717 | C6[( int )( K[6] >> 8 ) & 0xff] ^ 718 | C7[( int )( K[5] ) & 0xff]; 719 | L[5] = 720 | C0[( int )( K[5] >> 56 ) ] ^ 721 | C1[( int )( K[4] >> 48 ) & 0xff] ^ 722 | C2[( int )( K[3] >> 40 ) & 0xff] ^ 723 | C3[( int )( K[2] >> 32 ) & 0xff] ^ 724 | C4[( int )( K[1] >> 24 ) & 0xff] ^ 725 | C5[( int )( K[0] >> 16 ) & 0xff] ^ 726 | C6[( int )( K[7] >> 8 ) & 0xff] ^ 727 | C7[( int )( K[6] ) & 0xff]; 728 | L[6] = 729 | C0[( int )( K[6] >> 56 ) ] ^ 730 | C1[( int )( K[5] >> 48 ) & 0xff] ^ 731 | C2[( int )( K[4] >> 40 ) & 0xff] ^ 732 | C3[( int )( K[3] >> 32 ) & 0xff] ^ 733 | C4[( int )( K[2] >> 24 ) & 0xff] ^ 734 | C5[( int )( K[1] >> 16 ) & 0xff] ^ 735 | C6[( int )( K[0] >> 8 ) & 0xff] ^ 736 | C7[( int )( K[7] ) & 0xff]; 737 | L[7] = 738 | C0[( int )( K[7] >> 56 ) ] ^ 739 | C1[( int )( K[6] >> 48 ) & 0xff] ^ 740 | C2[( int )( K[5] >> 40 ) & 0xff] ^ 741 | C3[( int )( K[4] >> 32 ) & 0xff] ^ 742 | C4[( int )( K[3] >> 24 ) & 0xff] ^ 743 | C5[( int )( K[2] >> 16 ) & 0xff] ^ 744 | C6[( int )( K[1] >> 8 ) & 0xff] ^ 745 | C7[( int )( K[0] ) & 0xff]; 746 | K[0] = L[0]; 747 | K[1] = L[1]; 748 | K[2] = L[2]; 749 | K[3] = L[3]; 750 | K[4] = L[4]; 751 | K[5] = L[5]; 752 | K[6] = L[6]; 753 | K[7] = L[7]; 754 | // apply the r-th round transformation: 755 | L[0] = 756 | C0[( int )( state[0] >> 56 ) ] ^ 757 | C1[( int )( state[7] >> 48 ) & 0xff] ^ 758 | C2[( int )( state[6] >> 40 ) & 0xff] ^ 759 | C3[( int )( state[5] >> 32 ) & 0xff] ^ 760 | C4[( int )( state[4] >> 24 ) & 0xff] ^ 761 | C5[( int )( state[3] >> 16 ) & 0xff] ^ 762 | C6[( int )( state[2] >> 8 ) & 0xff] ^ 763 | C7[( int )( state[1] ) & 0xff] ^ 764 | K[0]; 765 | L[1] = 766 | C0[( int )( state[1] >> 56 ) ] ^ 767 | C1[( int )( state[0] >> 48 ) & 0xff] ^ 768 | C2[( int )( state[7] >> 40 ) & 0xff] ^ 769 | C3[( int )( state[6] >> 32 ) & 0xff] ^ 770 | C4[( int )( state[5] >> 24 ) & 0xff] ^ 771 | C5[( int )( state[4] >> 16 ) & 0xff] ^ 772 | C6[( int )( state[3] >> 8 ) & 0xff] ^ 773 | C7[( int )( state[2] ) & 0xff] ^ 774 | K[1]; 775 | L[2] = 776 | C0[( int )( state[2] >> 56 ) ] ^ 777 | C1[( int )( state[1] >> 48 ) & 0xff] ^ 778 | C2[( int )( state[0] >> 40 ) & 0xff] ^ 779 | C3[( int )( state[7] >> 32 ) & 0xff] ^ 780 | C4[( int )( state[6] >> 24 ) & 0xff] ^ 781 | C5[( int )( state[5] >> 16 ) & 0xff] ^ 782 | C6[( int )( state[4] >> 8 ) & 0xff] ^ 783 | C7[( int )( state[3] ) & 0xff] ^ 784 | K[2]; 785 | L[3] = 786 | C0[( int )( state[3] >> 56 ) ] ^ 787 | C1[( int )( state[2] >> 48 ) & 0xff] ^ 788 | C2[( int )( state[1] >> 40 ) & 0xff] ^ 789 | C3[( int )( state[0] >> 32 ) & 0xff] ^ 790 | C4[( int )( state[7] >> 24 ) & 0xff] ^ 791 | C5[( int )( state[6] >> 16 ) & 0xff] ^ 792 | C6[( int )( state[5] >> 8 ) & 0xff] ^ 793 | C7[( int )( state[4] ) & 0xff] ^ 794 | K[3]; 795 | L[4] = 796 | C0[( int )( state[4] >> 56 ) ] ^ 797 | C1[( int )( state[3] >> 48 ) & 0xff] ^ 798 | C2[( int )( state[2] >> 40 ) & 0xff] ^ 799 | C3[( int )( state[1] >> 32 ) & 0xff] ^ 800 | C4[( int )( state[0] >> 24 ) & 0xff] ^ 801 | C5[( int )( state[7] >> 16 ) & 0xff] ^ 802 | C6[( int )( state[6] >> 8 ) & 0xff] ^ 803 | C7[( int )( state[5] ) & 0xff] ^ 804 | K[4]; 805 | L[5] = 806 | C0[( int )( state[5] >> 56 ) ] ^ 807 | C1[( int )( state[4] >> 48 ) & 0xff] ^ 808 | C2[( int )( state[3] >> 40 ) & 0xff] ^ 809 | C3[( int )( state[2] >> 32 ) & 0xff] ^ 810 | C4[( int )( state[1] >> 24 ) & 0xff] ^ 811 | C5[( int )( state[0] >> 16 ) & 0xff] ^ 812 | C6[( int )( state[7] >> 8 ) & 0xff] ^ 813 | C7[( int )( state[6] ) & 0xff] ^ 814 | K[5]; 815 | L[6] = 816 | C0[( int )( state[6] >> 56 ) ] ^ 817 | C1[( int )( state[5] >> 48 ) & 0xff] ^ 818 | C2[( int )( state[4] >> 40 ) & 0xff] ^ 819 | C3[( int )( state[3] >> 32 ) & 0xff] ^ 820 | C4[( int )( state[2] >> 24 ) & 0xff] ^ 821 | C5[( int )( state[1] >> 16 ) & 0xff] ^ 822 | C6[( int )( state[0] >> 8 ) & 0xff] ^ 823 | C7[( int )( state[7] ) & 0xff] ^ 824 | K[6]; 825 | L[7] = 826 | C0[( int )( state[7] >> 56 ) ] ^ 827 | C1[( int )( state[6] >> 48 ) & 0xff] ^ 828 | C2[( int )( state[5] >> 40 ) & 0xff] ^ 829 | C3[( int )( state[4] >> 32 ) & 0xff] ^ 830 | C4[( int )( state[3] >> 24 ) & 0xff] ^ 831 | C5[( int )( state[2] >> 16 ) & 0xff] ^ 832 | C6[( int )( state[1] >> 8 ) & 0xff] ^ 833 | C7[( int )( state[0] ) & 0xff] ^ 834 | K[7]; 835 | state[0] = L[0]; 836 | state[1] = L[1]; 837 | state[2] = L[2]; 838 | state[3] = L[3]; 839 | state[4] = L[4]; 840 | state[5] = L[5]; 841 | state[6] = L[6]; 842 | state[7] = L[7]; 843 | } 844 | // apply the Miyaguchi-Preneel compression function: 845 | context->hash[0] ^= state[0] ^ block[0]; 846 | context->hash[1] ^= state[1] ^ block[1]; 847 | context->hash[2] ^= state[2] ^ block[2]; 848 | context->hash[3] ^= state[3] ^ block[3]; 849 | context->hash[4] ^= state[4] ^ block[4]; 850 | context->hash[5] ^= state[5] ^ block[5]; 851 | context->hash[6] ^= state[6] ^ block[6]; 852 | context->hash[7] ^= state[7] ^ block[7]; 853 | } 854 | 855 | Whirlpool::Whirlpool() : context( new WHIRLPOOL_CONTEXT ) {} 856 | 857 | Whirlpool::~Whirlpool() { 858 | delete context; 859 | context = NULL; 860 | } 861 | 862 | /** 863 | * Initialize the hashing state. 864 | */ 865 | void Whirlpool::init() { 866 | int i; 867 | 868 | memset( context->bitLength, 0, 32 ); 869 | context->bufferBits = context->bufferPos = 0; 870 | context->buffer[0] = 0; /* it's only necessary to cleanup buffer[bufferPos] */ 871 | for ( i = 0; i < 8; i++ ) { 872 | context->hash[i] = 0L; /* initial value */ 873 | } 874 | } 875 | 876 | /** 877 | * Delivers input data to the hashing algorithm. 878 | * 879 | * @param source plaintext data to hash. 880 | * @param sourceBits how many bits of plaintext to process. 881 | * 882 | * This method maintains the invariant: bufferBits < WHIRLPOOL_DIGEST_BITSIZE 883 | */ 884 | void Whirlpool::write( const byte* source, int sourceBits ) { 885 | sourceBits *= 8; 886 | int sourcePos = 0; /* index of leftmost source uint8_t containing data (1 to 8 bits). */ 887 | int sourceGap = ( 8 - ( ( int )sourceBits & 7 ) ) & 7; /* space on source[sourcePos]. */ 888 | int bufferRem = context->bufferBits & 7; /* occupied bits on buffer[bufferPos]. */ 889 | int i; 890 | uint32_t b, carry; 891 | uint8_t* buffer = context->buffer; 892 | uint8_t* bitLength = context->bitLength; 893 | int bufferBits = context->bufferBits; 894 | int bufferPos = context->bufferPos; 895 | 896 | // tally the length of the added data: 897 | uint64_t value = sourceBits; 898 | for ( i = 31, carry = 0; i >= 0 && ( carry != 0 || value != 0ULL ); i-- ) { 899 | carry += bitLength[i] + ( ( uint32_t )value & 0xff ); 900 | bitLength[i] = ( uint8_t )carry; 901 | carry >>= 8; 902 | value >>= 8; 903 | } 904 | // process data in chunks of 8 bits (a more efficient approach would be to take whole-word chunks): 905 | while ( sourceBits > 8 ) { 906 | /* N.B. at least source[sourcePos] and source[sourcePos+1] contain data. */ 907 | // take a byte from the source: 908 | b = ( ( source[sourcePos] << sourceGap ) & 0xff ) | 909 | ( ( source[sourcePos + 1] & 0xff ) >> ( 8 - sourceGap ) ); 910 | // process this byte: 911 | buffer[bufferPos++] |= ( uint8_t )( b >> bufferRem ); 912 | bufferBits += 8 - bufferRem; /* bufferBits = 8*bufferPos; */ 913 | if ( bufferBits == WHIRLPOOL_DIGEST_BITSIZE ) { 914 | // process data block: 915 | processBuffer(); 916 | // reset buffer: 917 | bufferBits = bufferPos = 0; 918 | } 919 | buffer[bufferPos] = b << ( 8 - bufferRem ); 920 | bufferBits += bufferRem; 921 | // proceed to remaining data: 922 | sourceBits -= 8; 923 | sourcePos++; 924 | } 925 | /* now 0 <= sourceBits <= 8; 926 | furthermore, all data (if any is left) is in source[sourcePos].*/ 927 | if ( sourceBits > 0 ) { 928 | b = ( source[sourcePos] << sourceGap ) & 0xff; /* bits are left-justified on b. */ 929 | // process the remaining bits: 930 | buffer[bufferPos] |= b >> bufferRem; 931 | } else { 932 | b = 0; 933 | } 934 | if ( bufferRem + sourceBits < 8 ) { 935 | // all remaining data fits on buffer[bufferPos], and there still remains some space. 936 | bufferBits += sourceBits; 937 | } else { 938 | // buffer[bufferPos] is full: 939 | bufferPos++; 940 | bufferBits += 8 - bufferRem; /* bufferBits = 8*bufferPos; */ 941 | sourceBits -= 8 - bufferRem; 942 | /* now 0 <= sourceBits < 8; 943 | furthermore, all data (if any is left) is in source[sourcePos].*/ 944 | if ( bufferBits == WHIRLPOOL_DIGEST_BITSIZE ) { 945 | // process data block: 946 | processBuffer(); 947 | // reset buffer: 948 | bufferBits = bufferPos = 0; 949 | } 950 | buffer[bufferPos] = b << ( 8 - bufferRem ); 951 | bufferBits += ( int )sourceBits; 952 | } 953 | context->bufferBits = bufferBits; 954 | context->bufferPos = bufferPos; 955 | } 956 | 957 | /** 958 | * Get the hash value from the hashing state. 959 | * 960 | * This method uses the invariant: bufferBits < WHIRLPOOL_DIGEST_BITSIZE 961 | */ 962 | byte* Whirlpool::final() { 963 | int i; 964 | uint8_t* buffer = context->buffer; 965 | uint8_t* bitLength = context->bitLength; 966 | int bufferBits = context->bufferBits; 967 | int bufferPos = context->bufferPos; 968 | 969 | // append a '1'-bit: 970 | buffer[bufferPos] |= 0x80U >> ( bufferBits & 7 ); 971 | bufferPos++; /* all remaining bits on the current uint8_t are set to zero. */ 972 | // pad with zero bits to complete (N*WHIRLPOOL_BLOCK_BITSIZE - WHIRLPOOL_BITSIZE) bits: 973 | if ( bufferPos > WHIRLPOOL_BLOCK_SIZE - WHIRLPOOL_SIZE ) { 974 | if ( bufferPos < WHIRLPOOL_BLOCK_SIZE ) { 975 | memset( &buffer[bufferPos], 0, WHIRLPOOL_BLOCK_SIZE - bufferPos ); 976 | } 977 | // process data block: 978 | processBuffer(); 979 | // reset buffer: 980 | bufferPos = 0; 981 | } 982 | if ( bufferPos < WHIRLPOOL_BLOCK_SIZE - WHIRLPOOL_SIZE ) { 983 | memset( &buffer[bufferPos], 0, ( WHIRLPOOL_BLOCK_SIZE - WHIRLPOOL_SIZE ) - bufferPos ); 984 | } 985 | bufferPos = WHIRLPOOL_BLOCK_SIZE - WHIRLPOOL_SIZE; 986 | // append bit length of hashed data: 987 | memcpy( &buffer[WHIRLPOOL_BLOCK_SIZE - WHIRLPOOL_SIZE], bitLength, WHIRLPOOL_SIZE ); 988 | // process data block: 989 | processBuffer(); 990 | // return the completed message digest: 991 | byte* digest = context->buffer; 992 | for ( i = 0; i < WHIRLPOOL_DIGEST_SIZE / 8; i++ ) { 993 | digest[0] = ( uint8_t )( context->hash[i] >> 56 ); 994 | digest[1] = ( uint8_t )( context->hash[i] >> 48 ); 995 | digest[2] = ( uint8_t )( context->hash[i] >> 40 ); 996 | digest[3] = ( uint8_t )( context->hash[i] >> 32 ); 997 | digest[4] = ( uint8_t )( context->hash[i] >> 24 ); 998 | digest[5] = ( uint8_t )( context->hash[i] >> 16 ); 999 | digest[6] = ( uint8_t )( context->hash[i] >> 8 ); 1000 | digest[7] = ( uint8_t )( context->hash[i] ); 1001 | digest += 8; 1002 | } 1003 | context->bufferBits = bufferBits; 1004 | context->bufferPos = bufferPos; 1005 | return context->buffer; 1006 | } 1007 | --------------------------------------------------------------------------------