summaryrefslogtreecommitdiff
path: root/seckey.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2016-09-07 09:32:06 -0400
committerJeffrey Walton <noloader@gmail.com>2016-09-07 09:32:06 -0400
commitf0e7b45bcbcc5b979d9d8df9d151f5951996e6e9 (patch)
tree1bcce17d98e98b9dad7124759c0a99edd5b2528d /seckey.h
parente2f2ace688167fe71d574b0c1b3305eacaeb9077 (diff)
downloadcryptopp-git-f0e7b45bcbcc5b979d9d8df9d151f5951996e6e9.tar.gz
Remove comma operator from return values for StaticGetDefaultRounds and StaticGetValidKeyLength in non-constexpr builds (Issue 255)
Diffstat (limited to 'seckey.h')
-rw-r--r--seckey.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/seckey.h b/seckey.h
index 31286ce6..bbf1ea7a 100644
--- a/seckey.h
+++ b/seckey.h
@@ -71,11 +71,20 @@ public:
//! \param keylength the size of the key, in bytes
//! \details keylength is unused in the default implementation.
CRYPTOPP_CONSTEXPR static unsigned int StaticGetDefaultRounds(size_t keylength)
- {return CRYPTOPP_UNUSED(keylength), DEFAULT_ROUNDS;}
+ {
+ // Comma operator breaks Debug builds with GCC 4.0 - 4.6.
+ // Also see http://github.com/weidai11/cryptopp/issues/255
+#if defined(CRYPTOPP_CXX11_CONSTEXPR)
+ return CRYPTOPP_UNUSED(keylength), static_cast<unsigned int>(DEFAULT_ROUNDS);
+#else
+ CRYPTOPP_UNUSED(keylength);
+ return static_cast<unsigned int>(DEFAULT_ROUNDS);
+#endif
+ }
protected:
//! \brief Validates the number of rounds for an algorithm.
- //! \param rounds the canddiate number of rounds
+ //! \param rounds the candidate number of rounds
//! \param alg an Algorithm object used if the number of rounds are invalid
//! \throws InvalidRounds if the number of rounds are invalid
//! \details ThrowIfInvalidRounds() validates the number of rounds and throws if invalid.
@@ -94,7 +103,7 @@ protected:
}
//! \brief Validates the number of rounds for an algorithm
- //! \param param the canddiate number of rounds
+ //! \param param the candidate number of rounds
//! \param alg an Algorithm object used if the number of rounds are invalid
//! \returns the number of rounds for the algorithm
//! \throws InvalidRounds if the number of rounds are invalid
@@ -143,7 +152,16 @@ public:
//! \details The default implementation returns KEYLENGTH. keylength is unused
//! in the default implementation.
CRYPTOPP_CONSTEXPR static size_t CRYPTOPP_API StaticGetValidKeyLength(size_t keylength)
- {return CRYPTOPP_UNUSED(keylength), KEYLENGTH;}
+ {
+ // Comma operator breaks Debug builds with GCC 4.0 - 4.6.
+ // Also see http://github.com/weidai11/cryptopp/issues/255
+#if defined(CRYPTOPP_CXX11_CONSTEXPR)
+ return CRYPTOPP_UNUSED(keylength), static_cast<size_t>(KEYLENGTH);
+#else
+ CRYPTOPP_UNUSED(keylength);
+ return static_cast<size_t>(KEYLENGTH);
+#endif
+ }
};
//! \class VariableKeyLength