Page 1 of 2 12 LastLast
Results 1 to 30 of 59

Thread: CHK v1.03 is here!

  1. #1
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts

    Cool CHK v1.03 is here!

    New version of CHK has been released!

    http://encode.narod.ru


    Enjoy!
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	1.png 
Views:	859 
Size:	79.0 KB 
ID:	1884   Click image for larger version. 

Name:	2.png 
Views:	569 
Size:	67.3 KB 
ID:	1885  

  2. #2
    Member FatBit's Avatar
    Join Date
    Jan 2012
    Location
    Prague, CZ
    Posts
    189
    Thanks
    0
    Thanked 36 Times in 27 Posts
    Dear Mr. Encode,

    thank you for your new release. But I have problem with some files. When I use "synthetic" filenames like file#### I do not any problem. But when I use "real" filenames with national characters (CZ) program does not find some of these ones. It depends on number of another files in directory. Could you be so kind and investigate it? I use Win XP SP3 Czech.

    Sincerely yours,

    FatBit

  3. #3
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts
    CHK is 100% Unicode inside, so you must have no issues with other languages. I tested CHK on Russian Windows XP with Russian files and had no problems.

    It only outputs TXT hash list in ANSI, for compatibility with other programs such as RHASH.

    Can you provide more details? How you open files via CHK? Via "Add..." command, Drag&Drop (dragging files on program) or as a command line parameters?
    Can you provide a screenshot?

  4. #4
    Member FatBit's Avatar
    Join Date
    Jan 2012
    Location
    Prague, CZ
    Posts
    189
    Thanks
    0
    Thanked 36 Times in 27 Posts
    Dear Mr. Encode,

    step by step "bug" reproduction:

    1. Start Chk 1.03
    2. File + Add
    3. "Travel" to different folder
    4. Enter inside folder
    5. Press Ctrl +A
    6. Press Open
    7. Error warning occurs (xxx This file was not found. Be sure you enter right filename)

    I prepared folder dir content as UTF8 text file, in zip archive attachment.

    Sincerely yours,

    FatBit

    Click image for larger version. 

Name:	Chk103.png 
Views:	476 
Size:	46.3 KB 
ID:	1889
    Attached Files Attached Files

  5. #5
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts
    It looks like a bug in TOpenDialog. Will check it out. Can these files be opened via OpenDialog with other programs? Say, can you add these files to an archive or something?

    Anyway, try to drag this folder to a program directly. i.e. instead of pressing "Add...", just drag the folder from Explorer and drop to CHK's window...

  6. #6
    Member FatBit's Avatar
    Join Date
    Jan 2012
    Location
    Prague, CZ
    Posts
    189
    Thanks
    0
    Thanked 36 Times in 27 Posts
    Dear Mr. Encode,

    1. Yes, files are fully readable via Foxit Reader and it is possible to pack them into zip.
    2. When I drag test folder from Explorer and drop directly to Chk 103 window the error does not occur.

    Sincerely yours,

    FatBit

    Click image for larger version. 

Name:	Chk103.png 
Views:	423 
Size:	78.2 KB 
ID:	1892

  7. #7
    Member
    Join Date
    May 2008
    Location
    HK
    Posts
    160
    Thanks
    4
    Thanked 25 Times in 15 Posts
    Is it possible to calculate multiple type of hash of file(s) (like HashCalc) and output a text file in CHK?

  8. #8
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts
    Quote Originally Posted by roytam1 View Post
    Is it possible to calculate multiple type of hash of file(s) (like HashCalc) and output a text file in CHK?
    The answer is no.

    As a note HashCalc can calculate multiple hashes for just one file and CHK can calculate one hash for multiple files...

  9. #9
    Member
    Join Date
    Apr 2012
    Location
    china
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your CHK.
    Could you let it work for Linux(Like Fedora or Ubuntu,Command line also good).And add a Completed progress % in order to calculate a big file?

  10. #10
    Member przemoc's Avatar
    Join Date
    Aug 2011
    Location
    Poland
    Posts
    44
    Thanks
    3
    Thanked 23 Times in 13 Posts
    cem, if command line is sufficient for you, then RHash (http://rhash.anz.ru/) is already there. It doesn't have many useful predefined templates as I suggested months ago for CHK, but it at least has templates at all, so you can format output as you wish if bare hashes (one after another, as you've chosen them from the options) are not suitable for you. Pretty useful.

  11. #11
    Member
    Join Date
    Apr 2012
    Location
    china
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks przemoc!
    RHash is easy to use,good,I like this one.
    but why so few user downloads?

  12. #12
    Member
    Join Date
    Sep 2011
    Location
    Yan
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nice tool, really easy to use

  13. #13
    Member
    Join Date
    Jun 2008
    Location
    Germany
    Posts
    369
    Thanks
    5
    Thanked 6 Times in 4 Posts
    That one is also very nice (but not as much various sums as in encodes chk.exe): http://code.kliu.org/hashcheck/

  14. #14
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	chk104.png 
Views:	317 
Size:	123.8 KB 
ID:	2089  

  15. #15
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts
    Or supported hash list might look like this:
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	chk104.png 
Views:	323 
Size:	94.0 KB 
ID:	2096  

  16. #16
    Tester
    Black_Fox's Avatar
    Join Date
    May 2008
    Location
    [CZE] Czechia
    Posts
    471
    Thanks
    26
    Thanked 9 Times in 8 Posts
    I like the first "HASH-BITS" form (0.07, it's much better to read.
    I am... Black_Fox... my discontinued benchmark
    "No one involved in computers would ever say that a certain amount of memory is enough for all time? I keep bumping into that silly quotation attributed to me that says 640K of memory is enough. There's never a citation; the quotation just floats like a rumor, repeated again and again." -- Bill Gates

  17. #17
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts
    Downloaded a few hash calculators with KECCAK support, the results are different from Wikipedia ones. My implementation shows completely different results. All tools calculate different KECCAK. Should we wait until this hash will be truly standardized?

    Anyway, what's new in CHK 1.04 BETA:
    + Notable speed improvements (All CRC, and all SHA - explored very interesting speed optimization trick)
    + Interface improvements and cleanups
    + Added CRC16
    + Drag&Drop bug-fix

  18. #18
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts
    Gangnam... Oops... Windows 8 style!

    BTW, what do you think about the new Windows 8 and it's brand new style? I personally prefer something in-between Windows XP and Windows Vista/7.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	w8.png 
Views:	314 
Size:	103.8 KB 
ID:	2097  

  19. #19
    Tester
    Black_Fox's Avatar
    Join Date
    May 2008
    Location
    [CZE] Czechia
    Posts
    471
    Thanks
    26
    Thanked 9 Times in 8 Posts
    Windows 8 style reminds me of Windows 1.0. There are some very nice improvements, but the overall shift of style towards simplification+touch-controls and Metro are just dealbreakers (for me that always eagerly updated on the newest Win version as soon as possible since Win ME). Win7 style is fine.
    I am... Black_Fox... my discontinued benchmark
    "No one involved in computers would ever say that a certain amount of memory is enough for all time? I keep bumping into that silly quotation attributed to me that says 640K of memory is enough. There's never a citation; the quotation just floats like a rumor, repeated again and again." -- Bill Gates

  20. #20
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts
    Extended icon logic
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Untitled.png 
Views:	298 
Size:	167.2 KB 
ID:	2098  

  21. #21
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	0.png 
Views:	286 
Size:	98.6 KB 
ID:	2099  

  22. #22
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts
    Added SHA3 (KECCAK)! SpongeBob rules!!!

    Actually, this Sponge terminology is just a poetry... In my implementation SHA3 has the same structure as MD4,MD5,SHA1...SHA512 - Init(), Update() and Final(). Anyway, the idea is very elegant and I like it very much.

    One downside, it's SLOW... So, IMHO, SHA3 must have a fixed width of 512-bits (just as SHA1 has 160-bits)

    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	sha3.png 
Views:	281 
Size:	65.4 KB 
ID:	2100  

  23. #23
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts
    For reference:
    Code:
    ENWIK9, SHA3: 181FA2F36043C4D7D37C08363169FAB782054E0028094D8E6620633336329248530BB79C91D217DFE301431B0F239A8BC4944B994C70C834BDDF874A769092AE

  24. #24
    Expert
    Matt Mahoney's Avatar
    Join Date
    May 2008
    Location
    Melbourne, Florida, USA
    Posts
    3,255
    Thanks
    306
    Thanked 778 Times in 485 Posts
    That agrees with what I get.
    But 80 sec. on a 2 GHz T3200 is slow using the code I posted. Did you try any of the SSE2 code on the Keccak site?

  25. #25
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts
    I didn't, since it's troublesome to use it with my compiler (Borland C++ is awkward as hell). But, I've applied some optimizations.
    As example, instead of loading bytes with turtle-speed 64-bit shifts, you may use union; e.g.
    Code:
    union
    {
    T a[25];
    unsigned char buf[sizeof(T)*25];
    };
    
    // ...
    
    // Put new char
    buf[ptr]^=ch;
    
    // To be MSB/LSB compatible (not needed for IA32), we may use:
    // if sizeof(T)==4 -> buf[ptr^3]^=ch;
    // if sizeof(T)==8 -> buf[ptr^7]^=ch;

  26. #26
    Expert
    Matt Mahoney's Avatar
    Join Date
    May 2008
    Location
    Melbourne, Florida, USA
    Posts
    3,255
    Thanks
    306
    Thanked 778 Times in 485 Posts
    I think most of the savings should come from implementing keccak-F in 64 bits. For example, g++ can optimize 32 bit rotates when compiled as 32 bit code like this:

    Code:
    typedef unsigned T;
    T rol(T a, int b) {
      return a<<b|a>>(8*sizeof(T))-b;
    }
    
    > gcc -O3 -msse2 -S
    
    movl    4(%esp), %eax
    movl    8(%esp), %ecx
    roll    %cl, %eax
    ret
    As 64 bit code, it does a similar optimization when T is changed to unsigned long long. But for a 32 bit compile, the code is a mess:
    Code:
    pushl   %edi
    pushl   %esi
    pushl   %ebx
    movl    16(%esp), %eax
    movl    20(%esp), %edx
    movl    24(%esp), %ecx
    movl    %eax, %esi
    movl    %edx, %edi
    shldl   %cl, %eax, %edi
    sall    %cl, %esi
    xorl    %ebx, %ebx
    testb   $32, %cl
    cmovne  %esi, %edi
    cmovne  %ebx, %esi
    movl    $64, %ebx
    subl    %ecx, %ebx
    movb    %bl, %cl
    shrdl   %cl, %edx, %eax
    shrl    %cl, %edx
    xorl    %ebx, %ebx
    testb   $32, %cl
    cmovne  %edx, %eax
    cmovne  %ebx, %edx
    orl     %esi, %eax
    orl     %edi, %edx
    popl    %ebx
    popl    %esi
    popl    %edi
    ret
    The problem is you have 360 rotates (30 per round) for each 64 byte input block, plus all the other operations done 32 bits at a time instead of 128 in SSE2.

    Edit: some benchmarks for sha3 enwik9 from http://encode.ru/threads/1613-SHA3-w...ll=1#post31428

    2.0 GHz T3200, Win32, g++ 4.7.0 -O3 -msse2
    Keccak<unsigned, 288>, 34.7 sec. process time
    Keccak<in64_t, 576>, 77.0 sec.
    fsum -sha1, 8.5 sec.
    fsum -sha256, 13.4 sec.

    2.67 GHz M620, 64 bit Ubuntu, g++ 4.6.3 -O3
    Keccak<unsigned, 288>, 26.3 sec.
    Keccak<in64_t, 576>, 19.6 sec.
    Last edited by Matt Mahoney; 24th November 2012 at 23:51. Reason: added benchmarks

  27. #27
    Expert
    Matt Mahoney's Avatar
    Join Date
    May 2008
    Location
    Melbourne, Florida, USA
    Posts
    3,255
    Thanks
    306
    Thanked 778 Times in 485 Posts
    Here is a version of SHA3-512 using SSSE3 intrinsics derived from code at http://keccak.noekeon.org/
    Time for enwik9 is improved from 77.0 sec to 29.2 sec. on a 2 GHz T3200 under 32 bit Windows. Compile with g++ -O3 -mssse3

    Code:
    // sha3 - Compute SHA3-512 hashes of files
    // Written by Matt Mahoney. Released to public domain.
    // Compile: g++ -O3 -ssse3 sha3.cpp -o sha3
    
    #define _CRT_DISABLE_PERFCRIT_LOCKS  // speed up getc() and putc() in VC++
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <stdint.h>
    #include <assert.h>
    #include <x86intrin.h>
    
    // Keccak code derived from public domain http://keccak.noekeon.org/
    
    typedef unsigned char UINT8;
    typedef unsigned long long int UINT64;
    
    #if defined(__GNUC__)
    #define ALIGN __attribute__ ((aligned(32)))
    #elif defined(_MSC_VER)
    #define ALIGN __declspec(align(32))
    #else
    #define ALIGN
    #endif
    
    typedef __m128i V64;
    typedef __m128i V128;
    typedef union {
      V128 v128;
      UINT64 v64[2];
    } V6464;
    
    #define ANDnu64(a, b)       _mm_andnot_si128(a, b)
    #define LOAD64(a)           _mm_loadl_epi64((const V64 *)&(a))
    #define CONST64(a)          _mm_loadl_epi64((const V64 *)&(a))
    #define ROL64(a, o)         _mm_or_si128(_mm_slli_epi64(a, o), _mm_srli_epi64(a, 64-(o)))
    #define STORE64(a, b)       _mm_storel_epi64((V64 *)&(a), b)
    #define XOR64(a, b)         _mm_xor_si128(a, b)
    #define XOReq64(a, b)       a = _mm_xor_si128(a, b)
    #define SHUFFLEBYTES128(a, b)   _mm_shuffle_epi8(a, b)
    
    #define ANDnu128(a, b)      _mm_andnot_si128(a, b)
    #define LOAD6464(a, b)      _mm_set_epi64((__m64)(a), (__m64)(b))
    #define CONST128(a)         _mm_load_si128((const V128 *)&(a))
    #define LOAD128(a)          _mm_load_si128((const V128 *)&(a))
    #define LOAD128u(a)         _mm_loadu_si128((const V128 *)&(a))
    #define ROL64in128(a, o)    _mm_or_si128(_mm_slli_epi64(a, o), _mm_srli_epi64(a, 64-(o)))
    #define STORE128(a, b)      _mm_store_si128((V128 *)&(a), b)
    #define XOR128(a, b)        _mm_xor_si128(a, b)
    #define XOReq128(a, b)      a = _mm_xor_si128(a, b)
    #define GET64LOLO(a, b)     _mm_unpacklo_epi64(a, b)
    #define GET64HIHI(a, b)     _mm_unpackhi_epi64(a, b)
    #define COPY64HI2LO(a)      _mm_shuffle_epi32(a, 0xEE)
    #define COPY64LO2HI(a)      _mm_shuffle_epi32(a, 0x44)
    #define ZERO128()           _mm_setzero_si128()
    
    void KeccakPermutationOnWords(UINT64 *state)
    {
      ALIGN static const UINT64 rho8_56[2]={0x0605040302010007, 0x080F0E0D0C0B0A09};
      static const UINT64 KeccakF1600RoundConstants[24] = {
        0x0000000000000001ULL,
        0x0000000000008082ULL,
        0x800000000000808aULL,
        0x8000000080008000ULL,
        0x000000000000808bULL,
        0x0000000080000001ULL,
        0x8000000080008081ULL,
        0x8000000000008009ULL,
        0x000000000000008aULL,
        0x0000000000000088ULL,
        0x0000000080008009ULL,
        0x000000008000000aULL,
        0x000000008000808bULL,
        0x800000000000008bULL,
        0x8000000000008089ULL,
        0x8000000000008003ULL,
        0x8000000000008002ULL,
        0x8000000000000080ULL,
        0x000000000000800aULL,
        0x800000008000000aULL,
        0x8000000080008081ULL,
        0x8000000000008080ULL,
        0x0000000080000001ULL,
        0x8000000080008008ULL };
    
      V6464 Abage, Abegi;
      V6464 Akame, Akemi;
      V6464 Abae, Abio, Agae, Agio, Akae, Akio, Amae, Amio, Asae, Asio;
      V64 Aba, Abe, Abi, Abo, Abu;
      V64 Aga, Age, Agi, Ago, Agu;
      V64 Aka, Ake, Aki, Ako, Aku;
      V64 Ama, Ame, Ami, Amo, Amu;
      V64 Asa, Ase, Asi, Aso, Asu;
      V128 Bbage, Bbegi, Bbigo, Bbogu, Bbuga;
      V128 Bkame, Bkemi, Bkimo, Bkomu, Bkuma;
      V64 Bba, Bbe, Bbi, Bbo, Bbu;
      V64 Bga, Bge, Bgi, Bgo, Bgu;
      V64 Bka, Bke, Bki, Bku;
      V64 Bma, Bme, Bmi, Bmo;
      V64 Bsa, Bse, Bsi, Bso, Bsu;
      V128 Cae, Cei, Cio, Cou, Cua, Dei, Dou;
      V64 Ca, Ce, Ci, Co, Cu;
      V64 Da, De, Di, Do, Du;
      V6464 Ebage, Ebegi, Ebigo, Ebogu, Ebuga;
      V6464 Ekame, Ekemi, Ekimo, Ekomu, Ekuma;
      V64 Ebi, Ebo, Ebu;
      V64 Ega, Ego, Egu;
      V64 Eki, Eko, Eku;
      V64 Ema, Emo, Emu;
      V64 Esa, Ese, Esi, Eso, Esu;
      V128 Zero;
    
      Abae.v128 = LOAD128(state[ 0]);
      Aba = Abae.v128;
      Abe = GET64HIHI(Abae.v128, Abae.v128);
      Cae = Abae.v128;
      Abio.v128 = LOAD128(state[ 2]);
      Abi = Abio.v128;
      Abo = GET64HIHI(Abio.v128, Abio.v128);
      Cio = Abio.v128;
      Abu = LOAD64(state[ 4]);
      Cu = Abu;
      Agae.v128 = LOAD128u(state[ 5]);
      Aga = Agae.v128;
      Age = GET64HIHI(Agae.v128, Agae.v128);
      Abage.v128 = GET64LOLO(Aba, Age);
      XOReq128(Cae, Agae.v128);
      Agio.v128 = LOAD128u(state[ 7]);
      Agi = Agio.v128;
      Abegi.v128 = GET64LOLO(Abe, Agi);
      Ago = GET64HIHI(Agio.v128, Agio.v128);
      XOReq128(Cio, Agio.v128);
      Agu = LOAD64(state[ 9]);
      XOReq64(Cu, Agu);
      Akae.v128 = LOAD128(state[10]);
      Aka = Akae.v128;
      Ake = GET64HIHI(Akae.v128, Akae.v128);
      XOReq128(Cae, Akae.v128);
      Akio.v128 = LOAD128(state[12]);
      Aki = Akio.v128;
      Ako = GET64HIHI(Akio.v128, Akio.v128);
      XOReq128(Cio, Akio.v128);
      Aku = LOAD64(state[14]);
      XOReq64(Cu, Aku);
      Amae.v128 = LOAD128u(state[15]);
      Ama = Amae.v128;
      Ame = GET64HIHI(Amae.v128, Amae.v128);
      Akame.v128 = GET64LOLO(Aka, Ame);
      XOReq128(Cae, Amae.v128);
      Amio.v128 = LOAD128u(state[17]);
      Ami = Amio.v128;
      Akemi.v128 = GET64LOLO(Ake, Ami);
      Amo = GET64HIHI(Amio.v128, Amio.v128);
      XOReq128(Cio, Amio.v128);
      Amu = LOAD64(state[19]);
      XOReq64(Cu, Amu);
      Asae.v128 = LOAD128(state[20]);
      Asa = Asae.v128;
      Ase = GET64HIHI(Asae.v128, Asae.v128);
      XOReq128(Cae, Asae.v128);
      Asio.v128 = LOAD128(state[22]);
      Asi = Asio.v128;
      Aso = GET64HIHI(Asio.v128, Asio.v128);
      XOReq128(Cio, Asio.v128);
      Asu = LOAD64(state[24]);
      XOReq64(Cu, Asu);
    
      for(int i=0; i<24; i++) {
    
        Cua = GET64LOLO(Cu, Cae);
        Dei = XOR128(Cae, ROL64in128(Cio, 1));
        Dou = XOR128(Cio, ROL64in128(Cua, 1));
        Da = XOR64(Cu, ROL64in128(COPY64HI2LO(Cae), 1));
        De = Dei;
        Di = COPY64HI2LO(Dei);
        Do = Dou;
        Du = COPY64HI2LO(Dou);
    
        Aba = LOAD64(Abage.v64[0]);
        XOReq64(Aba, Da);
        Bba = Aba;
        XOReq64(Agu, Du);
        Bge = ROL64(Agu, 20);
        Bbage = GET64LOLO(Bba, Bge);
        Age = LOAD64(Abage.v64[1]);
        XOReq64(Age, De);
        Bbe = ROL64(Age, 44);
        Aka = LOAD64(Akame.v64[0]);
        XOReq64(Aka, Da);
        Bgi = ROL64(Aka, 3);
        Bbegi = GET64LOLO(Bbe, Bgi);
        XOReq64(Aki, Di);
        Bbi = ROL64(Aki, 43);
        Ame = LOAD64(Akame.v64[1]);
        XOReq64(Ame, De);
        Bgo = ROL64(Ame, 45);
        Bbigo = GET64LOLO(Bbi, Bgo);
        Ebage.v128 = XOR128(Bbage, ANDnu128(Bbegi, Bbigo));
        XOReq128(Ebage.v128, CONST64(KeccakF1600RoundConstants[i]));
        Cae = Ebage.v128;
        XOReq64(Amo, Do);
        Bbo = ROL64(Amo, 21);
        XOReq64(Asi, Di);
        Bgu = ROL64(Asi, 61);
        Bbogu = GET64LOLO(Bbo, Bgu);
        Ebegi.v128 = XOR128(Bbegi, ANDnu128(Bbigo, Bbogu));
        Cei = Ebegi.v128;
        XOReq64(Asu, Du);
        Bbu = ROL64(Asu, 14);
        XOReq64(Abo, Do);
        Bga = ROL64(Abo, 28);
        Bbuga = GET64LOLO(Bbu, Bga);
        Ebigo.v128 = XOR128(Bbigo, ANDnu128(Bbogu, Bbuga));
        Ebi = Ebigo.v128;
        Ego = GET64HIHI(Ebigo.v128, Ebigo.v128);
        Cio = Ebigo.v128;
        Ebogu.v128 = XOR128(Bbogu, ANDnu128(Bbuga, Bbage));
        Ebo = Ebogu.v128;
        Egu = GET64HIHI(Ebogu.v128, Ebogu.v128);
        Cou = Ebogu.v128;
        Ebuga.v128 = XOR128(Bbuga, ANDnu128(Bbage, Bbegi));
        Ebu = Ebuga.v128;
        Ega = GET64HIHI(Ebuga.v128, Ebuga.v128);
        Cua = Ebuga.v128;
    
        Abe = LOAD64(Abegi.v64[0]);
        XOReq64(Abe, De);
        Bka = ROL64(Abe, 1);
        XOReq64(Aga, Da);
        Bme = ROL64(Aga, 36);
        Bkame = GET64LOLO(Bka, Bme);
        Agi = LOAD64(Abegi.v64[1]);
        XOReq64(Agi, Di);
        Bke = ROL64(Agi, 6);
        Ake = LOAD64(Akemi.v64[0]);
        XOReq64(Ake, De);
        Bmi = ROL64(Ake, 10);
        Bkemi = GET64LOLO(Bke, Bmi);
        XOReq64(Ako, Do);
        Bki = ROL64(Ako, 25);
        Ami = LOAD64(Akemi.v64[1]);
        XOReq64(Ami, Di);
        Bmo = ROL64(Ami, 15);
        Bkimo = GET64LOLO(Bki, Bmo);
        Ekame.v128 = XOR128(Bkame, ANDnu128(Bkemi, Bkimo));
        XOReq128(Cae, Ekame.v128);
        Bkomu = GET64LOLO(XOR64(Amu, Du), XOR64(Aso, Do));
        Bkomu = SHUFFLEBYTES128(Bkomu, CONST128(rho8_56));
        Ekemi.v128 = XOR128(Bkemi, ANDnu128(Bkimo, Bkomu));
        XOReq128(Cei, Ekemi.v128);
        XOReq64(Asa, Da);
        Bku = ROL64(Asa, 18);
        XOReq64(Abu, Du);
        Bma = ROL64(Abu, 27);
        Bkuma = GET64LOLO(Bku, Bma);
        Ekimo.v128 = XOR128(Bkimo, ANDnu128(Bkomu, Bkuma));
        Eki = Ekimo.v128;
        Emo = GET64HIHI(Ekimo.v128, Ekimo.v128);
        XOReq128(Cio, Ekimo.v128);
        Ekomu.v128 = XOR128(Bkomu, ANDnu128(Bkuma, Bkame));
        Eko = Ekomu.v128;
        Emu = GET64HIHI(Ekomu.v128, Ekomu.v128);
        XOReq128(Cou, Ekomu.v128);
        Ekuma.v128 = XOR128(Bkuma, ANDnu128(Bkame, Bkemi));
        Eku = Ekuma.v128;
        Ema = GET64HIHI(Ekuma.v128, Ekuma.v128);
        XOReq128(Cua, Ekuma.v128);
    
        XOReq64(Abi, Di);
        Bsa = ROL64(Abi, 62);
        XOReq64(Ago, Do);
        Bse = ROL64(Ago, 55);
        XOReq64(Aku, Du);
        Bsi = ROL64(Aku, 39);
        Esa = XOR64(Bsa, ANDnu64(Bse, Bsi));
        Ca = Esa;
        XOReq64(Ama, Da);
        Bso = ROL64(Ama, 41);
        Ese = XOR64(Bse, ANDnu64(Bsi, Bso));
        Ce = Ese;
        XOReq128(Cae, GET64LOLO(Ca, Ce));
        XOReq64(Ase, De);
        Bsu = ROL64(Ase, 2);
        Esi = XOR64(Bsi, ANDnu64(Bso, Bsu));
        Ci = Esi;
        Eso = XOR64(Bso, ANDnu64(Bsu, Bsa));
        Co = Eso;
        XOReq128(Cio, GET64LOLO(Ci, Co));
        Esu = XOR64(Bsu, ANDnu64(Bsa, Bse));
        Cu = Esu;
    
        Zero = ZERO128();
        XOReq128(Cae, GET64HIHI(Cua, Zero));
        XOReq128(Cae, GET64LOLO(Zero, Cei));
        XOReq128(Cio, GET64HIHI(Cei, Zero));
        XOReq128(Cio, GET64LOLO(Zero, Cou));
        XOReq128(Cua, GET64HIHI(Cou, Zero));
        XOReq64(Cu, Cua);
    
        Abage = Ebage;
        Abegi = Ebegi;
        Abi = Ebi;
        Abo = Ebo;
        Abu = Ebu;
        Aga = Ega;
        Ago = Ego;
        Agu = Egu;
        Akame = Ekame;
        Akemi = Ekemi;
        Aki = Eki;
        Ako = Eko;
        Aku = Eku;
        Ama = Ema;
        Amo = Emo;
        Amu = Emu;
        Asa = Esa;
        Ase = Ese;
        Asi = Esi;
        Aso = Eso;
        Asu = Esu;
      }
    
      state[ 0] = Abage.v64[0];
      state[ 1] = Abegi.v64[0];
      STORE64(state[ 2], Abi);
      STORE64(state[ 3], Abo);
      STORE64(state[ 4], Abu);
      STORE64(state[ 5], Aga);
      state[ 6] = Abage.v64[1];
      state[ 7] = Abegi.v64[1];
      STORE64(state[ 8], Ago);
      STORE64(state[ 9], Agu);
      state[10] = Akame.v64[0];
      state[11] = Akemi.v64[0];
      STORE64(state[12], Aki);
      STORE64(state[13], Ako);
      STORE64(state[14], Aku);
      STORE64(state[15], Ama);
      state[16] = Akame.v64[1];
      state[17] = Akemi.v64[1];
      STORE64(state[18], Amo);
      STORE64(state[19], Amu);
      STORE64(state[20], Asa);
      STORE64(state[21], Ase);
      STORE64(state[22], Asi);
      STORE64(state[23], Aso);
      STORE64(state[24], Asu);
    }
    
    // Compute a SHA3 (Keccak[r,c]) hash with rate r
    // To compute a hash, put() the input bytes and get() the result.
    // For SHA3-{224,256,384,512} set r={1152,1088,832,576}.
    template <int r>
    class Keccak {
    public:
      void put(int ch);  // Hash 1 byte
      int get();         // Retrieve next byte of hash
      void init();       // Reset state to compute a new hash
      Keccak() {init();}
    private:
      UINT64 state[25];  // Keccak hash state
      unsigned ptr;      // next byte to get/put (range 0..r/8)
      enum {ABSORB, SQUEEZE} spongeState;  // putting or getting?
      void f();          // Keccak-F function
    };
    
    // Reset hash state to accept a new input message.
    template <int r>
    void Keccak<r>::init() {
      memset(state, 0, sizeof(state));
      ptr=0;
      spongeState=ABSORB;
    }
    
    // Hash 1 byte. Reset state if this is the first byte.
    template <int r>
    void Keccak<r>::put(int ch) {
      assert(ptr>=0 && ptr<r/8);
      assert(ch>=0 && ch<=255);
      assert(spongeState==ABSORB);
      state[ptr/8]^=UINT64(ch)<<(ptr%8*8);
      if (++ptr==r/8) f();
    }
    
    // Get 1 byte of hash. If this is the first byte then pad the input.
    template <int r>
    int Keccak<r>::get() {
      if (spongeState==ABSORB) {  // first get()?
        assert(ptr>=0 && ptr<r/8);
        if (ptr==r/8-1)
          put(0x81);
        else {
          put(1);
          while (ptr<r/8-1) put(0);
          put(0x80);
        }
        spongeState=SQUEEZE;
        assert(ptr==0);
      }
      assert(ptr>=0 && ptr<=r/8);
      if (ptr==r/8) f();
      int ch=(state[ptr/8]>>(ptr%8*8))&255;
      ++ptr;
      return ch;
    }
    
    // Compute rounds
    template <int r>
    void Keccak<r>::f() {
      assert(ptr==r/8);
      KeccakPermutationOnWords(state);
      ptr=0;
    }
    
    // Compute hash of each arg
    int main(int argc, char** argv) {
      Keccak<576> keccak;
      for (int i=1; i<argc; ++i) {
        FILE* in=fopen(argv[i], "rb");
        if (!in)
          perror(argv[i]);
        else {
          keccak.init();
          for (int c; (c=getc(in))!=EOF; keccak.put(c));
          fclose(in);
          for (int j=0; j<64; ++j) printf("%02x", keccak.get());
          printf(" %s\n", argv[i]);
        }
      }
      return 0;
    }
    Edit: there are 6 variants of the optimized code. I used #define UseSSE. I could not get UseXOP to work, and the others would be slower. I couldn't get any of the faster versions to work in VC++. There are also options to unroll the rounds, but I found it was slower that way. I kept the byte oriented version to keep it simple, even though it could probably be faster using block I/O.
    Last edited by Matt Mahoney; 25th November 2012 at 06:07.

  28. #28
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts
    Have you tested my "union" trick to load the bytes? I see you still use "state[ptr/8]^=UINT64(ch)<<(ptr%8*;"
    64-bit shift is super-slow on a 32-bit machine! You could use just "buf[ptr]^=ch;" No shifts, same simplicity! You just load bytes to buf, and use state as usual...

  29. #29
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts
    BTW, new version of CHK will be released very soon. New version 1.10 (non-beta!!!) - is a major update, featuring serious speed improvements, some important bug-fixes, new hashes, and more.

    To help user choose the right hash function, CHK will show a quick one-line tip for each hash (in status bar).
    Please revise it:

    CRC16 ->
    16-bit checksum (one word that warns about its high rate of collisions), not secure

    CRC32 ->
    32-bit checksum, not secure

    CRC64 ->
    64-bit checksum, not secure

    MD4 ->
    128-bit cryptographic hash (broken), not secure

    MD5 ->
    128-bit cryptographic hash (broken), not secure

    SHA1 ->
    160-bit cryptographic hash (broken), not secure

    SHA256 ->
    256-bit cryptographic hash, secure

    SHA512 ->
    512-bit cryptographic hash, very secure

    SHA3 ->
    512-bit cryptographic hash, very secure

  30. #30
    The Founder encode's Avatar
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    3,954
    Thanks
    359
    Thanked 332 Times in 131 Posts
    Also, how to mark high collision rate of CRC16? (I'll keep it anyway, since LHA/LZH use it)
    One more question, is "highly secure" more correct phrase than "very secure"?

Page 1 of 2 12 LastLast

Similar Threads

  1. CHK wishlist
    By encode in forum The Off-Topic Lounge
    Replies: 64
    Last Post: 17th March 2012, 13:51
  2. CHK 1.02 - file analysis tool
    By encode in forum Data Compression
    Replies: 6
    Last Post: 24th July 2011, 15:46
  3. CHK 1.01 is here! (New GUI MD5/SHA1 file checker)
    By encode in forum Data Compression
    Replies: 24
    Last Post: 20th July 2011, 08:45

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •