xbps icon indicating copy to clipboard operation
xbps copied to clipboard

Generalizing sha256-functions

Open friedelschoen opened this issue 2 years ago • 0 comments

Hey! I've resolved the deprecated SHA256_* functions with it's EVP_* functions. With that I've generic all xbps_file_sha256(...) functions to xbps_file_hash(XBPS_HASH_SHA256, ...) thus making support for other hashes in e.g. xbps-digest more easy.

  1. File Hashing Abstraction:

    • Introduces an enumeration xbps_hash_algorithm_t representing different hashing algorithms, including XBPS_HASH_SHA256 and XBPS_HASH_BLAKE2B256.
    • Adds functions xbps_hash_size_raw and xbps_hash_size to retrieve raw and hexstring hash sizes.
    • Implements xbps_file_hash_raw and xbps_file_hash to calculate raw and hexstring file hashes, respectively, based on the chosen algorithm.
  2. Code Refactoring:

    • Replaces instances of direct SHA256 calls with the new file hashing functions (xbps_file_hash_raw and xbps_file_hash) in various parts of the codebase.
    • Enhances the xbps_file_hash_check function to support different hashing algorithms.
  3. Support for Blake2b256:

    • Adjusts the existing codebase to use the new hash functions, ensuring compatibility with both SHA256 and Blake2b256.

friedelschoen avatar Jan 23 '24 19:01 friedelschoen