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/tests/test_core_sha_state.c # 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 / tests / test_core_sha_state.c` 25 lines · 1368 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #include "sha256.h" 3 #include 4 #include 5 void ref_sha256_init(sha256_ctx *); 6 void ref_sha256_update(sha256_ctx *,const uint8_t *,size_t); 7 void ref_sha256_final(sha256_ctx *,uint8_t *); 8 int main(void) { 9 const size_t sizes[]={0,1,3,55,56,63,64,65,119,120,127,128,4095,4096,4097,32768}; 10 const size_t chunks[]={1,63,64,257,4096}; 11 uint8_t input[32768],a[32],b[32];memset(input,0x5a,sizeof input); 12 for(size_t t=0;tchunks[k])n=chunks[k];sha256_update(&x,input+i,n);ref_sha256_update(&y,input+i,n);i+=n;} 16 for(unsigned final=0;final<2;final++) { 17 sha256_final(&x,a);ref_sha256_final(&y,b); 18 if(memcmp(a,b,sizeof a)||memcmp(&x,&y,sizeof x)) { 19 fprintf(stderr,"SHA context mismatch: size=%zu chunk=%zu final=%u count=%llu reference=%llu\n",sizes[t],chunks[k],final,(unsigned long long)x.count,(unsigned long long)y.count); 20 return 1; 21 } 22 } 23 } 24 puts("CORE-UTIL SHA context PASS: padding boundaries, chunk splits and repeated finalization");return 0; 25 }