summaryrefslogtreecommitdiff
path: root/blake2.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-11-15 04:12:35 -0500
committerJeffrey Walton <noloader@gmail.com>2018-11-15 04:12:35 -0500
commit8b4da4ca68bc3b38aad0e795088e0cc6d9efc87f (patch)
tree6e6cb7ff75ff65229fbe4354d85d7e827e975135 /blake2.cpp
parente784c04eb0f3daada055e75b3354bd617a8749f3 (diff)
downloadcryptopp-git-8b4da4ca68bc3b38aad0e795088e0cc6d9efc87f.tar.gz
Update comments
Diffstat (limited to 'blake2.cpp')
-rw-r--r--blake2.cpp33
1 files changed, 22 insertions, 11 deletions
diff --git a/blake2.cpp b/blake2.cpp
index e80985d4..96dedfbc 100644
--- a/blake2.cpp
+++ b/blake2.cpp
@@ -1,6 +1,17 @@
-// blake2.cpp - written and placed in the public domain by Jeffrey Walton and Zooko
-// Wilcox-O'Hearn. Based on Aumasson, Neves, Wilcox-O'Hearn and Winnerlein's
-// reference BLAKE2 implementation at http://github.com/BLAKE2/BLAKE2.
+// blake2.cpp - written and placed in the public domain by Jeffrey Walton
+// and Zooko Wilcox-O'Hearn. Based on Aumasson, Neves,
+// Wilcox-O'Hearn and Winnerlein's reference BLAKE2
+// implementation at http://github.com/BLAKE2/BLAKE2.
+//
+// The BLAKE2b and BLAKE2s numbers are consistent with the BLAKE2 team's
+// numbers. However, we have an Altivec/POWER7 implementation of BLAKE2s,
+// and a POWER8 implementation of BLAKE2b (BLAKE2 is missing them). The
+// Altivec/POWER7 code is about 2x faster than C++ when using GCC 5.0 or
+// above. The POWER8 code is about 2.5x faster than C++ when using GCC 5.0
+// or above. If you use GCC 4.0 (PowerMac) or GCC 4.8 (GCC Compile Farm)
+// then the PowerPC code will be slower than C++. Be sure to use GCC 5.0
+// or above for PowerPC builds or disable Altivec for BLAKE2b and BLAKE2s
+// if using the old compilers.
#include "pch.h"
#include "config.h"
@@ -15,6 +26,7 @@
// #undef CRYPTOPP_SSE41_AVAILABLE
// #undef CRYPTOPP_ARM_NEON_AVAILABLE
// #undef CRYPTOPP_ALTIVEC_AVAILABLE
+// #undef CRYPTOPP_POWER8_AVAILABLE
// Disable NEON/ASIMD for Cortex-A53 and A57. The shifts are too slow and C/C++ is about
// 3 cpb faster than NEON/ASIMD. Also see http://github.com/weidai11/cryptopp/issues/367.
@@ -22,11 +34,6 @@
# undef CRYPTOPP_ARM_NEON_AVAILABLE
#endif
-#if !(CRYPTOPP_ALTIVEC_AVAILABLE)
-# undef CRYPTOPP_POWER7_AVAILABLE
-# undef CRYPTOPP_POWER8_AVAILABLE
-#endif
-
NAMESPACE_BEGIN(CryptoPP)
// Export the tables to the SIMD files
@@ -155,7 +162,7 @@ extern void BLAKE2_Compress32_NEON(const byte* input, BLAKE2s_State& state);
extern void BLAKE2_Compress64_NEON(const byte* input, BLAKE2b_State& state);
#endif
-#if CRYPTOPP_POWER7_AVAILABLE
+#if CRYPTOPP_ALTIVEC_AVAILABLE
extern void BLAKE2_Compress32_POWER7(const byte* input, BLAKE2s_State& state);
#endif
@@ -384,6 +391,10 @@ std::string BLAKE2s::AlgorithmProvider() const
if (HasPower7())
return "Power7";
#endif
+#if (CRYPTOPP_ALTIVEC_AVAILABLE)
+ if (HasAltivec())
+ return "Altivec";
+#endif
return "C++";
}
@@ -655,8 +666,8 @@ void BLAKE2s::Compress(const byte *input)
return BLAKE2_Compress32_NEON(input, *m_state.data());
}
#endif
-#if CRYPTOPP_POWER7_AVAILABLE
- if(HasPower7())
+#if CRYPTOPP_ALTIVEC_AVAILABLE
+ if(HasAltivec())
{
return BLAKE2_Compress32_POWER7(input, *m_state.data());
}