Giter Site home page Giter Site logo

sha-3's Introduction

This is a C++ implementation of the SHA-3 family of hash functions, based on 
the documentation found at 
http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf
Download binaries at: http://www.danielhorne.co.uk/Projects/SHA-3/SHA3.html

Usage: sha3sum [command]* file*

 where command is an optional parameter that can set either the algorithm, as
 there is a slight difference between the bare keccak function and the SHA-3
 variant.
 
 Algorithm 
 
 -a=s   :  Set algorithm to SHA-3 (default).
 -a=k   :  Set algotithm to Keccak.
 -a=h   :  Set algorithm to SHAKE
 
 Size
 
 -w=224 :  Set width to 224 bits.
 -w=256 :  Set width to 256 bits.
 -w=384 :  Set width to 384 bits.
 -w=512 :  Set width to 512 bits (default).
 
 Digest size (SHAKE)
 
 -d=number : Set the SHAKE digest size. Should be less than or equal to the hash size.
       Should be multiple of 8
       Only relevant for SHAKE - For SHA-3 and keccak, digest size is equal to sponge size.

 Output format
 
 -o=b : Base 64 encoded.
 -o=h : hexadecimal (default)
 
Any number of files can be specified. Files will be processed with the most
recently specified options - for example:

  sha3sum test.txt -a=k -w=384 test.txt -a=s -w=256 text.txt

will hash "test.txt" three times - First with 512-bit SHA-3, then with 384-bit
keccak, then finally with 256-bit SHA-3.



The intent with this implementation is to make a performant implementation in 
pure C++, following modern idioms: Favouring inline functions over macros, 
leaning on the compiler's optimiser instead of resorting to inline assembly,
for example. 

ToDo:

- Add command option to set the chunk size for reading.

- Attempt formal proof of important aspects of this implementation. 

Bugs:

- Any bugs, please either add them to the github repo 
  (https://github.com/DuSTman31/SHA-3/issues), or e-mail me at
  [email protected] (remove "-"s).
  
- Will document the design and verification on www.danielhorne.co.uk when I 
  get round to it.

sha-3's People

Contributors

bytesbyharsh avatar dustman31 avatar i-am-cjc avatar mcshaz avatar oyheskes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sha-3's Issues

Different result between Debug and Release

My Code:

qq20170621-224605 2x

Input ”A“

Debug(Correct):
421a35a60054e5f383b6137e43d44e998f496748cc77258240ccfaa8730b51f40cf47c1bc09c728a8cd4f096731298d51463f15af89543fed478053346260c38

Release:
fff33bdfffbfdbffb5712b45afaa596feaf59e440bf66b0f18948e4cc9ebc144e7c9f0a0aa3c8fc7375e2a4fc8add620f28210b2cb87f1d040448b62fbe7392a

Error when try execute program in Visual studio 2017

'Keccak.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\kernel32.dll'
The thread 0x1184 has exited with code 0 (0x0).
The program '[8172] Keccak.exe' has exited with code 0 (0x0).

What version you use VS ?
Or how I can solve this problem ?

keccakUpdate can be called with incorrect amount of data parameter..

Bjorn Nilsson pointed out the following:

In the doFile function, the keccakUpdate call looks different for the three hash types:

For hashType 0: keccakUpdate((uint8_t*)buf, 0, bytesRead, st);
For hashType 1: keccakUpdate((uint8_t*)buf, 0, bufferSize, st);
For hashType 2: keccakUpdate((uint8_t*)buf, 0, bufferSize, st);

Is the difference bytesRead vs bufferSize intentional? It seems to me the code might feed uninitialized buffer for hashType 1 and 2 if bytesRead<bufferSize.

This is correct - it should have been bytesRead. This was likely missed when I converted the project from reading the whole file at once. I have pushed the fix, and encourage users to update to this version.

sha3Digest

Its complete junk.
1)state->length isnt a uint64_t count.
2)A is a 25 uint64
3)'for' really terrible

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.