viperleed.calc.lib.checksums

Checksums for TensErLEED Fortran source code files.

Contains basic information about TensErLEED files and code to check their checksums before run time compilation. This is supposed to help avoid security vulnerabilities.

This module can be executed with argument -p “path/to/tensorleed/folder” to generate the file _checksums.dat which contains an encoded version of checksums for all TensErLEED Fortran source code files.

We use the common SHA-256 hashing algorithm as available from Pythons hashlib. The check is toggled by parameter TL_IGNORE_CHECKSUM.

Functions

decode_checksums(encoded_checksums)

Return a dict of source_file_checksums from its encoded form.

encode_checksums(source_file_checksums)

Return a base-64 encoded version of source_file_checksums.

get_file_checksum(file_path)

Return the SHA256 hash of the file at file_path.

get_tl_version_files(version)

Return a tuple of TLSourceFile instances for a given version.

read_encoded_checksums([encoded_file_path])

Return checksums read from encoded_file_path.

validate_checksum(tl_version, filename)

Compare checksum for filename with known checksums.

validate_multiple_files(files_to_check, ...)

Validate multiple files by calling validate_checksum on each.

Classes

TLSourceFile(name, version, checksums)

Class that holds information of TensErLEED source files.

Exceptions

InvalidChecksumError

Exception for invalid checksums.

InvalidChecksumFileError

Exception for invalid checksum file.

UnknownTensErLEEDVersionError([version, message])

Exception for invalid TensErLEED version.