test_signed_usable.py: Add test case for security bugs
This checks all 4 variants of signed x usable hashes, by builting
a package each. And then checks for all variants of the
allow_unauthenticated parameter.
We need to provide assertRaisesRegex for Pythons < 3.1, so we
can test there as well.
(cherry picked from commit 8b527257c55b88310c315b5c588940626cf206ef)
(cherry picked from commit 315ec78ab98d16de2f8c36e8646bb9e11c26bcc6)
Backport to xenial: Set trusted=yes for signed repo, as signing check
does not work, because apt-key always uses host keys.
(cherry picked from commit de31eee5cf3f816d8675aa36888a2bafe96c9d3d)
If allow_unauthenticated is not set, reject hashes other than
SHA256.
(cherry picked from commit 59a26938489af8bf4e4c326c4d50ff5ba2ba9f85)
(cherry picked from commit 51eac2e007911b52630881bc228d8bb2505962a3)
(cherry picked from commit 5f4d7114dc578142364c4cec05b0937856f5317b)
(cherry picked from commit 192dc55a5068a6d5e3faee6fada63c1e56dfce92)
(cherry picked from commit 01c56933d07ffdf24351396b99ce29c3162abf4d)
(cherry picked from commit fac8c9c31c8d63b51ecd57e366a667291aa2cf1b)
(cherry picked from commit 286d9f90948d453326e98cb37aad0fb9763a9dd7)
apt/package.py: Use strongest avaialble hash when fetching
Use the strongest hash available when fetching binaries and
source packages. This requires a bit of trickery compared to
later releases where HashStringList is supported everywhere,
but it's not that bad.
We do not reject files with only untrusted hashes, placing
the burden of making the repository safe on the signer.