Commit Graph

61 Commits

Author SHA1 Message Date
Panu Matilainen b8b5cdb09f Fix error handling in rpmDigestBundleAddID()
Besides the logic being completely wrong to begin with, it wasn't
actually handling the failure to allocate a digest at all. Do that,
and return values according to documentation.
2017-03-29 13:33:46 +03:00
Panu Matilainen ab943e93f7 Duplicate IDs in digest bundles are not permitted
Regresssion introduced in commit 6046386afd,
inserting a duplicate id must not succeed.
2017-03-03 11:24:34 +02:00
Panu Matilainen 6046386afd Use arbitrary ids instead of algorithm number to identify digests in bundles
Change the way individual digests within bundles are stored and accessed:
Previously the digest algo number was used directly as the index into
the bundle. Which works, but limits you to a single digest per algo,
and the array is likely to be rather sparse. To address both issues, use
an arbitrary integer ID to address the digests and always add new
digests in the first available slot. And yes the implementation is
a bit simplistic and taking some shortcuts, but so was the previous one.

Abstracting out the actual algorithm allows using eg rpm tag values
as the identifier, and also makes it possible to do multiple digests
of the same type on overlapping ranges. This is entirely backwards
compatible however if you simply use algorithm number also as the id,
so callers *need* to be updated.
2017-02-21 14:30:39 +02:00
Panu Matilainen 85b62554d2 Make room for SHA224 in digest bundles. Doh.
- Should've really been in commit 20cfa7d2b4
  but at the time NSS didn't even support SHA-224 so it was untestable.
  Now that it does, and somebody actually bothered to test...
  Fixes RhBug:1066494.
2014-02-18 18:26:38 +02:00
Panu Matilainen 3db9a10577 Bury all NSS specifics into a separate source
- Not everybody needs/wants the certified monster that NSS is
  (along with all its quirks), this leaves room for alternative
  compile-time selectable crypto backends. Besides that, we get
  a clean functionality separation for the PGP parser and the
  cryptography parts.
- The whole crypto abstraction works inspired + somewhat based on
  Michael Schroeder's similar patch in Suse, kudos.
- TODO: port beecrypt support from Suse to the new interface.
2011-11-04 16:49:01 +02:00
Panu Matilainen e104b67237 Eliminate use of pgpHashAlgo in rpmio interface arguments
- While its use would seem kinda obvious here, in rpm context this
  information often comes from header tags which are plain integers
  and would require conversion/casting to the enum. What matters is
  the integral value, not it being actual enum.
2010-10-22 12:22:44 +03:00
Panu Matilainen fa0337c9b6 Move fdDigest*() to rpmio.c where they better belong 2009-10-14 15:59:39 +03:00
Panu Matilainen 90c60cc5bb Remove redundant reinitialization, cleanup 2009-09-07 11:42:28 +03:00
Panu Matilainen 1446825571 Eliminate header/payload digests from pgpDig_s, they dont belong
- allocate+free digests locally where needed, pass around in separate argument
- use digest bundles to handle rpmVerifySignatures() needs
- kill-kill-kill fdStealDigest(), dup the contexts from bundles as needed
2009-03-25 13:23:19 +02:00
Panu Matilainen 3f6b2f8c7b Implement fdUpdateDigests() and friends using digest bundle 2009-03-25 13:10:23 +02:00
Panu Matilainen c9146aa580 Add a type + basic api for bundle of digests (on same data)
- in various places we need to calculate different digests of the same
  data, having them stored in a single container makes managing easier
- can hold as many digest types as we support
- remembers how much input data it has handled
2009-03-25 13:08:09 +02:00
Panu Matilainen 847c991b2b Proper error handling in rpmDigestDup()
- tolerate calling with NULL
- avoid allocations in case of failure
- return NULL instead of calling exit(), ick
2009-03-16 14:13:00 +02:00
Panu Matilainen 4cf26d30f8 NSS supports MD2, we might as well handle it too
- also getHashType() is a "pure" function, mark it as such
2009-03-11 21:41:57 +02:00
Panu Matilainen 15042bc909 Eliminate now unnecessary FDDIGEST_t
- contexts know their hash algorithm, this is not needed anymore
2009-03-11 18:10:19 +02:00
Panu Matilainen 7fc5e62eaa Remember hash algorithm in digest context
- alternatively we could reverse map NSS hash types (HASHContext
  knows its type) but shrug...
2009-03-11 18:07:22 +02:00
Panu Matilainen d05e4438a9 Streamline rpmDigestInit() a bit
- single point of exit, rearrange to avoid having to free if stuff fails
2009-03-11 18:06:33 +02:00
Panu Matilainen 5ff05aec30 Delay NSS initialization until actually used
- since NSS is allergic (ie becomes non-functional) after forking, delay
  it's initialization until really needed, ie lazy init in rpmDigestInit()
- however as NSS init can fail if attempted in completely empty chroot,
  we force crypto init to happen at transaction set create time, forking
  past that is pretty much doomed anyway
- this is the other half of the fix for rhbz#476737, and similar case
  noticed by Pixel in Mandriva (due to urpm forking)
2009-01-08 13:17:22 +02:00
Panu Matilainen b256dc9e25 NSS uses unsigned int, not size_t for hash lengths
- broke ppc64 in entertaining ways...
2008-07-12 17:57:51 +03:00
Panu Matilainen 5ef8b53108 Eliminate several copy-paste hex converters, use pgpHexStr() instead 2008-04-07 14:04:00 +03:00
Panu Matilainen 8fde231cac Mark bunch of misc. tables & such read-only in librpmio 2008-03-06 19:27:19 +02:00
Panu Matilainen 2579e086c2 Un-inline fd*Digest()
- avoid leaking nss + digest internals all over the place
2008-02-26 21:46:38 +02:00
Panu Matilainen eb5dc35c19 Include spring-cleaning
- put some consistency into include ordering
- everything (apart from bits missed ;) is now ordered like this
  1. "system.h"
  2. other system includes
  3. rpm public headers
  4. rpm private headers
  5. "debug.h"
2008-01-30 17:05:29 +02:00
Panu Matilainen a9490bf57a Gah, nss doesn't use size_t for lengths... 2008-01-02 14:44:58 +02:00
Panu Matilainen 2a27a8fcdb More assorted int -> size_t uses 2008-01-02 14:10:25 +02:00
Ralf Corsépius 96e7f513cd Eliminate type "byte" 2007-11-26 10:42:39 +01:00
Ralf Corsépius 8ef0ca213f Expand private include file names to be relative to $(top_srcdir) 2007-11-23 11:41:29 +01:00
Panu Matilainen db4e34966e Split digest-stuff out of rpmio_internal to separate header 2007-11-16 17:37:54 +02:00
Panu Matilainen 589b54af90 Initialize NSS early (rhbz#382091)
- add new rpmInitCrypto() API for directly initializing any crypto
- call it from rpmReadConfig() to ensure it's always initialized early on
2007-11-15 11:08:53 +02:00
Panu Matilainen 8afe81c214 Use NSS instead of beecrypt for encryption (Tomas Mraz) 2007-11-02 10:02:40 +02:00
Ralf Corsépius 8fa3c5becf Remove splint remnants. 2007-09-20 07:36:41 +02:00
Ralf Corsépius e9f3a5c89d Remove splint tags. 2007-09-11 19:23:32 +02:00
Ralf Corsépius f982bbaa79 Remove splint tags. 2007-09-11 16:48:54 +02:00
jbj 48972a87c8 Add support for sha256/sha384/sha512 (if available.).
Update beecrypt version.

CVS patchset: 7803
CVS date: 2005/03/13 01:15:37
2005-03-13 01:15:37 +00:00
jbj d4538f2d0d beecrypt-3.0.0 merge: DSA/SHA1 functional in rpm.
CVS patchset: 6786
CVS date: 2003/04/28 21:10:07
2003-04-28 21:10:07 +00:00
jbj 552d691608 Splint fiddles.
CVS patchset: 6736
CVS date: 2003/04/09 21:46:31
2003-04-09 21:46:31 +00:00
jbj 95f01d39a5 Splint clean.
CVS patchset: 6729
CVS date: 2003/04/02 21:16:26
2003-04-02 21:16:26 +00:00
jbj 6af194ed8e - add methods to make signature handling opaque wrto rpmts.
CVS patchset: 5566
CVS date: 2002/07/21 22:06:19
2002-07-21 22:06:19 +00:00
jbj 241fad1287 Propagate splint-3.0.1.7 close(2) internalState annotation throughout.
CVS patchset: 5542
CVS date: 2002/07/08 14:21:26
2002-07-08 14:21:26 +00:00
jbj e5fb770e7d Add boundsread annotations throughout, enable +bounds checking.
Start narrowing the scope of bounds annotations by adding more annotations.

CVS patchset: 5537
CVS date: 2002/07/02 23:54:35
2002-07-02 23:54:35 +00:00
jbj 13d177beb2 Add boundswrite annotations everywhere.
CVS patchset: 5522
CVS date: 2002/06/23 19:47:08
2002-06-23 19:47:08 +00:00
jbj 20901c1a62 - beecrypt: merge changes from beecrypt-2.3.0.
- beecrypt: merge doxygen markup with rpmapi doco.
- beecrypt: revert cpu/arch compile option mixup (#66752).

CVS patchset: 5495
CVS date: 2002/06/15 19:43:41
2002-06-15 19:43:41 +00:00
jbj e5a632b26d - beecrypt: add types.h, eliminate need for config.gnu.h.
CVS patchset: 5386
CVS date: 2002/04/10 20:00:40
2002-04-10 20:00:40 +00:00
jbj ca1d809cb1 Rewire digests, step 2.
CVS patchset: 5122
CVS date: 2001/10/19 01:35:57
2001-10-19 01:35:57 +00:00
jbj 96a3f7a55d Factor -type problems into explicit code annotations.
CVS patchset: 5117
CVS date: 2001/10/16 17:42:18
2001-10-16 17:42:18 +00:00
jbj 9f45bcd3ec More lclint annotations.
CVS patchset: 5116
CVS date: 2001/10/16 14:58:57
2001-10-16 14:58:57 +00:00
jbj 72471f2e54 Explicit branchstate annotations.
CVS patchset: 5113
CVS date: 2001/10/15 17:53:34
2001-10-15 17:53:34 +00:00
jbj d8dc44f363 lclint fiddles to annotate globals.
CVS patchset: 5106
CVS date: 2001/10/15 03:22:10
2001-10-15 03:22:10 +00:00
jbj 71dff1a731 - proof-of-concept GPG/DSA verification for legacy signatures.
CVS patchset: 5097
CVS date: 2001/10/05 20:39:50
2001-10-05 20:39:50 +00:00
jbj b7c25b0bef - create RFC-2440 OpenPGP API in rpmio.
- display signature packets before exec'ing gpg/pgp when verifying.

CVS patchset: 5090
CVS date: 2001/09/29 17:44:45
2001-09-29 17:44:45 +00:00
jbj 90fb17b356 - bind beecrypt md5/sha1 underneath rpmio.
CVS patchset: 5083
CVS date: 2001/09/26 14:45:50
2001-09-26 14:45:50 +00:00