summaryrefslogtreecommitdiff
path: root/sha.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-08-05 00:24:02 -0400
committerJeffrey Walton <noloader@gmail.com>2017-08-05 00:24:02 -0400
commit20def29d33d5a296051345bab73eb0c617068ce9 (patch)
tree9a8fe0a6462eb21e0ac9d7beb4bf613789502a0b /sha.h
parenta2cab9311703d7ce8d05844321923c2754a1f771 (diff)
downloadcryptopp-git-20def29d33d5a296051345bab73eb0c617068ce9.tar.gz
Use MOVDQU for SSE2 in static transform (Issue 455)
Updated documentation
Diffstat (limited to 'sha.h')
-rw-r--r--sha.h126
1 files changed, 117 insertions, 9 deletions
diff --git a/sha.h b/sha.h
index 7660909e..530aee42 100644
--- a/sha.h
+++ b/sha.h
@@ -25,12 +25,34 @@ NAMESPACE_BEGIN(CryptoPP)
class CRYPTOPP_DLL SHA1 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 20, SHA1>
{
public:
-#if CRYPTOPP_BOOL_SSE_SHA_INTRINSICS_AVAILABLE
- size_t HashMultipleBlocks(const word32 *input, size_t length);
-#endif
+ //! \brief Initialize state array
+ //! \param state the state of the hash
+ //! \details InitState sets a state array to SHA1 initial values
+ //! \details Hashes which derive from IteratedHashWithStaticTransform provide static
+ //! member functions InitState and Transform. External classes, like SEAL and MDC,
+ //! can initialize state with a user provided key and operate the hash on the data
+ //! with the used supplied initial state.
+ //! \note On Intel platforms the state array must be 16-byte aligned for SSE2.
static void CRYPTOPP_API InitState(HashWordType *state);
+ //! \brief Operate the hash
+ //! \param digest the state of the hash
+ //! \param data the data to be digested
+ //! \details Transform operates the hash on <tt>data</tt>. When the call is invoked
+ //! <tt>data</tt> holds initial state. Upon return <tt>data</tt> holds the hash or
+ //! updated state.
+ //! \details Hashes which derive from IteratedHashWithStaticTransform provide static
+ //! member functions InitState and Transform. External classes, like SEAL and MDC,
+ //! can initialize state with a user provided key and operate the hash on the data
+ //! with the used supplied initial state.
+ //! \note On Intel platforms the state array and data must be 16-byte aligned for SSE2.
static void CRYPTOPP_API Transform(word32 *digest, const word32 *data);
+ //! \brief The algorithm name
+ //! \returns C-style string "SHA-1"
CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "SHA-1";}
+
+#if CRYPTOPP_BOOL_SSE_SHA_INTRINSICS_AVAILABLE
+ size_t HashMultipleBlocks(const word32 *input, size_t length);
+#endif
};
//! \class SHA256
@@ -40,12 +62,34 @@ public:
class CRYPTOPP_DLL SHA256 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA256, 32, true>
{
public:
-#if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_SHA_ASM)
- size_t HashMultipleBlocks(const word32 *input, size_t length);
-#endif
+ //! \brief Initialize state array
+ //! \param state the state of the hash
+ //! \details InitState sets a state array to SHA256 initial values
+ //! \details Hashes which derive from IteratedHashWithStaticTransform provide static
+ //! member functions InitState and Transform. External classes, like SEAL and MDC,
+ //! can initialize state with a user provided key and operate the hash on the data
+ //! with the used supplied initial state.
+ //! \note On Intel platforms the state array must be 16-byte aligned for SSE2.
static void CRYPTOPP_API InitState(HashWordType *state);
+ //! \brief Operate the hash
+ //! \param digest the state of the hash
+ //! \param data the data to be digested
+ //! \details Transform operates the hash on <tt>data</tt>. When the call is invoked
+ //! <tt>data</tt> holds initial state. Upon return <tt>data</tt> holds the hash or
+ //! updated state.
+ //! \details Hashes which derive from IteratedHashWithStaticTransform provide static
+ //! member functions InitState and Transform. External classes, like SEAL and MDC,
+ //! can initialize state with a user provided key and operate the hash on the data
+ //! with the used supplied initial state.
+ //! \note On Intel platforms the state array and data must be 16-byte aligned for SSE2.
static void CRYPTOPP_API Transform(word32 *digest, const word32 *data);
+ //! \brief The algorithm name
+ //! \returns C-style string "SHA-256"
CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "SHA-256";}
+
+#if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_SHA_ASM)
+ size_t HashMultipleBlocks(const word32 *input, size_t length);
+#endif
};
//! \class SHA224
@@ -55,12 +99,34 @@ public:
class CRYPTOPP_DLL SHA224 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA224, 28, true>
{
public:
-#if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_SHA_ASM)
- size_t HashMultipleBlocks(const word32 *input, size_t length);
-#endif
+ //! \brief Initialize state array
+ //! \param state the state of the hash
+ //! \details InitState sets a state array to SHA224 initial values
+ //! \details Hashes which derive from IteratedHashWithStaticTransform provide static
+ //! member functions InitState and Transform. External classes, like SEAL and MDC,
+ //! can initialize state with a user provided key and operate the hash on the data
+ //! with the used supplied initial state.
+ //! \note On Intel platforms the state array must be 16-byte aligned for SSE2.
static void CRYPTOPP_API InitState(HashWordType *state);
+ //! \brief Operate the hash
+ //! \param digest the state of the hash
+ //! \param data the data to be digested
+ //! \details Transform operates the hash on <tt>data</tt>. When the call is invoked
+ //! <tt>data</tt> holds initial state. Upon return <tt>data</tt> holds the hash or
+ //! updated state.
+ //! \details Hashes which derive from IteratedHashWithStaticTransform provide static
+ //! member functions InitState and Transform. External classes, like SEAL and MDC,
+ //! can initialize state with a user provided key and operate the hash on the data
+ //! with the used supplied initial state.
+ //! \note On Intel platforms the state array and data must be 16-byte aligned for SSE2.
static void CRYPTOPP_API Transform(word32 *digest, const word32 *data) {SHA256::Transform(digest, data);}
+ //! \brief The algorithm name
+ //! \returns C-style string "SHA-224"
CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "SHA-224";}
+
+#if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_SHA_ASM)
+ size_t HashMultipleBlocks(const word32 *input, size_t length);
+#endif
};
//! \class SHA512
@@ -70,8 +136,29 @@ public:
class CRYPTOPP_DLL SHA512 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA512, 64, (CRYPTOPP_BOOL_X86|CRYPTOPP_BOOL_X32)>
{
public:
+ //! \brief Initialize state array
+ //! \param state the state of the hash
+ //! \details InitState sets a state array to SHA512 initial values
+ //! \details Hashes which derive from IteratedHashWithStaticTransform provide static
+ //! member functions InitState and Transform. External classes, like SEAL and MDC,
+ //! can initialize state with a user provided key and operate the hash on the data
+ //! with the used supplied initial state.
+ //! \note On Intel platforms the state array must be 16-byte aligned for SSE2.
static void CRYPTOPP_API InitState(HashWordType *state);
+ //! \brief Operate the hash
+ //! \param digest the state of the hash
+ //! \param data the data to be digested
+ //! \details Transform operates the hash on <tt>data</tt>. When the call is invoked
+ //! <tt>data</tt> holds initial state. Upon return <tt>data</tt> holds the hash or
+ //! updated state.
+ //! \details Hashes which derive from IteratedHashWithStaticTransform provide static
+ //! member functions InitState and Transform. External classes, like SEAL and MDC,
+ //! can initialize state with a user provided key and operate the hash on the data
+ //! with the used supplied initial state.
+ //! \note On Intel platforms the state array and data must be 16-byte aligned for SSE2.
static void CRYPTOPP_API Transform(word64 *digest, const word64 *data);
+ //! \brief The algorithm name
+ //! \returns C-style string "SHA-512"
CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "SHA-512";}
};
@@ -82,8 +169,29 @@ public:
class CRYPTOPP_DLL SHA384 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA384, 48, (CRYPTOPP_BOOL_X86|CRYPTOPP_BOOL_X32)>
{
public:
+ //! \brief Initialize state array
+ //! \param state the state of the hash
+ //! \details InitState sets a state array to SHA384 initial values
+ //! \details Hashes which derive from IteratedHashWithStaticTransform provide static
+ //! member functions InitState and Transform. External classes, like SEAL and MDC,
+ //! can initialize state with a user provided key and operate the hash on the data
+ //! with the used supplied initial state.
+ //! \note On Intel platforms the state array must be 16-byte aligned for SSE2.
static void CRYPTOPP_API InitState(HashWordType *state);
+ //! \brief Operate the hash
+ //! \param digest the state of the hash
+ //! \param data the data to be digested
+ //! \details Transform operates the hash on <tt>data</tt>. When the call is invoked
+ //! <tt>data</tt> holds initial state. Upon return <tt>data</tt> holds the hash or
+ //! updated state.
+ //! \details Hashes which derive from IteratedHashWithStaticTransform provide static
+ //! member functions InitState and Transform. External classes, like SEAL and MDC,
+ //! can initialize state with a user provided key and operate the hash on the data
+ //! with the used supplied initial state.
+ //! \note On Intel platforms the state array and data must be 16-byte aligned for SSE2.
static void CRYPTOPP_API Transform(word64 *digest, const word64 *data) {SHA512::Transform(digest, data);}
+ //! \brief The algorithm name
+ //! \returns C-style string "SHA-384"
CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "SHA-384";}
};