def stream

bend-collections@1.0.0.0 · src/crypto/sha/core.bend:1128

import bend-collections@1.0.0.0/src/crypto/sha/core.bend as Core
import Base
import bend-collections@1.0.0.0/src/crypto/sha/state.bend as S

1128# Compress complete 64-byte blocks straight from the input list, so the
1129# message is never copied, counted or reversed. count is the number of bytes
1130# already hashed and extra the number of derived schedule words (48).
1131def stream(+bytes: List<&2, U32>, count: Nat, +extra: Nat, s: S.State) -> S.State:
1132  match bytes:
1133    case b0 <> b1 <> b2 <> b3 <> b4 <> b5 <> b6 <> b7 <> b8 <> b9 <> b10 <> b11 <> b12 <> b13 <> b14 <> b15 <> b16 <> b17 <> b18 <> b19 <> b20 <> b21 <> b22 <> b23 <> b24 <> b25 <> b26 <> b27 <> b28 <> b29 <> b30 <> b31 <> b32 <> b33 <> b34 <> b35 <> b36 <> b37 <> b38 <> b39 <> b40 <> b41 <> b42 <> b43 <> b44 <> b45 <> b46 <> b47 <> b48 <> b49 <> b50 <> b51 <> b52 <> b53 <> b54 <> b55 <> b56 <> b57 <> b58 <> b59 <> b60 <> b61 <> b62 <> b63 <> rest:
1134      stream(rest, Nat.add(64n, count), extra, fips_compress16(
1135        pack(b0, b1, b2, b3), pack(b4, b5, b6, b7), pack(b8, b9, b10, b11), pack(b12, b13, b14, b15),
1136        pack(b16, b17, b18, b19), pack(b20, b21, b22, b23), pack(b24, b25, b26, b27), pack(b28, b29, b30, b31),
1137        pack(b32, b33, b34, b35), pack(b36, b37, b38, b39), pack(b40, b41, b42, b43), pack(b44, b45, b46, b47),
1138        pack(b48, b49, b50, b51), pack(b52, b53, b54, b55), pack(b56, b57, b58, b59), pack(b60, b61, b62, b63),
1139        extra, s))
1140    case _:
1141      finish(bytes, count, extra, s)

Uses (8)

Used by (3)