MCPcopy Index your code
hub / github.com/RsyncProject/rsync / sum_init

Function sum_init

checksum.c:558–619  ·  view source on GitHub ↗

Initialize a hash digest accumulator. Data is supplied via * sum_update() and the resulting binary digest is retrieved via * sum_end(). This only supports one active sum at a time. */

Source from the content-addressed store, hash-verified

556 * sum_update() and the resulting binary digest is retrieved via
557 * sum_end(). This only supports one active sum at a time. */
558int sum_init(struct name_num_item *nni, int seed)
559{
560 char s[4];
561
562 if (!nni)
563 nni = parse_csum_name(NULL, 0);
564 cur_sum_nni = nni;
565 cur_sum_len = csum_len_for_type(nni->num, 0);
566#ifdef USE_OPENSSL
567 cur_sum_evp_md = csum_evp_md(nni);
568#endif
569
570#ifdef USE_OPENSSL
571 if (cur_sum_evp_md) {
572 if (!ctx_evp && !(ctx_evp = EVP_MD_CTX_create()))
573 out_of_memory("file_checksum");
574 EVP_DigestInit_ex(ctx_evp, cur_sum_evp_md, NULL);
575 } else
576#endif
577 switch (cur_sum_nni->num) {
578#ifdef SUPPORT_XXHASH
579 case CSUM_XXH64:
580 if (!xxh64_state && !(xxh64_state = XXH64_createState()))
581 out_of_memory("sum_init");
582 XXH64_reset(xxh64_state, 0);
583 break;
584#endif
585#ifdef SUPPORT_XXH3
586 case CSUM_XXH3_64:
587 if (!xxh3_state && !(xxh3_state = XXH3_createState()))
588 out_of_memory("sum_init");
589 XXH3_64bits_reset(xxh3_state);
590 break;
591 case CSUM_XXH3_128:
592 if (!xxh3_state && !(xxh3_state = XXH3_createState()))
593 out_of_memory("sum_init");
594 XXH3_128bits_reset(xxh3_state);
595 break;
596#endif
597 case CSUM_MD5:
598 md5_begin(&ctx_md);
599 break;
600 case CSUM_MD4:
601 mdfour_begin(&ctx_md);
602 sumresidue = 0;
603 break;
604 case CSUM_MD4_OLD:
605 case CSUM_MD4_BUSTED:
606 case CSUM_MD4_ARCHAIC:
607 mdfour_begin(&ctx_md);
608 sumresidue = 0;
609 SIVAL(s, 0, seed);
610 sum_update(s, 4);
611 break;
612 case CSUM_NONE:
613 break;
614 default: /* paranoia to prevent missing case values */
615 exit_cleanup(RERR_UNSUPPORTED);

Callers 7

gen_challengeFunction · 0.85
generate_hashFunction · 0.85
verify_digestFunction · 0.85
match_sumsFunction · 0.85
rsync_xal_getFunction · 0.85
rsync_xal_setFunction · 0.85
receive_dataFunction · 0.85

Calls 7

parse_csum_nameFunction · 0.85
csum_evp_mdFunction · 0.85
md5_beginFunction · 0.85
mdfour_beginFunction · 0.85
SIVALFunction · 0.85
sum_updateFunction · 0.85
csum_len_for_typeFunction · 0.70

Tested by

no test coverage detected