Commit Graph

12 Commits

Author SHA1 Message Date
Panu Matilainen e2659684b4 Revert back to DSA-1 only support for NSS
- This essentially reverts commit fe5a1e5dfa
  which apparently causes intermittent failures with DSA-1. Look at
  DSA-2 again on some sunnier day...
2014-05-19 15:50:32 +03:00
Michael Schroeder 70af849f0c Check the mpi length before calling setmpi, remove pend parameter
Simplifies the code a lot. Also check that that there's room for the
mpi len before calling pgpMpiLen().

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2013-08-28 20:34:11 +03:00
Panu Matilainen cca91666d0 Failure to initialize crypto is fatal
- Almost nothing works if crypto fails to initialize for whatever reason,
  check and propagate rpmInitCrypto() failure from rpmReadConfigFiles().
- Logging the error left for individual crypto backends to let them
  identify themselves: beecrypt requires no initialization whatsoever
  so it cannot fail at all, but NSS can fail in a number of entertaining
  ways due to missing dlopen()'ed bits and pieces, this should help
  avoiding wild-goose chases in such cases (RhBug:909627, RhBug:909618...)
2013-02-12 05:19:23 +02:00
Panu Matilainen fe5a1e5dfa Add support for DSA2 signatures with NSS versions that support it
- DSA2 signatures are not fixed-length so we need to calculate the
  number of bits and bytes (quite literally) from the data we get.
  Unfortunately it seems DSA2 in NSS 3.14 is slightly buggy (mixup
  wrt bytes and bits in DSA2 keysize in its verification internals),
  preventing this from actually working with that version.
- Prior to this, rpm would report "unverifiable signature" on DSA2,
  with NSS 3.14 it'll now report signature as BAD, once NSS is fixed
  it should "just work".
2012-12-13 13:36:41 +02:00
Panu Matilainen 2d39f13064 Handle allocation failure in NSS DSA signature initialization 2012-12-04 14:06:42 +02:00
Panu Matilainen e15e298234 Fix build with older NSS versions that dont support SHA224
- SHA224-support was added around NSS 3.13, dont break compilation
  with older versions just for this rarely used hash.
- HASH_AlgSHA224 is an enum so test for SHA224_LENGTH define instead
2012-11-30 12:23:42 +02:00
Panu Matilainen 466a6b554e Condence NSS getHashType() a bit, handle SHA224 too
- Not much point in enumurating unsupported cases, or with switch-breaks
  after returns.
- Recognize SHA224 too
2012-11-30 12:20:05 +02:00
Panu Matilainen 9b995a7674 Get rid of long since deprecated VFY_VerifyDigest() uses
- VFY_VerifyDigest() has been deprecated since NSS >= 3.12 and for
  a good reason too: with VFY_VerifyDigest() caller needs to painfully
  enumerate every possible supported enc + hash combination, only for
  NSS to revert the process. Use the saner VFY_VerifyDigestDirect()
  interface instead and test for its presence in configure.
- This means we now require NSS >= 3.12 but as that's already 4.5 years
  old and included in ancient beasts like RHEL-4, this doesn't seem
  exactly unreasonable requirement. And then there's always beecrypt...
2012-11-29 12:35:13 +02:00
Panu Matilainen 604da18bc2 Use NSS-defined constants for DSA q-bits and signature length too
- No functional changes here (either), but using the proper constants
  simply makes things that little bit clearer.
2012-11-29 11:05:46 +02:00
Panu Matilainen 73be0fc7d9 Avoid deprecation warnings from NSS >= 3.14
- NSS >= 3.14 introduces support for DSA2 and marks DSA_SUBPRIME_LEN
  as deprecated. Use explicit DSA1_SUBPRIME_LEN (we only support DSA1
  for now) instead where available, add compatibility define for
  older versions.
- Also directly include <blapit.h> where its defined - blabit.h gets
  included via cryptohi.h but being explicit about it avoids having
  to redefine it again "just in case".
2012-11-29 10:52:29 +02:00
Panu Matilainen 5ecfdcea4e Use private NSS context if NSS supports it (RhBug:871485)
- Older NSS versions operate on global context, which can cause
  all sorts of trouble when an API user tries to use NSS for their
  own purposes: eg they might want to use NSS databases which is not
  possible once we've initialized NSS with NSS_NoDB_Init(). Further
  background on the subject at https://wiki.mozilla.org/NSS_Library_Init
- Use private private NSS context when possible (NSS >= 3.12.5) to
  avoid such clashes, but keep support for older versions for now.
2012-10-31 09:43: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