nanpuyue / sha256 Goto Github PK
View Code? Open in Web Editor NEWA Pure Rust Implementation of SHA-256 Algorithm
Home Page: https://blog.nanpuyue.com/2019/049.html
License: Apache License 2.0
A Pure Rust Implementation of SHA-256 Algorithm
Home Page: https://blog.nanpuyue.com/2019/049.html
License: Apache License 2.0
There are two bugs in the implementation that prevent the KAT from passing.
First, the main compression function is implemented incorrectly. Lines 77-84 update the primary state after each of the 64 rounds of the algorithm, however this is incorrect. The state is not to be updated until AFTER all 64 rounds - see NIST FIPS 180-4 6.2.2 steps 2 and 4. In step 2, a copy of the previous round state is put into temporary variables, then the copies of the state are updated in each round in step 3. In step 4, the new state is created from the old state and the copies of the state variables (a, b, c,...).
The second problem is in the length construction. Use of the update function creates problems as a full block is not create. The final method needs to handle the length construction to input a full block into the compression function. In some cases this requires a new block to be created because there are not 65 bits leftover in the buffer. The whole final function needs to be rewritten.
I have made both fixes in my private area and now pass the KAT tests. See the KAT tests here: https://www.di-mgt.com.au/sha_testvectors.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.