~/bend-docscommunity

sha1.bend checks

raw source on the hub · import bend-osdev-hashes@0.1.0.0/sha1.bend as Sha1

SHA-1 (FIPS 180-4, Secure Hash Standard, 2015, sections 4.1.1, 4.2.1, 5.1.1, 5.3.1 and 6.1): a 160-bit digest of 64-byte blocks, eighty steps over a message schedule of eighty words (unrolled by gen/rounds.py). Big-endian words; the length in bits is padded in big-endian. SHA-1 is broken for collisions (SHAttered, 2017): it is here for HMAC-SHA-1, PBKDF2-HMAC-SHA-1 and the formats that require it.

The hash, as the crypto package's hash interface takes it: ~Hs.HsMdState<Hs.HsW5>, ~64n, ~20n, ~HsSha1.init(), ~HsSha1.update, ~HsSha1.final, ~HsSha1.digest

3 imports
import Base
import bend-osdev-bytes@0.1.0.0/bytes.bend as B
import ./hashes.bend as Hs

Definitions

def hs.sha1.ch source · line 17 · raw

@+x:U32 -> @y:U32 -> @z:U32 -> U32

the functions of section 4.1.1: Ch (steps 0 to 19), Parity (20 to 39 and 60 to 79), Maj (40 to 59)

def hs.sha1.parity source · line 20 · raw

@x:U32 -> @y:U32 -> @z:U32 -> U32

def hs.sha1.maj source · line 23 · raw

@+x:U32 -> @+y:U32 -> @+z:U32 -> U32

def hs.sha1.rounds source · line 27 · raw

@x:0xd04c3185dce130521497bf85ab03f249/hashes.HsW16 -> @cv:0xd04c3185dce130521497bf85ab03f249/hashes.HsW5 -> 0xd04c3185dce130521497bf85ab03f249/hashes.HsW5

BEGIN GENERATED by gen/rounds.py: sha1

def HsSha1.iv source · line 262 · raw

0xd04c3185dce130521497bf85ab03f249/hashes.HsW5

The chaining value before any block (section 5.3.1)

def HsSha1.compress source · line 267 · raw

@cv:0xd04c3185dce130521497bf85ab03f249/hashes.HsW5 -> @blk:List<&2, U32> -> 0xd04c3185dce130521497bf85ab03f249/hashes.HsW5

One 64-byte block (a list of another length is read as zero words: the engine passes only whole blocks)

def HsSha1.init source · line 270 · raw

0xd04c3185dce130521497bf85ab03f249/hashes.HsMdState<0xd04c3185dce130521497bf85ab03f249/hashes.HsW5>

def HsSha1.update source · line 273 · raw

@s:0xd04c3185dce130521497bf85ab03f249/hashes.HsMdState<0xd04c3185dce130521497bf85ab03f249/hashes.HsW5> -> @o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> 0xd04c3185dce130521497bf85ab03f249/hashes.HsMdState<0xd04c3185dce130521497bf85ab03f249/hashes.HsW5>

def HsSha1.final source · line 278 · raw

@s:0xd04c3185dce130521497bf85ab03f249/hashes.HsMdState<0xd04c3185dce130521497bf85ab03f249/hashes.HsW5> -> 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets

the digest of the bytes so far: the padding of section 5.1.1, then the five words big-endian

def HsSha1.digest source · line 282 · raw

@o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets

The digest in one call