diff options
author | Brian Smith <brian@briansmith.org> | 2015-02-02 14:21:27 -0800 |
---|---|---|
committer | Brian Smith <brian@briansmith.org> | 2015-02-02 14:21:27 -0800 |
commit | e20bed17c0957b6df106e6f355a2c725d2c23f06 (patch) | |
tree | 63b2df9050c262796c1f6d64e4f823c554bca286 /lib/mozpkix/lib/pkixnss.cpp | |
parent | 1e3c2dd35033397dc6a7caef2769383549ab4322 (diff) | |
download | nss-hg-e20bed17c0957b6df106e6f355a2c725d2c23f06.tar.gz |
Bug 1128413, Part 1: Fix switch-related warnings, r=mmc
Diffstat (limited to 'lib/mozpkix/lib/pkixnss.cpp')
-rw-r--r-- | lib/mozpkix/lib/pkixnss.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/lib/mozpkix/lib/pkixnss.cpp b/lib/mozpkix/lib/pkixnss.cpp index aea39d614..72187cf69 100644 --- a/lib/mozpkix/lib/pkixnss.cpp +++ b/lib/mozpkix/lib/pkixnss.cpp @@ -33,6 +33,7 @@ #include "pkix/pkix.h" #include "pkix/ScopedPtr.h" #include "pkixder.h" +#include "pkixutil.h" #include "secerr.h" #include "sslerr.h" @@ -56,6 +57,17 @@ CheckPublicKeySize(Input subjectPublicKeyInfo, unsigned int minimumNonECCBits, return MapPRErrorCodeToResult(PR_GetError()); } + // Some compilers complain if if we don't explicitly list every case. That is + // usually what we want, but in this case we really want to support an + // open-ended set of key types that might be expanded by future NSS versions. +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch-enum" +#elif defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable: 4061) +#endif + switch (publicKey.get()->keyType) { case ecKey: { @@ -87,28 +99,27 @@ CheckPublicKeySize(Input subjectPublicKeyInfo, unsigned int minimumNonECCBits, case NamedCurve::secp384r1: // fall through case NamedCurve::secp521r1: break; - default: - return Result::ERROR_UNSUPPORTED_ELLIPTIC_CURVE; } return Success; } + case rsaKey: if (SECKEY_PublicKeyStrengthInBits(publicKey.get()) < minimumNonECCBits) { return Result::ERROR_INADEQUATE_KEY_SIZE; } break; - case dsaKey: // fall through - case nullKey: // fall through - case fortezzaKey: // fall through - case dhKey: // fall through - case keaKey: // fall through - case rsaPssKey: // fall through - case rsaOaepKey: // fall through + default: return Result::ERROR_UNSUPPORTED_KEYALG; } +#if defined(__clang__) +#pragma clang diagnostic pop +#elif defined(_MSC_VER) +#pragma warning(pop) +#endif + return Success; } @@ -160,9 +171,9 @@ VerifySignedDataNSS(const SignedDataWithSignature& sd, digestAlg = SEC_OID_SHA1; break; case SignatureAlgorithm::unsupported_algorithm: // fall through - default: return NotReached("unknown signature algorithm", Result::ERROR_CERT_SIGNATURE_ALGORITHM_DISABLED); + MOZILLA_PKIX_UNREACHABLE_DEFAULT_ENUM } Result rv; @@ -244,9 +255,7 @@ MapResultToPRErrorCode(Result result) #undef MOZILLA_PKIX_MAP - default: - PR_NOT_REACHED("Unknown error code in MapResultToPRErrorCode"); - return SEC_ERROR_LIBRARY_FAILURE; + MOZILLA_PKIX_UNREACHABLE_DEFAULT_ENUM } } |