The sum buffer only needs to be as long as the current checksum's digest * len, not MAX_DIGEST_LEN. Note that for CSUM_MD4_ARCHAIC that is the full * MD4_DIGEST_LEN even if the file-list code is going to ignore all but the * first 2 bytes of it. */
| 683 | * MD4_DIGEST_LEN even if the file-list code is going to ignore all but the |
| 684 | * first 2 bytes of it. */ |
| 685 | void sum_end(char *sum) |
| 686 | { |
| 687 | #ifdef USE_OPENSSL |
| 688 | if (cur_sum_evp_md) { |
| 689 | EVP_DigestFinal_ex(ctx_evp, (uchar *)sum, NULL); |
| 690 | } else |
| 691 | #endif |
| 692 | switch (cur_sum_nni->num) { |
| 693 | #ifdef SUPPORT_XXHASH |
| 694 | case CSUM_XXH64: |
| 695 | SIVAL64(sum, 0, XXH64_digest(xxh64_state)); |
| 696 | break; |
| 697 | #endif |
| 698 | #ifdef SUPPORT_XXH3 |
| 699 | case CSUM_XXH3_64: |
| 700 | SIVAL64(sum, 0, XXH3_64bits_digest(xxh3_state)); |
| 701 | break; |
| 702 | case CSUM_XXH3_128: { |
| 703 | XXH128_hash_t digest = XXH3_128bits_digest(xxh3_state); |
| 704 | SIVAL64(sum, 0, digest.low64); |
| 705 | SIVAL64(sum, 8, digest.high64); |
| 706 | break; |
| 707 | } |
| 708 | #endif |
| 709 | case CSUM_MD5: |
| 710 | md5_result(&ctx_md, (uchar *)sum); |
| 711 | break; |
| 712 | case CSUM_MD4: |
| 713 | case CSUM_MD4_OLD: |
| 714 | mdfour_update(&ctx_md, (uchar *)ctx_md.buffer, sumresidue); |
| 715 | mdfour_result(&ctx_md, (uchar *)sum); |
| 716 | break; |
| 717 | case CSUM_MD4_BUSTED: |
| 718 | case CSUM_MD4_ARCHAIC: |
| 719 | if (sumresidue) |
| 720 | mdfour_update(&ctx_md, (uchar *)ctx_md.buffer, sumresidue); |
| 721 | mdfour_result(&ctx_md, (uchar *)sum); |
| 722 | break; |
| 723 | case CSUM_NONE: |
| 724 | *sum = '\0'; |
| 725 | break; |
| 726 | default: /* paranoia to prevent missing case values */ |
| 727 | exit_cleanup(RERR_UNSUPPORTED); |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | #if defined SUPPORT_XXH3 || defined USE_OPENSSL |
| 732 | static void verify_digest(struct name_num_item *nni, BOOL check_auth_list) |
no test coverage detected