]> the.earth.li Git - onak.git/log
onak.git
6 months ago0.6.3 release main onak-0.6.3
Jonathan McDowell [Tue, 26 Sep 2023 19:52:47 +0000 (20:52 +0100)]
0.6.3 release

Release; update version string in CMakeLists.txt, doc/README, Doxyfile.
Update doc/HISTORY and debian/changelog.

6 months agoEnsure EDDSA signatures including leading zeros
Jonathan McDowell [Mon, 25 Sep 2023 20:22:19 +0000 (21:22 +0100)]
Ensure EDDSA signatures including leading zeros

mpz_export() expands an mpz to only the correct number of bytes
required. EDDSA signatures are based on a full 64 bytes of signature
data. But if either element of the signature (r or s) is fewer than 249
bits we'll end up with fewer than 32 bytes output and the signature
won't valid.

Ensure our output is right justified so we don't lose the leftmost
zeros.

6 months agoHandle failed database initialisation more gracefully
Jonathan McDowell [Mon, 25 Sep 2023 17:51:41 +0000 (18:51 +0100)]
Handle failed database initialisation more gracefully

Actually check the result from dbinit and exit rather than continuing
if we failed to initialise it. In particular we hit this path with a
missing config file.

6 months agoImprove HTML escaping
Jonathan McDowell [Fri, 22 Sep 2023 18:19:00 +0000 (19:19 +0100)]
Improve HTML escaping

Our existing HTML escaping was very primitive, looking only for a single
< and > around an email address. Extend this to cover multiple instance
of <, >, &, ", ' which should cover all the important bits. Also move to
using a caller provided buffer rather than a static buffer.

7 months agoEnsure our apt lists are current in the GitHub Action
Jonathan McDowell [Sat, 16 Sep 2023 09:36:20 +0000 (15:06 +0530)]
Ensure our apt lists are current in the GitHub Action

7 months agoRelax version check on parsing signature + key packets
Jonathan McDowell [Sat, 16 Sep 2023 09:27:02 +0000 (14:57 +0530)]
Relax version check on parsing signature + key packets

Rather than ensuring signatures/keys are no more than v5 allow them to
be anything from v2 onwards; otherwise things like armor/dearmor won't
work properly.

7 months agoSwitch to passing the key packet in when checking a hash signature
Jonathan McDowell [Sat, 16 Sep 2023 06:29:39 +0000 (11:59 +0530)]
Switch to passing the key packet in when checking a hash signature

Rather than passing the whole key in for verifying a hash signature,
explicitly pass in the key packet. This opens the way to being able to
verify signatures from subkeys.

7 months agoFix decoding of signature creation time
Jonathan McDowell [Fri, 15 Sep 2023 18:27:49 +0000 (23:57 +0530)]
Fix decoding of signature creation time

7 months agoSwitch charfuncs to returning number of read/written characters
Jonathan McDowell [Fri, 15 Sep 2023 12:55:51 +0000 (18:25 +0530)]
Switch charfuncs to returning number of read/written characters

The charfuncs prototypes were returning 0 for success ("I wrote all the
characters you asked me to") or 1 for failure. When we get to verifying
signatures over data we may not know how much to read, so change them to
returning 0 on error/no more data and otherwise the count of the amount
of data read/written.

7 months agoFix systemd unit files to deal with socket activation
Jonathan McDowell [Fri, 15 Sep 2023 10:21:29 +0000 (15:51 +0530)]
Fix systemd unit files to deal with socket activation

If we make the onak.service file require onak.socket then systemd will
take care of creating the Unix domain socket file, and we can avoid the
need to setup the RuntimeDirectory.

7 months agoAdd a test for signature verification
Jonathan McDowell [Fri, 15 Sep 2023 10:09:58 +0000 (15:39 +0530)]
Add a test for signature verification

Test signature verification by adding my new ECC key with verification
enabled, which will strip all signatures, then adding my old RSA key,
then readding my ECC key. This should result in the ECC key having a
signature from my old RSA key.

7 months agoIndicate when we've been started via socket activation
Jonathan McDowell [Fri, 15 Sep 2023 05:58:38 +0000 (11:28 +0530)]
Indicate when we've been started via socket activation

Update the starting log message for keyd so it's clear when we've been
started up via systemd socket activation, which would have helped avoid
the long standing bug with building properly with systemd support.

7 months agoFix systemd detection
Jonathan McDowell [Fri, 15 Sep 2023 05:50:54 +0000 (11:20 +0530)]
Fix systemd detection

All of our systemd detection logic was in keydb/CMakeLists.txt because
only keyd actually cares about it. However that then means we don't
correctly update build-config.h with HAVE_SYSTEMD and so we link against
it, but don't correctly do socket activation. Split out the detection
into the main CMakeLists.txt so we correctly set the define.

7 months agoFix systemd RuntimeDirectory
Jonathan McDowell [Fri, 15 Sep 2023 05:40:12 +0000 (11:10 +0530)]
Fix systemd RuntimeDirectory

RuntimeDirectory should be a path relative to /run/, rather than an
absolute path. Fix.

7 months agoDon't catch signals if we're using the keyd backend
Jonathan McDowell [Fri, 15 Sep 2023 05:28:31 +0000 (10:58 +0530)]
Don't catch signals if we're using the keyd backend

Catching signals dates from when we didn't have the keyd backend and
install every process opened the DB4 files itself. This lead to major
issues if the process didn't clean up correctly. If we're using keyd
there's no such concern, so we can avoid catching signals and preventing
things like Ctrl-C working for the CLI tool.

7 months agoAdd a log entry for when keyd cleanly exits
Jonathan McDowell [Fri, 15 Sep 2023 05:18:51 +0000 (10:48 +0530)]
Add a log entry for when keyd cleanly exits

We currently log when we're trying to shut down, but not when we've
actually done so successfully. Add a log message when we're definitely
exiting.

7 months agoAdd some build dependencies for GitHub build action
Jonathan McDowell [Fri, 15 Sep 2023 03:04:16 +0000 (08:34 +0530)]
Add some build dependencies for GitHub build action

We need nettle to be able to pass our tests, the others improve
coverage.

7 months agoSupport shallow git checkouts when configuring cmake
Jonathan McDowell [Fri, 15 Sep 2023 02:59:00 +0000 (08:29 +0530)]
Support shallow git checkouts when configuring cmake

git will bale out if we're using a shallow checkout with no tags. Just
fall back to the short commit hash when that happens, so we can still
try and identify when the build was from.

7 months agoExplicitly use main rather than default-branch in GitHub build action
Jonathan McDowell [Fri, 15 Sep 2023 02:46:08 +0000 (08:16 +0530)]
Explicitly use main rather than default-branch in GitHub build action

It looks like $default-branch is only available in templates.

7 months agoMove the CGI specific routines into cgi/ and split out UID escaping
Jonathan McDowell [Thu, 14 Sep 2023 18:17:22 +0000 (23:47 +0530)]
Move the CGI specific routines into cgi/ and split out UID escaping

The only piece from getcgi.c that anything other than the CGI needs is
the code to escape a UID. Move that into keyindex.c and shuffle the CGI
routines off to the subdirectory. The escaping routine could do with a
lot of improvement, but this is a start in terms of cleaning things up.

7 months agoSwitch from Travis CI to GitHub Actions
Jonathan McDowell [Thu, 14 Sep 2023 14:07:40 +0000 (19:37 +0530)]
Switch from Travis CI to GitHub Actions

The free Travis bits stopped working ages ago, let's try out GitHub's
Actions support as a replacement. Just a simple build + test without
extra deps to start with.

7 months agoRemove stray ; from keydb_keyring
Jonathan McDowell [Thu, 14 Sep 2023 13:32:39 +0000 (19:02 +0530)]
Remove stray ; from keydb_keyring

No need for a ; at the end of a function...

7 months agoMark unused function parameters
Jonathan McDowell [Thu, 14 Sep 2023 08:20:10 +0000 (13:50 +0530)]
Mark unused function parameters

Do a pass-through with "gcc -Werror -Wunused-parameter" and mark up all
the unused function parameters (and remove a few unused variables). Also
add a CMake check to ensure we have __attribute__((unused)) available to
us.

7 months agoFix issues found by llvm scan-build static analysis
Jonathan McDowell [Thu, 14 Sep 2023 06:53:41 +0000 (12:23 +0530)]
Fix issues found by llvm scan-build static analysis

A mixture of fixes: a number of uses of getenv into functions that don't
like NULL, a couple of potential double-setting of config file details
resulting in a brief memory leak, and a true, but not an issue, report
of setting without using of our offset within a packet.

7 months agoAdd a helper for reading OpenPGP packets from a file
Jonathan McDowell [Thu, 14 Sep 2023 05:59:08 +0000 (11:29 +0530)]
Add a helper for reading OpenPGP packets from a file

Provide a convenience function for opening a file, working out if it's
ASCII-armoured or binary, and loading the packets contained within it.

7 months agoAdd a hash helper
Jonathan McDowell [Tue, 12 Sep 2023 09:13:39 +0000 (14:43 +0530)]
Add a hash helper

Rather than ifdef'ing hash contexts everywhere we want to use them, wrap
them up in a helper.

7 months agoAdd CMake checking for Berkeley DB
Jonathan McDowell [Fri, 8 Sep 2023 13:52:56 +0000 (14:52 +0100)]
Add CMake checking for Berkeley DB

Rather than hard coding the fact we build in Berkeley DB support,
actually check for the existence of the library and only build it if we
find it.

15 months agoSwitch to RuntimeDirectory in systemd service file
Jonathan McDowell [Mon, 2 Jan 2023 15:52:58 +0000 (15:52 +0000)]
Switch to RuntimeDirectory in systemd service file

Instead of the ExecStartPre commands for creating our runtime directory
switch to the correct approach, RuntimeDirectory. Thanks to Guillem
Jover for the pointer.

16 months ago0.6.2 release onak-0.6.2
Jonathan McDowell [Sun, 27 Nov 2022 19:41:37 +0000 (19:41 +0000)]
0.6.2 release

Release; update version string in CMakeLists.txt, doc/README, Doxyfile.
Update doc/HISTORY and debian/changelog.

16 months agoBump Debian Standards-Version to 4.6.1
Jonathan McDowell [Sun, 27 Nov 2022 18:17:33 +0000 (18:17 +0000)]
Bump Debian Standards-Version to 4.6.1

16 months agoAdd support for verifying v3 signature packets
Jonathan McDowell [Sun, 27 Nov 2022 16:05:16 +0000 (16:05 +0000)]
Add support for verifying v3 signature packets

We only support signature checking on v4+ keys, so hadn't any support
for v3 signature packets. However keys have been observed in the wild
where the key itself is a v4 key, but it's making v3 signatures (in
particular as a revocation signature for the key). While this seems odd
(anything that supports the key has to support v4, so why generate
anything lower?) it's probably too strict a check to have in place.

16 months agoBump debhelper compat level to 13
Jonathan McDowell [Sat, 26 Nov 2022 17:48:45 +0000 (17:48 +0000)]
Bump debhelper compat level to 13

This gives us the appropriate RUNSTATEDIR setting of /run, and is still
compatible with backports to Bullseye. Also use the new
debhelper-compat build-dep rather than debian/compat.

16 months agoFix /run/onak creation
Jonathan McDowell [Sat, 26 Nov 2022 16:50:03 +0000 (16:50 +0000)]
Fix /run/onak creation

The keyd socket was previously moved under /run/onak so that
subdirectory could be owned by the onak user. However the systemd
ExecStartPre commands run as the onak user, so the creation + ownership
setup was not properly happening. Prefix with a +, which tells systemd
these commands ignore the User= setting.

21 months agoFix deletion of keys with PostgreSQL backend
Jonathan McDowell [Sun, 3 Jul 2022 10:16:14 +0000 (11:16 +0100)]
Fix deletion of keys with PostgreSQL backend

In pg_delete_key() we deleted the key from onak_keys as the first
action, which would fail because the other tables had a reference to
that object via a foreign key relation. The correct approach is to
delete the key itself last, after the signature and UID tables have had
their entries deleted.

22 months agoUse an onak subdir for the keyd socket
Jonathan McDowell [Sat, 28 May 2022 18:12:28 +0000 (19:12 +0100)]
Use an onak subdir for the keyd socket

Instead of putting keyd.sock file directly in /run create a /run/onak
which can then be owned by the onak user. Otherwise keyd will have
problems creating the socket when activated directly instead of via the
socket unit file.

2 years agoFix handling of other signature requirement
Jonathan McDowell [Thu, 3 Feb 2022 19:07:58 +0000 (19:07 +0000)]
Fix handling of other signature requirement

Two fixes related to the check that a key has another signature on it.

Firstly, if any of the UIDs has a signature from another key then allow
all of them. Otherwise it's not possible to add a new UID to an existing
key. Our primary concern is that the key is linked into the WoT, rather
than policing individual UIDs.

Secondly, if a key is already present in the backend database then don't
perform the other signature check. If we've added to the backend and all
of the cross signatures are removed then it would be no longer possible
to update the key, which isn't what we want. If we've trusted it at some
point and added it then we should allow verifiable updates, even if
there are no valid cross signatures left.

3 years agoDon't take creation time from unhashed subpackets
Jonathan McDowell [Sat, 2 Jan 2021 11:31:27 +0000 (11:31 +0000)]
Don't take creation time from unhashed subpackets

When looking at the subpackets for a signature don't use the unhashed
set to obtain the creation time, and only use them for the keyid if it
wasn't present in the hashed section.

Fixes #3

3 years agoSwitch to re-entrant versions of *time functions
Jonathan McDowell [Sat, 2 Jan 2021 11:18:55 +0000 (11:18 +0000)]
Switch to re-entrant versions of *time functions

We're not running these in a multi-threaded scenario at present, but it
makes sense to avoid them.

3 years agoRemove dead store in generic_fetch_key
Jonathan McDowell [Sat, 2 Jan 2021 11:05:46 +0000 (11:05 +0000)]
Remove dead store in generic_fetch_key

We don't use curkey once we've found the key, so there's no need to set
it here.

3 years agoFix missing break in ECDSA/SHA1 sigcheck
Jonathan McDowell [Sat, 2 Jan 2021 11:04:33 +0000 (11:04 +0000)]
Fix missing break in ECDSA/SHA1 sigcheck

We were mistakenly falling through to the ECDSA/SHA256 check.

3 years agoUpdate Debian changelog for 0.6.1-1 package
Jonathan McDowell [Sun, 13 Sep 2020 11:11:45 +0000 (12:11 +0100)]
Update Debian changelog for 0.6.1-1 package

3 years agoReformat debian/NEWS file appropriately
Jonathan McDowell [Sun, 13 Sep 2020 11:08:08 +0000 (12:08 +0100)]
Reformat debian/NEWS file appropriately

3 years agoBump Debian Standards-Version to 4.5.0
Jonathan McDowell [Sun, 13 Sep 2020 11:04:18 +0000 (12:04 +0100)]
Bump Debian Standards-Version to 4.5.0

3 years agoRename debian/NEWS.Debian to debian/NEWS
Jonathan McDowell [Sun, 13 Sep 2020 10:59:29 +0000 (11:59 +0100)]
Rename debian/NEWS.Debian to debian/NEWS

Lintian inspired cleanup.

3 years agoRemove --with-systemd option to dh
Jonathan McDowell [Sun, 13 Sep 2020 10:57:56 +0000 (11:57 +0100)]
Remove --with-systemd option to dh

3 years ago0.6.1 release onak-0.6.1
Jonathan McDowell [Sun, 13 Sep 2020 10:51:07 +0000 (11:51 +0100)]
0.6.1 release

Release; update version string in CMakeLists.txt, doc/README, Doxyfile.
Update doc/HISTORY and debian/changelog.

3 years agoFix compilation with later versions of Nettle
Jonathan McDowell [Sun, 13 Sep 2020 10:45:54 +0000 (11:45 +0100)]
Fix compilation with later versions of Nettle

Need to actually check for the appropriate symbols existing; the header
file alone is not enough to have them defined.

3 years agoFix compilation without libnettle
Jonathan McDowell [Sun, 13 Sep 2020 10:21:09 +0000 (11:21 +0100)]
Fix compilation without libnettle

The RSA signature routines are unavailable when we don't have nettle.

3 years ago0.6.0 release onak-0.6.0
Jonathan McDowell [Sun, 13 Sep 2020 10:08:23 +0000 (11:08 +0100)]
0.6.0 release

Release; update version string in CMakeLists.txt, doc/README, Doxyfile.
Update doc/HISTORY and debian/changelog.

3 years agoUpdate details of other keyservers
Jonathan McDowell [Sun, 13 Sep 2020 10:03:34 +0000 (11:03 +0100)]
Update details of other keyservers

Update the URL for SKS, add Hockeypuck.

3 years agoAdd libpq-dev to Travis CI config
Jonathan McDowell [Sun, 13 Sep 2020 09:16:17 +0000 (10:16 +0100)]
Add libpq-dev to Travis CI config

Should ensure the CI stuff makes sure we can still compile the
PostgreSQL backend.

4 years agoAdd Evil32 fingerprint blacklist
Jonathan McDowell [Fri, 17 Jan 2020 20:17:09 +0000 (20:17 +0000)]
Add Evil32 fingerprint blacklist

These are the Evil32 fingerprints to allow their blacklisting in the
server.

4 years agoProvide key_fetch routine that will not search subkey fingerprints
Jonathan McDowell [Fri, 17 Jan 2020 19:48:10 +0000 (19:48 +0000)]
Provide key_fetch routine that will not search subkey fingerprints

We have *_key_fetch_fp to search for keys by fingerprint, but that
includes subkeys. While unlikely a subkey could be bound to multiple
certification primary keys, resulting in multiple keys being returned
for a fingerprint query. Provide a plain *_fetch_key that only searches
primary keys and is thus guaranteed to return at most one key.

4 years agoCope with colliding 64 bit keyids when verifying signatures
Jonathan McDowell [Fri, 17 Jan 2020 19:28:18 +0000 (19:28 +0000)]
Cope with colliding 64 bit keyids when verifying signatures

Signature keys can be indicated by 64 bit keyid rather than full
fingerprint; there are very few of this collisions but they do exist and
we should handle them gracefully rather than incorrectly dropping a
signature.

4 years agoUpdate TODO list
Jonathan McDowell [Mon, 16 Sep 2019 18:57:32 +0000 (19:57 +0100)]
Update TODO list

4 years agoAdd a basic README.md for the top level directory
Jonathan McDowell [Mon, 16 Sep 2019 18:51:22 +0000 (19:51 +0100)]
Add a basic README.md for the top level directory

4 years agoMove docs into their own subdirectory
Jonathan McDowell [Mon, 16 Sep 2019 18:34:32 +0000 (19:34 +0100)]
Move docs into their own subdirectory

4 years agoAdd configuration file comment for check_packet_size option
Jonathan McDowell [Sun, 8 Sep 2019 17:05:38 +0000 (18:05 +0100)]
Add configuration file comment for check_packet_size option

4 years agoAdd defines for nettle_get_secp_* for Nettle pre 3.4
Jonathan McDowell [Sat, 7 Sep 2019 19:56:04 +0000 (19:56 +0000)]
Add defines for nettle_get_secp_* for Nettle pre 3.4

Debian 9 (stretch) has Nettle 3.3, so define these fallbacks so we
can build with crypto support there.

4 years agoAdd support for full signature verification
Jonathan McDowell [Sat, 7 Sep 2019 12:04:14 +0000 (12:04 +0000)]
Add support for full signature verification

For a long time it has been known that attacks against the keyserver
network were easy due to the lack of cryptographic verification on
signatures, as well as the lack of other checks and balances. Add the
ability to actually verify signatures, allowing those are that are not
valid (or that come from non-present keys) to be removed.

4 years agoError out if there's any problem setting up the keyd socket
Jonathan McDowell [Fri, 6 Sep 2019 17:56:51 +0000 (18:56 +0100)]
Error out if there's any problem setting up the keyd socket

Rather than ending up in an accept() loop that goes nowhere, print
the error we saw and exit.

4 years agoAdd dependency on pkg-config
Jonathan McDowell [Thu, 5 Sep 2019 15:17:42 +0000 (16:17 +0100)]
Add dependency on pkg-config

The move to cmake requires pkg-config in order to find nettle-dev
correctly.

4 years agoAdd MD5_DIGEST_SIZE to our local MD5 implementation header
Jonathan McDowell [Thu, 5 Sep 2019 13:18:33 +0000 (14:18 +0100)]
Add MD5_DIGEST_SIZE to our local MD5 implementation header

This is present in libnettle and has been made use of recently to
avoid a hard coded digest length value.

4 years agoRemove v5 keyid support when libnettle not present
Jonathan McDowell [Thu, 5 Sep 2019 13:06:44 +0000 (14:06 +0100)]
Remove v5 keyid support when libnettle not present

v5 key fingerprints are SHA256 based. We have fallbacks for MD5 + SHA1
when libnettle is not present, but there's no intent to provide a SHA256
fallback, and we're close to the point where support for building
without libnettle will be removed entirely.

4 years agoPass a keydb context into cleankeys in preparation for signature checks
Jonathan McDowell [Wed, 28 Aug 2019 07:20:03 +0000 (08:20 +0100)]
Pass a keydb context into cleankeys in preparation for signature checks

In order to validate signatures cleankeys() will need to do key lookups
of the signing keys. Plumb in the database context in preparation for
this.

4 years agoMove key database backends into their own directory
Jonathan McDowell [Tue, 27 Aug 2019 17:56:46 +0000 (18:56 +0100)]
Move key database backends into their own directory

These logically sit together and are separate from the core code, so
move them off to a separate directory. There are various bits of support
that should be hived off the core libonak and move in here too, but that
can wait until later.

4 years agoCleanup postinst to avoid recursive chown of database
Jonathan McDowell [Thu, 22 Aug 2019 07:17:49 +0000 (08:17 +0100)]
Cleanup postinst to avoid recursive chown of database

The recursive chown of /var/lib/onak has the potential to be abused
during installation, so just chown the top level directory and then run
the onak that's initialising the DB as the onak user, rather than root.

4 years agoSet Rules-Requires-Root to no
Jonathan McDowell [Thu, 22 Aug 2019 07:07:46 +0000 (08:07 +0100)]
Set Rules-Requires-Root to no

We can build as a normal user.

4 years agoBump debhelper compat level to 10
Jonathan McDowell [Thu, 22 Aug 2019 06:19:36 +0000 (07:19 +0100)]
Bump debhelper compat level to 10

Also remove now unnecessary build-depend on dh-systemd.

4 years agoRemove git clone depth for Travis-CI
Jonathan McDowell [Thu, 22 Aug 2019 06:14:38 +0000 (07:14 +0100)]
Remove git clone depth for Travis-CI

The default of 50 wasn't enough to be able to "git describe" our current
revision for the build process.

4 years agoAdd test for blacklisting functionality
Jonathan McDowell [Wed, 21 Aug 2019 19:07:09 +0000 (20:07 +0100)]
Add test for blacklisting functionality

4 years agoAdd option to only accept updates for existing keys
Jonathan McDowell [Wed, 21 Aug 2019 17:56:57 +0000 (18:56 +0100)]
Add option to only accept updates for existing keys

It's plausible in a curated keyring scenario where a keyserver should
accept updates to existing keys (new signatures, updated expiries, new
subkeys) but no entirely new keys. Add a configuration file option which
enforces this behaviour.

4 years agoAdd blank line before armoured PGP data
Jonathan McDowell [Wed, 21 Aug 2019 17:55:32 +0000 (18:55 +0100)]
Add blank line before armoured PGP data

When removing the Version: header it's still necessary to have a blank
line before the actual armoured data.

4 years agoClean up signature hash calculation code
Jonathan McDowell [Tue, 20 Aug 2019 07:12:52 +0000 (08:12 +0100)]
Clean up signature hash calculation code

Use the defined digest lengths for MD5/SHA1/SHA1X rather than magic
numbers, clear the hash type at the start and then only set it if we
know it.

4 years agoUpdate Travis CI to use Ubuntu 18.04 instead of 16.04
Jonathan McDowell [Mon, 19 Aug 2019 07:29:40 +0000 (08:29 +0100)]
Update Travis CI to use Ubuntu 18.04 instead of 16.04

4 years agoClean up GCC warnings
Jonathan McDowell [Mon, 19 Aug 2019 07:25:15 +0000 (08:25 +0100)]
Clean up GCC warnings

GCC -Wall found a valid issue with a & instead of a && in the keyring DB
backend, a buffer assignment missing a cast and some unused variables in
the DB4 backend.

4 years agoClean up use of shifts beyond composite types
Jonathan McDowell [Mon, 19 Aug 2019 06:28:16 +0000 (07:28 +0100)]
Clean up use of shifts beyond composite types

GCC with the -fsanitize=undefined flag issues complaints like:

runtime error: left shift of 232 by 24 places cannot be represented in
type 'int'

due to the fact we shift the byte values into a 64 bit value. Rather
than adding lots of casts split out the formation into a set of steps
that doesn't end up shifting the byte value, just the final 64 bit
value.

4 years agoAdd support for a key fingerprint blacklist
Jonathan McDowell [Sun, 18 Aug 2019 20:55:45 +0000 (21:55 +0100)]
Add support for a key fingerprint blacklist

There are various keys in the wild, such as Evil32 (https://evil32.com/)
which a keyserver is unlikely to want to carry in the general case.
Introduce the capability to have a blacklist of fingerprints which will
not be accepted into the keyserver.

4 years agoDeprecate the .conf configuration file format
Jonathan McDowell [Sun, 18 Aug 2019 19:46:39 +0000 (20:46 +0100)]
Deprecate the .conf configuration file format

The old .conf config file was intended to be compatible with the ancient
PKS keyserver. All new features are only supported with the .ini format
and this is going to make the automated tests supporting both more
awkward. So deprecate the old style and stop testing it.

4 years agoFix memory leak when updating keys
Jonathan McDowell [Sun, 18 Aug 2019 18:30:06 +0000 (19:30 +0100)]
Fix memory leak when updating keys

If the first new key had no new components we'd remove it from the list
but not actually free it. Fix things up so we free it properly. Found
with gcc's -fsanitize=leak option.

4 years agoFix up memory leaks in fs keydb backend deletion
Jonathan McDowell [Sun, 18 Aug 2019 18:03:44 +0000 (19:03 +0100)]
Fix up memory leaks in fs keydb backend deletion

We need to clean up the wordlist we created, as well as the copy of the
actual key we retrieved.

4 years agoFix memory leak in makewordlistfromkey()
Jonathan McDowell [Sun, 18 Aug 2019 17:49:47 +0000 (18:49 +0100)]
Fix memory leak in makewordlistfromkey()

We were building a linked list of words in each UID, but then not
cleaning up this linked list when we were done with it. Found with gcc
-fsanitize=leak

4 years agoProperly free database context when cleaning up fs backend
Jonathan McDowell [Sun, 18 Aug 2019 13:55:09 +0000 (14:55 +0100)]
Properly free database context when cleaning up fs backend

4 years agoFix memory leak when merging key signatures
Jonathan McDowell [Sun, 18 Aug 2019 10:03:47 +0000 (11:03 +0100)]
Fix memory leak when merging key signatures

This is a long-standing memory leak when merging signed packet lists. It
hasn't been observed in the wild because the key merging is normally
done in a transient process. Found using GCC with -fsanitize=leak

4 years agoCleanup DB4 deletion code from pre-fingerprint period
Jonathan McDowell [Mon, 12 Aug 2019 18:03:05 +0000 (19:03 +0100)]
Cleanup DB4 deletion code from pre-fingerprint period

Some remanents from the key ID based deletion function that are no
longer needed.

4 years agoFix up key deletion by key ID with onak tool
Jonathan McDowell [Mon, 12 Aug 2019 17:59:54 +0000 (18:59 +0100)]
Fix up key deletion by key ID with onak tool

The call to db_delete_key() was claiming we were in a transaction, which
isn't true and causes failures with deletion with DB4.

4 years agoExpose more of calculating the packet signature hash
Jonathan McDowell [Mon, 5 Aug 2019 18:27:06 +0000 (19:27 +0100)]
Expose more of calculating the packet signature hash

As preparation for full signature verification move to calculating the
signature hash and exposing it, and then doing the verification in the
cleaning routine.

4 years agoDrop v3 keys by default when cleaning keys
Jonathan McDowell [Sun, 4 Aug 2019 18:19:31 +0000 (19:19 +0100)]
Drop v3 keys by default when cleaning keys

v3 keys have long been considered insecure. While we want to retain
support for them there's no reason most keyservers should actually store
them these days. So drop them by default when running cleankeys()

4 years agoFix header size for v5 packet sig checks
Jonathan McDowell [Sat, 3 Aug 2019 10:10:09 +0000 (11:10 +0100)]
Fix header size for v5 packet sig checks

The keyheader for a v5 signature has a 4 byte length instead of a 2 byte
length, but the structure hadn't been increased in size.

4 years agoMove CGI sources to their own subdirectory
Jonathan McDowell [Sat, 3 Aug 2019 08:35:23 +0000 (09:35 +0100)]
Move CGI sources to their own subdirectory

Cleanup the code structure a bit by pulling those files only used for
the HKP interface into their own directory.

4 years agoRemove unused worddb_cmp() from DB4 backend
Jonathan McDowell [Sat, 3 Aug 2019 08:09:41 +0000 (09:09 +0100)]
Remove unused worddb_cmp() from DB4 backend

This function was no longer used, so remove it.

4 years agoRemove getfullkeyid functionality
Jonathan McDowell [Thu, 1 Aug 2019 21:32:51 +0000 (22:32 +0100)]
Remove getfullkeyid functionality

This expanded a 32 bit key ID into a 64 bit key ID. It's mostly
redundant, so encode 64 bit key IDs where necessary and rely on the
fetch fallback to 32 bit elsewhere.

4 years agoChange delete_key to use a full fingerprint
Jonathan McDowell [Thu, 1 Aug 2019 21:18:24 +0000 (22:18 +0100)]
Change delete_key to use a full fingerprint

delete_key was deleting a key based on the keyid, which is
insufficiently precise. Move over to the full fingerprint (even though
with some backends this is an effective no-op for now).

4 years agoImprove handling of colliding 64-bit key IDs
Jonathan McDowell [Thu, 1 Aug 2019 18:19:30 +0000 (19:19 +0100)]
Improve handling of colliding 64-bit key IDs

Originally key retrieval was all performed on the 64 bit key ID but back
in 2013 support was added for fetching by fingerprint. However not all
the pieces to deal with colliding 64 bit IDs were added at this time.
This commit improves things by:

 * Using the fingerprint to retrieve the key to update in update_keys()
 * Returning all keys that share a 64 bit key ID from the DB4 backend,
   rather than just the first found.
 * Adding a test to ensure multiple keys are returned for a colliding
   key lookup.

It also removes the old compatibility code for the DB4 backend with key
lookups by 64 bit key ID.

Note this isn't yet common in the wild; unlike Evil32 it is not possible
to create collisions for arbitrary key IDs.

4 years agoFix potential memory leak in wotsap tool
Jonathan McDowell [Wed, 31 Jul 2019 19:49:30 +0000 (20:49 +0100)]
Fix potential memory leak in wotsap tool

In failure paths we can leak the memory allocated to hold the directory
path. This isn't really a problem, as we'll exit shortly afterwards, but
scan-build complains and we should really fix for completeness.

4 years agoEnable sighash checking for v5 keys
Jonathan McDowell [Wed, 31 Jul 2019 18:17:44 +0000 (19:17 +0100)]
Enable sighash checking for v5 keys

v5 signatures are calculated slightly differently than v4 signatures, so
allow for this when checking the 2 leading bytes of the signature hash.

4 years agoExit on failure to initialise a dynamic DB backend
Jonathan McDowell [Wed, 31 Jul 2019 18:08:37 +0000 (19:08 +0100)]
Exit on failure to initialise a dynamic DB backend

The dynamic DB backend does a lot of checks to ensure it can load the
requested backend successfully, but didn't actually check that it
initialised correctly. Bomb out with a graceful error message if this
happens rather than leading the caller to think everything is ok.

4 years agoAdd an OpenPGP keyring backed database backend
Jonathan McDowell [Tue, 30 Jul 2019 18:40:17 +0000 (19:40 +0100)]
Add an OpenPGP keyring backed database backend

Allow the use of an OpenPGP keyring (like keyring.gpg from GnuPG v1) as
a read-only database backend. This is just a collection of keys
concatenated together. The file is mmaped on load and parsed for keys,
then simple linear searches are done for keyids/fingerprints.
Performance with large numbers of keys will not be good.

4 years agoAdd more generic OID parsing to decodekey
Jonathan McDowell [Tue, 30 Jul 2019 18:32:34 +0000 (15:32 -0300)]
Add more generic OID parsing to decodekey

Rather than only parsing the encoded OID to calculate the key size make
a helper function in decodekey and use that. This will be useful when
trying to parse key material for signature checks.

4 years agoExport fingerprint_cmp from keyarray.c
Jonathan McDowell [Tue, 30 Jul 2019 18:26:58 +0000 (15:26 -0300)]
Export fingerprint_cmp from keyarray.c

Comparing fingerprints is generally useful outside of the routines in
keyarray.c, so export the function prototype in the header file.