mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.11.0t10
This commit is contained in:
61
shs1.c
61
shs1.c
@@ -5,20 +5,20 @@
|
||||
*
|
||||
* This file was Modified/Re-written by:
|
||||
*
|
||||
* Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
* Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
*
|
||||
* chongo <was here> /\../\
|
||||
* chongo <was here> /\../\
|
||||
*
|
||||
* This code has been placed in the public domain. Please do not
|
||||
* copyright this code.
|
||||
*
|
||||
* LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT
|
||||
* NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT
|
||||
* NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
|
||||
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -40,23 +40,23 @@
|
||||
* f1: ((x&y) | (~x&z)) == (z ^ (x&(y^z)))
|
||||
* f3: ((x&y) | (x&z) | (y&z)) == ((x&y) | (z&(x|y)))
|
||||
*/
|
||||
#define f1(x,y,z) (z ^ (x&(y^z))) /* Rounds 0-19 */
|
||||
#define f2(x,y,z) (x^y^z) /* Rounds 20-39 */
|
||||
#define f3(x,y,z) ((x&y) | (z&(x|y))) /* Rounds 40-59 */
|
||||
#define f4(x,y,z) (x^y^z) /* Rounds 60-79 */
|
||||
#define f1(x,y,z) (z ^ (x&(y^z))) /* Rounds 0-19 */
|
||||
#define f2(x,y,z) (x^y^z) /* Rounds 20-39 */
|
||||
#define f3(x,y,z) ((x&y) | (z&(x|y))) /* Rounds 40-59 */
|
||||
#define f4(x,y,z) (x^y^z) /* Rounds 60-79 */
|
||||
|
||||
/* The SHS1 Mysterious Constants */
|
||||
#define K1 0x5A827999L /* Rounds 0-19 */
|
||||
#define K2 0x6ED9EBA1L /* Rounds 20-39 */
|
||||
#define K3 0x8F1BBCDCL /* Rounds 40-59 */
|
||||
#define K4 0xCA62C1D6L /* Rounds 60-79 */
|
||||
#define K1 0x5A827999L /* Rounds 0-19 */
|
||||
#define K2 0x6ED9EBA1L /* Rounds 20-39 */
|
||||
#define K3 0x8F1BBCDCL /* Rounds 40-59 */
|
||||
#define K4 0xCA62C1D6L /* Rounds 60-79 */
|
||||
|
||||
/* SHS1 initial values */
|
||||
#define h0init 0x67452301L
|
||||
#define h1init 0xEFCDAB89L
|
||||
#define h2init 0x98BADCFEL
|
||||
#define h3init 0x10325476L
|
||||
#define h4init 0xC3D2E1F0L
|
||||
#define h0init 0x67452301L
|
||||
#define h1init 0xEFCDAB89L
|
||||
#define h2init 0x98BADCFEL
|
||||
#define h3init 0x10325476L
|
||||
#define h4init 0xC3D2E1F0L
|
||||
|
||||
/* 32-bit rotate left - kludged with shifts */
|
||||
#define LEFT_ROT(X,n) (((X)<<(n)) | ((X)>>(32-(n))))
|
||||
@@ -67,7 +67,7 @@
|
||||
* 80-word expanded input array W, where the first 16 are copies of the input
|
||||
* data, and the remaining 64 are defined by
|
||||
*
|
||||
* W[i] = LEFT_ROT(W[i-16] ^ W[i-14] ^ W[i-8] ^ W[i-3], 1)
|
||||
* W[i] = LEFT_ROT(W[i-16] ^ W[i-14] ^ W[i-8] ^ W[i-3], 1)
|
||||
*
|
||||
* NOTE: The expanding function used in rounds 16 to 79 was changed from the
|
||||
* original SHA (in FIPS Pub 180) to one that also left circular shifted
|
||||
@@ -80,11 +80,11 @@
|
||||
/*
|
||||
* The prototype SHS1 sub-round. The fundamental sub-round is:
|
||||
*
|
||||
* a' = e + LEFT_ROT(a,5) + f(b,c,d) + k + data;
|
||||
* b' = a;
|
||||
* c' = LEFT_ROT(b,30);
|
||||
* d' = c;
|
||||
* e' = d;
|
||||
* a' = e + LEFT_ROT(a,5) + f(b,c,d) + k + data;
|
||||
* b' = a;
|
||||
* c' = LEFT_ROT(b,30);
|
||||
* d' = c;
|
||||
* e' = d;
|
||||
*
|
||||
* but this is implemented by unrolling the loop 5 times and renaming the
|
||||
* variables ( e, a, b, c, d ) = ( a', b', c', d', e' ) each iteration.
|
||||
@@ -319,7 +319,7 @@ shs1Update(HASH *state, USB8 *buffer, USB32 count)
|
||||
* Next if we have more than 56 bytes, we will zero fill the remainder
|
||||
* of the chunk, transform and then zero fill the first 56 bytes.
|
||||
* If we have 56 or fewer bytes, we will zero fill out to the 56th
|
||||
* chunk byte. Regardless, we wind up with 56 bytes data.
|
||||
* chunk byte. Regardless, we wind up with 56 bytes data.
|
||||
*
|
||||
* Finally we append the 64 bit length on to the 56 bytes of data
|
||||
* remaining. This final chunk is transformed.
|
||||
@@ -357,8 +357,7 @@ shs1Final(HASH *state)
|
||||
for (i=0; i < SHS1_CHUNKWORDS; ++i) {
|
||||
SWAP_B8_IN_B32(dig->data+i, dig->data+i);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (count % 4) {
|
||||
math_error("This should not happen in shs1Final");
|
||||
/*NOTREACHED*/
|
||||
@@ -673,13 +672,13 @@ shs1_print(HASH *state)
|
||||
* form the hash value
|
||||
*/
|
||||
if (conf->calc_debug & CALCDBG_HASH_STATE) {
|
||||
char buf[DEBUG_SIZE+1]; /* hash value buffer */
|
||||
char buf[DEBUG_SIZE+1]; /* hash value buffer */
|
||||
|
||||
/*
|
||||
* print numeric debug value
|
||||
*
|
||||
* NOTE: This value represents only the hash value as of
|
||||
* the last full update or finalization. Thus it
|
||||
* the last full update or finalization. Thus it
|
||||
* may NOT be the actual hash value.
|
||||
*/
|
||||
sprintf(buf,
|
||||
|
Reference in New Issue
Block a user