Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/om/components/cm_digest.om # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / om / components / cm_digest.om` 61 lines · 1225 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note Reuses om/cache/digest.om's SHA-256 schedule, constants, rounds and padding. 3 note Mode 0 initializes; mode 1 consumes 64 bytes; mode 2 finishes tail state[9] and writes data[0:32]. 4 note State[0:8] is the chaining value and state[8] is consumed bytes. Mode 3 compares data[0:32] and [32:64]. 5 fn cm_sha_output s view uint 8 data edit uchar 128 to void 6 for i ulong 8 7 for j ulong 4 8 q = add mul i 4 j 9 v = shr get s i mul sub ulong 3 j 8 10 put data q uchar and v 255 11 end 12 end 13 end 14 fn cm_digest mode ulong state edit ulong 16 data edit uchar 128 to ulong 15 if eq mode 3 16 for i ulong 32 17 if ne get data i get data add 32 i 18 ret 0 19 end 20 end 21 ret 1 22 end 23 s = new uint 8 0 24 if eq mode 0 25 kc_iv s 26 for i ulong 8 27 put state i ulong get s i 28 end 29 put state 8 ulong 0 30 ret 0 31 end 32 for i ulong 8 33 put s i uint get state i 34 end 35 w = new uint 64 0 36 kt = new uint 64 0 37 kc_k kt 38 if eq mode 1 39 kc_padsched w data 0 40 kc_rounds s w kt 41 put state 8 add get state 8 64 42 else 43 used = get state 9 44 if ge used 64 45 ret 1 46 end 47 n = add get state 8 used 48 for i ulong 128 49 if ge i used 50 put data i uchar 0 51 end 52 end 53 kc_finish s w kt data n 54 cm_sha_output s data 55 put state 8 n 56 end 57 for i ulong 8 58 put state i ulong get s i 59 end 60 ret 0 61 end