// Copyright 2009 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package sha1import ()const ( _K0 = 0x5A827999 _K1 = 0x6ED9EBA1 _K2 = 0x8F1BBCDC _K3 = 0xCA62C1D6)// blockGeneric is a portable, pure Go version of the SHA-1 block step.// It's used by sha1block_generic.go and tests.func blockGeneric( *digest, []byte) {var [16]uint32 , , , , := .h[0], .h[1], .h[2], .h[3], .h[4]forlen() >= chunk {// Can interlace the computation of w with the // rounds below if needed for speed.for := 0; < 16; ++ { := * 4 [] = uint32([])<<24 | uint32([+1])<<16 | uint32([+2])<<8 | uint32([+3]) } , , , , := , , , , // Each of the four 20-iteration rounds // differs only in the computation of f and // the choice of K (_K0, _K1, etc). := 0for ; < 16; ++ { := & | (^)& := bits.RotateLeft32(, 5) + + + [&0xf] + _K0 , , , , = , , bits.RotateLeft32(, 30), , }for ; < 20; ++ { := [(-3)&0xf] ^ [(-8)&0xf] ^ [(-14)&0xf] ^ [()&0xf] [&0xf] = bits.RotateLeft32(, 1) := & | (^)& := bits.RotateLeft32(, 5) + + + [&0xf] + _K0 , , , , = , , bits.RotateLeft32(, 30), , }for ; < 40; ++ { := [(-3)&0xf] ^ [(-8)&0xf] ^ [(-14)&0xf] ^ [()&0xf] [&0xf] = bits.RotateLeft32(, 1) := ^ ^ := bits.RotateLeft32(, 5) + + + [&0xf] + _K1 , , , , = , , bits.RotateLeft32(, 30), , }for ; < 60; ++ { := [(-3)&0xf] ^ [(-8)&0xf] ^ [(-14)&0xf] ^ [()&0xf] [&0xf] = bits.RotateLeft32(, 1) := (( | ) & ) | ( & ) := bits.RotateLeft32(, 5) + + + [&0xf] + _K2 , , , , = , , bits.RotateLeft32(, 30), , }for ; < 80; ++ { := [(-3)&0xf] ^ [(-8)&0xf] ^ [(-14)&0xf] ^ [()&0xf] [&0xf] = bits.RotateLeft32(, 1) := ^ ^ := bits.RotateLeft32(, 5) + + + [&0xf] + _K3 , , , , = , , bits.RotateLeft32(, 30), , } += += += += += = [chunk:] } .h[0], .h[1], .h[2], .h[3], .h[4] = , , , , }
The pages are generated with Goldsv0.7.0-preview. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.