summaryrefslogtreecommitdiff
path: root/lib/signature.c
AgeCommit message (Collapse)AuthorFilesLines
2012-04-03Validate negated offsets too in headerVerifyInfo()Panu Matilainen1-1/+1
- Undo the ancient broken fix for RhBug:71996 from commit 9e06e3b8ca76ae55eaf2c4e37ba9cac729789014: instead of disabling the check, pass in the correct upper range which is entirely different from everything else for the region trailer tag. - Fixes CVE-2012-0815
2012-04-03Differentiate between non-existent and invalid region tagPanu Matilainen1-6/+12
- Non-existent region tag is very different from existing but invalid one - the former is not an error but the latter one is, and needs to be handled as such. Previously an invalid region tag would cause us to treat it like rpm v3 package on entry, skipping all the region sanity checks and then crashing and burning later on when the immutable tag is fetched. - Refer to REGION_TAG_TYPE instead of RPM_BIN_TYPE wrt the expected type of region tag for consistency and clarity, they are the same exact thing though. - Should unify these damn copy-slop check one of these days, sigh... For now, settling for the easily backportable approach. - Fixes the other half of CVE-2012-0060
2011-11-30Update internal callers to use headerImport() instead of headerLoad()Panu Matilainen1-3/+4
- Pass size where possible, this is a bit redundant in places since its already checked in various places but wont hurt anyway.
2011-11-24Log an error on attempt to sign V3 packages (RhBug:517818 & others)Panu Matilainen1-0/+3
- We haven't been able to sign V3 packages in the last decade or so, might as well spit out an error on it instead of silently failing.
2011-11-09Switch to using rpmKeyringVerifySig() internallyPanu Matilainen1-23/+15
- Change rpmVerifySignature() to take just the signature parameters instead of the whole dig (this is an internal API so we're free to mess with it) from which it only needed the signature params. - The internal low-level verifySignature() is thus reduced to to a call to rpmKeyringVerifySig() and spitting some silly strings to msg. - With this, keyring can now use and reuse the its internally stored pgp key parameters instead of having to parse the same PGP packets over and over. As a result, signature checking is faster now. Not dramatically so but measurably nevertheless.
2011-11-09Don't make assumptions about how pgpDig allocates thingsPanu Matilainen1-2/+2
- Only call pgpDigGetParams() on the public key once we've at least tried to fetch it via rpmKeyringLookup(). This way we dont assume things about how pgpDig internal allocation is done - currently it does return what's essentially a static pointer into pgpDig, but this is not a reasonable assumption for an opaque type. No functional changes.
2011-11-07Use pgpDigParamsAlgo() throughout the codebasePanu Matilainen1-1/+0
- Tedious but straightforward conversion to use the API instead of going to the struct directly. - Remove digest.h includes where no longer necessary
2011-11-07Eliminate direct pgpDig accesses from lowlevel signature codePanu Matilainen1-7/+11
2011-11-07Add another pgpVerify variant which takes key and sig as separate argsPanu Matilainen1-1/+1
- pgpVerifySig() is now just a dumb wrapper around pgpVerifySignature() which does the real work. - Update the sole caller to use the new interface instead, deprecate the old dig interface. - First steps towards getting rig of pgpDig which always was a strange creature and now is nothing but a nuisance and obfuscation. Yes keys and signatures walk hand in hand much of the time, but they come from different sources and want to be handled as separate data really.
2011-11-04Add a couple of missing includes, masked by NSS headersPanu Matilainen1-0/+1
2011-10-20Verify the entire region trailer, not just its offset, is within data areaPanu Matilainen1-1/+2
- Offset being within the data area doesn't help if the actual data doesn't fit. Since the trailer size is well known, we can just as easily make the check accurate to prevent reading beyond end of data in case the offset is subtly wrong. - In headerLoad(), region offset of zero doesn't need sanity checking, only validate if its something else and do so accurately there too.
2011-10-06Eliminate redundant NULL-checks in lower level sigchecking functionsPanu Matilainen1-9/+3
- sigtd->data and dig checking (where needed) is done at rpmVerifySignature() level, dont bother double-checking - Hash context is dup'ed, which CAN fail, so while we dont need to check the argument for non-null, the dup result needs to be checked for digests. For actual signatures the dup happens elsewhere, we dont need to check the argument for non-null here.
2011-10-06Sanitize rpmVerifySignature() a bitPanu Matilainen1-7/+13
- Hash context is required for everything, require non-NULL ctx in rpmVerifySignature() already - pgpDig is only relevant for true signature, digest checking doesn't need it - dont require dummy dig to be passed for digests. - Treat unknown signatures as a case of bad parameters: we're the only caller of rpmVerifySignature() so it'd be us screwing up if we ask for unknown signature to be verified. - Treat bad parameters as a hard failure instead of "not found", bad parameters mean we cannot verify the signature which really equals FAIL.
2011-07-14Sanity check signatures even if we dont have a keyPanu Matilainen1-5/+3
- Fixes a regression originating all the way back from commit c7fc09d585ff3831924f72f61d990aa791f2c3f2 (ie rpm >= 4.8.0) where a package with a bogus signature can slip through undetected if we dont have a key for it. - This additional sanity check on the signature prevents is enough to prevent the fuzzed package in RhBug:721225 from crashing us by stopping the bad package at the front door. That we don't have proper tag data validation is another, much wider issue...
2011-05-28Eliminate dead NULL-assignments at scope-end in librpm, part IIPanu Matilainen1-2/+2
- Remove NULL-assignments of local variables at the end of scope in package+signature manipulation code
2011-04-28Remove redundant strlen()'s on sha1 digest verificationPanu Matilainen1-1/+1
- string comparison notices different length anyway, avoid going through the same data twice
2011-03-23Avoid timedRead() usageJindrich Novy1-3/+3
- it is to be removed in the next soname bump
2010-10-22Replace remaing rpmSigTag uses with rpmTagValPanu Matilainen1-4/+4
- Some of these might actually be "correct" but about one case from librpmbuild cascades down here ... just not worth the trouble to keep the as rpmSigTags.
2010-09-29And now sighdrPut() can be buried back into signature.cPanu Matilainen1-0/+13
2010-09-29Clean up makeHDRDigest() a bitPanu Matilainen1-4/+0
- No need to separately free this stuff (at least anymore), it gets done on exit anyway.
2010-09-29Lift the signature generation in all its g(l)ory to rpmgensig.cPanu Matilainen1-256/+0
- signature.c is now entirely free of all actual signing activities, which requires stuff that like gpg that nothing else needs.
2010-09-29Move sighdrPut() to inline function in signature.hPanu Matilainen1-12/+0
- Avoids having to expose this in the ABI in the next steps
2010-09-29Split signature and digest generation to separate functionsPanu Matilainen1-17/+32
- Similar in spirit to commit 825691afb2a8e2c0b3c6a031950f3c7855dc4c6e, these have fairly little in common really. - Change the function names to force breakage on users (these are exported in ABI but not in public headers so "users" are internal uses in practise): the automatically generated bits in signature header are not signatures, but digests (even size is a checksum of sorts) ... and fix the couple of internal uses.
2010-09-29Split internal header signature and digest generation to separate functionsPanu Matilainen1-26/+46
- These have fairly little in common in reality: one is always automatically created on package generation, the other is optional extra step requiring passphrases and all sorts of other things. - The switch-cases are now fairly hysterical but leaving them for later spring-clean to keep changes minimal for this step. - No functional changes (supposedly ;)
2010-09-28Whoops, wrong enum type used for pubkey algorithmPanu Matilainen1-1/+1
- dumb thinko/typo from commit 0e143cfe9f11abc42733d2265dc6d61cb716e5a4
2010-09-28Decide header sigtag based on what was actually writtenPanu Matilainen1-2/+2
- makeGPGSignature() figures the signature type by parsing the created signature, use that instead of the rather bogus tag based on %_signature macro value passed from the cli level.
2010-09-03Put the rpmLookupSignature() and rpmGetPassPhrase() out of their miseryPanu Matilainen1-143/+0
2010-06-29Add some sanity checks for generated signatures (related to RhBug:608599)Panu Matilainen1-1/+24
- GPG supports all sorts of algorithms NSS doesn't, do some basic tests to verify the generated signature is something we can actually use.
2010-01-05Move <errno.h> include out of system.h to the places that need itPanu Matilainen1-0/+1
2010-01-05Unconditionally include <sys/wait.h> where neededPanu Matilainen1-0/+1
- no point conditionalizing what we cant live without
2009-12-23Move getpass() portability tweaks out of system.hPanu Matilainen1-0/+5
- only signature.c needs, no need to pollute system.h
2009-11-25Fix signature password checking result on abnormal conditions (RhBug:496754)Panu Matilainen1-1/+2
- Execve() failure wasn't returning an error code, causing rpm to think the password was ok when we couldn't even try verifying - Stricter return code checking from the password checking child: the password can only be ok if the child exits with WIFEXITED() *and* WIFEXITCODE() of 0. Also WIFEXITCODE() should only be called if WIFEXITED() returns true.
2009-08-31Replace equal/not equal uses of str[n]cmp() with rstreq[n] in header codePanu Matilainen1-1/+1
2009-06-23Set HEADERFLAGS_ALLOCATED centrally from headerLoad()Panu Matilainen1-1/+2
- requiring every caller to handle this separately, violating header type opaqueness in the process, doesn't seem that bright an idea - also fix a memleak on signature header read in case of failure
2009-05-20Remove unnecessary includes + other minor include correctionsPanu Matilainen1-5/+2
2009-05-20Remove size "signature" verificationPanu Matilainen1-30/+0
- rpm itself hasn't used this for anything in ages, its broken too for quite some time and nobody noticed -> nobody's going to miss this
2009-03-26Put the PGP foobar signature generation out of its miseryPanu Matilainen1-235/+12
- the last freeware PGP version (6.5.8) is from year 2000 and doesn't come close to compiling on modern distros, commercial versions we're not interested in - "PGP" signatures in rpm mean RSA, gpg can handle that just fine since forever - the code's been unused for years, unlikely to be functional anyway...
2009-03-25Unify DSA/RSA/GPG/blaa signature verification, simplifyPanu Matilainen1-46/+14
- verifyRSA/DSA were just the same already, differences are in key/sig parameters which dont matter on this level - these dont need sigtd for anything, the data has been parsed into pgpDig before we get here - add extra flag for header-only vs header+payload signatures, we know which is it in rpmVerifySignature()
2009-03-25Rename internal signature verification functionsPanu Matilainen1-6/+6
- size, md5 and sha1 aren't really signatures
2009-03-25Reorder internal signature verification argumentsPanu Matilainen1-10/+10
- move retval msg last everywhere
2009-03-25Push signature identification to librpmio / pgp handlingPanu Matilainen1-52/+8
- retrieve names from pgp tables instead of manually duplicated strings
2009-03-25Remove redundant RSA/DSA parameter checksPanu Matilainen1-16/+0
- if this stuff doesn't match, pgpVerifySig() will fail anyway, dont bother checking for same things over and over
2009-03-25Push signature verification down to librpmioPanu Matilainen1-55/+3
- new pgpVerifySig() call to perform the lowlevel verify, use for verifying DSA/RSA signatures - librpm is now free of NSS specifics (apart from what still leaks through including rpmio/digest.h), remove linkage
2009-03-25These cases are identical now...Panu Matilainen1-4/+0
2009-03-25Rename arguments, RSA keys are certainly not limited to md5 hashesPanu Matilainen1-6/+6
2009-03-25Use makeGPGSignature() for both DSA and RSAPanu Matilainen1-19/+1
- in reality makePGPSignature() never gets called here due to other fun...
2009-03-25Eliminate header/payload digests from pgpDig_s, they dont belongPanu Matilainen1-9/+7
- 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-16Handle rpmDigestDup() failure in signature checkingPanu Matilainen1-6/+6
2009-03-16Eliminate unnecessary field from pgpDig_sPanu Matilainen1-2/+2
- key/signature can't be both DSA and RSA at the same time
2009-03-12Rip all handling of broken md5 sums from 1997, rpm 2.x eraPanu Matilainen1-4/+0
- we dont even recognize rpm 2.x packages as rpms...