Commit Graph

29 Commits

Author SHA1 Message Date
Panu Matilainen 1e28f6ca75 Store signature/key creation time in a saner format internally
The OpenPGP time fields are unsigned four-octet numbers, storing
it as the uint32_t it actually is makes using the value that
little bit saner.

Way too many places to update as we still have no API for this, sigh.
2017-04-13 14:44:05 +03:00
Panu Matilainen 4bbeec134a Fixup ages old confusion wrt OpenPGP fingerprint vs Key ID
Originally introduced in commit f5203aea8b
in 2004, pgpPubkeyFingerprint() has been returning the 64 bits long
Key ID from the tail of 160 bits long fingerprint, not the actual
fingerprint.

Add a new public API for retrieving the Key ID specifically, adjust
the handful of internal users to use it and make pgpPubkeyFingerprint()
return the actual fingerprint. It's an API break sure but there are
unlikely to be any callers outside rpm and we're breaking the API + ABI
left and right in this release so doesn't matter...
2017-04-12 16:26:47 +03:00
Lubos Kardos cc61141245 Fix memory leaks in rpmGetSubkeys() and pgpPrtParamsSubkeys() 2016-03-08 14:29:24 +01:00
Lubos Kardos 2dd0693372 Fix SIGSEGV in case of old unsupported gpg keys (rhbz:1277464)
Regression from: a173d781a6
Adds also warning that gpg key is not supported.
2015-11-06 12:45:32 +01:00
Lubos Kardos a742fc8ce9 Store gpg subkey IDs in provides of the package containing gpg key.
Previously provides contained only ID of main gpg key. Now they
contains ID of main key and also IDs of subkeys. You can list all
keys of some gpg package with:

   rpm --provides -q gpg-pubkey-...
2015-07-23 10:55:03 +02:00
Lubos Kardos 355c9b069f Add rpmGetSubkeys() and pgpPrtParamsSubkeys() for getting gpg subkeys.
pgpPrtParamSubkeys() parses gpg packets to get gpg subkeys parameters.
rpmGetSubkeys() uses pgpPrtParamSubkeys() and it creates rpmPubkey
objects that can be insterted into rpm keyring.
2015-07-23 10:55:03 +02:00
Panu Matilainen 6f76f4fa78 Late evening hacking considered harmful... 2013-02-20 09:07:35 +02:00
Panu Matilainen 5b75e88858 Whoops, misread manual on pthread_rwlock_destroy()
- Turns out "destroying the object and release any resources used by the
  lock" does not include *unlocking* the lock. How silly of me to think
  it would...
2013-02-19 22:26:01 +02:00
Panu Matilainen 9f0e1bbb5a Add basic locking to pubkey objects
- Keys are basically immutable and generally owned by the keyring
  which doesn't currently doesn't expose anything about the keys
  it owns... so there isn't perhaps that much need for locking,
  except for keeping reference counts sane. Under that assumption
  the keys are not locked from within keyring lookup and signature
  verification, as it'd seem the keyring locking is sufficient
  to keep our keys around during them. Just as well there might
  be holes in this theory but gotta start someplace...
2013-02-19 16:51:38 +02:00
Panu Matilainen 23e7ada136 Add rwlocking to keyring for basic thread protection
- While we're mostly interested in very limited thread-safety
  where objects need to be kept private to the owning thread, being
  able to share the keyring (from transaction set) seems desireable,
  so lets try at least...
- Try to keep things as simple as possible: grab locks at the outer
  level functions, dont bother optimizing for write-lock avoidance
  in corner cases etc.
2013-02-19 16:46:47 +02:00
Panu Matilainen efc618107e Refactor rpmKeyringAddKey() to eliminate an early return
- No functional changes, just refactoring to make the code
  locking-friendlier
2013-02-19 16:01:12 +02:00
Panu Matilainen 20a79a7ac7 Refactor pubkey destructor to eliinate Unlink() helper
- Having a helper function to decrement an integer seems a bit much,
  but mostly this is preparing for thread protection where the
  unlink-helpers would just get in the way.
2013-02-19 15:35:10 +02:00
Panu Matilainen 4c7ee7383a Refactor keyring destructor to eliminate Unlink() helper
- Having a helper function to decrement an integer seems a bit much,
  but mostly this is preparing for thread protection where the
  unlink-helpers would just get in the way.
2013-02-19 15:32:54 +02:00
Panu Matilainen 97a37397c7 Initialize keyrings and pubkeys with refcount 1 directly
- Returning through fooLink() gains us nothing, but would complicate
  things wrt locking: fooLink() will require locks, but object
  creation does not.
2013-02-19 15:10:32 +02:00
Panu Matilainen 70f063cb77 Make base64 encoding/decoding part of rpmio public API
- Base64 is present in headers and all, it's only reasonable that
  our API users have access to this functionality without having
  to link to other libraries. Even if we didn't want to carry the
  implementation forever in our codebase, we should provide a wrapping
  for this (much like the other crypto stuff) for the reason stated above.
- A bigger issue is that our dirty little (badly hidden) secret was using
  non-namespaced function names, clashing with at least beecrypt. And we
  couldn't have made these internal-only symbols even on platforms that
  support it, because they are used all over the place outside rpmio.
  So... rename the b64 functions to rpmLikeNamingStyle and make 'em public.
  No functional changes, just trivial renaming despite touching numerous
  places.
2011-11-09 15:16:28 +02:00
Panu Matilainen 9e58316b0f Add a signature verification method to keyring
- At least within rpm itself, callers aren't particularly interested
  in the actual key that matches a given signature, they just want
  simple good/bad/nokey answers. This makes life simple for them
  and avoids exposing further rpmPubkey internals through APIs.
2011-11-09 13:09:37 +02:00
Panu Matilainen 6f7700dbed Split keyring find-by-signature to helper function, document...
- Document the broken rpmKeyringLookup() behavior / side-effect,
  the new helper uses the values from our stored pgp parameters though.
- Shouldn't make any difference functionality-wise, but we'll need
  the helper function shortly.
2011-11-09 12:51:39 +02:00
Panu Matilainen 564242f23b Parse pubkey parameters on rpmPubkeyNew() already and store results
- Yet more pre-requisites for separating key and signature management.
  In addition this gains us more thorough initial sanity checking and
  will allow reusing the parameters instead of having to parse
  the same packets over and over again on every single verification
  against this key. Unfortunately rpmKeyringLookup() is so braindead
  it prevents us from doing this right now, we'll need a better
  interface to take advantage of the stored pgp key parameters.
2011-11-09 11:59:31 +02:00
Panu Matilainen 917a5c4f6b Revert "Take advantage of pgpDigParamsCmp() in rpmKeyringLookup()"
- This only "works" because of other brokenness in the sig/key
  parsing, revert while we can
- This reverts commit 4c51eff3f0.
2011-11-08 15:08:01 +02:00
Panu Matilainen 4c51eff3f0 Take advantage of pgpDigParamsCmp() in rpmKeyringLookup()
- Besides eliminating a couple of direct struct accesses,
  pgpDigParamsCmp() does a much more thorough job of comparing
  the parameters than we ever did here (ie less chance for returning
  ok for for a wrong key, although because the interface is as
  braindead as it is, it doesn't make a whole lot of difference)
2011-11-07 14:49:47 +02:00
Panu Matilainen 9134a375f0 Eliminate direct pgpDig accesses from keyring 2011-11-07 12:53:47 +02:00
Panu Matilainen 2544204715 pgpPubkeyFingerprint() can fail, propagate errors part II
- rpmPubkeyNew() needs to return NULL if we fail to grab the
  keyid, make it so...
2011-10-25 14:03:43 +03:00
Panu Matilainen 612579c6f6 Oops, rpmPubkeyDig() should return NULL if pgpPrtPkts() fails 2011-07-13 15:46:21 +03:00
Panu Matilainen 92c12d1a8e Eliminate all fooUnlink() functions out of the API
- These are internal helpers only, all refcount users need to use
  fooFree() or similar for correct operation. Add fwd declarations
  where necessary to avoid moving code around unnecessarily.
- We could add these back later as aliases to fooFree() but for now,
  just get them out of the way.
2010-09-13 13:08:33 +03:00
Panu Matilainen 3897bdc37d Add couple of new rpmPubkey() methods
- rpmPubkeyDig() to retrieve parsed OpenPGP parameters of key
- rpmPubkeyBase64() to return base64 encoding of the key
2008-08-08 09:26:30 +03:00
Panu Matilainen ba644ed5aa Add (and use) refcounting for rpmKeyring and rpmPubkey 2008-07-17 15:50:35 +03:00
Panu Matilainen 710750ebff Make rpmkeyring.h public header 2008-07-02 14:23:30 +03:00
Panu Matilainen cea83865c9 Some keyring improvements
- keep keyring sorted by keyid, use bsearch for key lookups
- check for key in keyring before adding it to avoid dupes
- actually check that pubkey parameters match the signature on keyring
  lookup like was done in rpmtsFindPubkey()
2008-07-02 13:31:12 +03:00
Panu Matilainen 685877f2a0 Beginnings of an abstract keyring
- in librpmio to avoid dependencies on higher level stuff
- for now it's just an in-memory structure that needs to be populated
  by someone simply by feeding in GPG public keys
2008-07-01 17:52:40 +03:00