The Debian package system (dpkg
and .deb
packages) generates MD5
sums internally when packages are installed. Unfortunately, your output only generates SHA1
and SHA256
sums. For this to work, you have to get the measurement to provide MD5
sums for the files.
What happens is that when you install a package with apt
/dpkg
, an .md5sums
file is generated for the package inside the directory /var/lib/dpkg/info
.
This means you can easily check the MD5
sum for all files as they were when the packages was installed. This can be used to determine if any of the files have been altered after the packages was installed.
An example from my own system (Ubuntu 22.04.2). If I run cat /var/lib/dpkg/info/sudo.md5sums
I get this:
e8e2fd5938804db1abb67773f84f5549 usr/bin/cvtsudoers
8176b78ba666fb64e72a3ae6a4851793 usr/bin/sudo
7cd774a8abe0586bdd75fb90c8bcaec7 usr/bin/sudoreplay
3f90917a245d4aafe98bb39a1fb9fa09 usr/include/sudo_plugin.h
9eb3041fcbb7ba1a64664d7a7a13cc15 usr/lib/tmpfiles.d/sudo.conf
8ccb24178b5cef512ac3fef3ad3b44f1 usr/libexec/sudo/audit_json.so
fc97536f5bf479b310cbffd9c5f030ec usr/libexec/sudo/group_file.so
4410a4f7ce928d5cbc79b5881e26194b usr/libexec/sudo/libsudo_util.so.0.0.0
c087bda8ff9210f79a94176ca817a4c8 usr/libexec/sudo/sample_approval.so
d8d8ca3f48bda0bb8a3e782379230284 usr/libexec/sudo/sesh
091c0ce05a872050dbe145bf156cea90 usr/libexec/sudo/sudo_intercept.so
d42066a08c1877f738c4c55c570f78e7 usr/libexec/sudo/sudo_noexec.so
4e920ee4b000c0bd9a1659a4368d5fdf usr/libexec/sudo/sudoers.so
59df52d5f1b4b01740df4abb34294711 usr/libexec/sudo/system_group.so
2f3db27567e8b72955cdccafb8d4750b usr/sbin/sudo_logsrvd
8f778373024750a98f7412593ac7fa39 usr/sbin/sudo_sendlog
e46edcfbb954c4bd8a599d3d76d53d9a usr/sbin/visudo
... (33 more lines omitted)
If you could get measurement you run to provide MD5
sums for the files, you could check this value against the values provided in the .md5sums
file.
If this is not possible, then it's unfortunate that the dpkg
utility uses the old MD5
hashes, while the kernel can not output these. In this case there might not be a better solution than to calculate the SHA256
checksums yourself directly from the .deb
files.