|
||||
File indexing completed on 2025-01-18 09:55:09
0001 // sm3.h - written and placed in the public domain by Jeffrey Walton and Han Lulu 0002 // Based on the specification provided by Sean Shen and Xiaodong Lee. 0003 // Based on code by Krzysztof Kwiatkowski and Jack Lloyd. 0004 // Also see https://tools.ietf.org/html/draft-shen-sm3-hash. 0005 0006 /// \file sm3.h 0007 /// \brief Classes for the SM3 hash function 0008 /// \details SM3 is a hash function designed by Xiaoyun Wang, et al. The hash is part of the 0009 /// Chinese State Cryptography Administration portfolio. 0010 /// \sa <A HREF="https://tools.ietf.org/html/draft-shen-sm3-hash">SM3 Hash Function</A> and 0011 /// <A HREF="http://github.com/guanzhi/GmSSL">Reference implementation using OpenSSL</A>. 0012 /// \since Crypto++ 6.0 0013 0014 #ifndef CRYPTOPP_SM3_H 0015 #define CRYPTOPP_SM3_H 0016 0017 #include "config.h" 0018 #include "iterhash.h" 0019 0020 NAMESPACE_BEGIN(CryptoPP) 0021 0022 /// \brief SM3 hash function 0023 /// \details SM3 is a hash function designed by Xiaoyun Wang, et al. The hash is part of the 0024 /// Chinese State Cryptography Administration portfolio. 0025 /// \sa <A HREF="https://tools.ietf.org/html/draft-shen-sm3-hash">SM3 Hash Function</A> 0026 /// \since Crypto++ 6.0 0027 class SM3 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SM3, 32, true> 0028 { 0029 public: 0030 /// \brief Initialize state array 0031 /// \param state the state of the hash 0032 /// \details InitState sets a state array to SM3 initial values 0033 /// \details Hashes which derive from IteratedHashWithStaticTransform provide static 0034 /// member functions InitState() and Transform(). External classes, like SEAL and MDC, 0035 /// can initialize state with a user provided key and operate the hash on the data 0036 /// with the user supplied state. 0037 static void InitState(HashWordType *state); 0038 0039 /// \brief Operate the hash 0040 /// \param digest the state of the hash 0041 /// \param data the data to be digested 0042 /// \details Transform() operates the hash on <tt>data</tt>. When the call is invoked 0043 /// <tt>digest</tt> holds initial or current state. Upon return <tt>digest</tt> holds 0044 /// the hash or updated state. 0045 /// \details Hashes which derive from IteratedHashWithStaticTransform provide static 0046 /// member functions InitState() and Transform(). External classes, like SEAL and MDC, 0047 /// can initialize state with a user provided key and operate the hash on the data 0048 /// with the user supplied state. 0049 static void Transform(HashWordType *digest, const HashWordType *data); 0050 0051 /// \brief The algorithm name 0052 /// \return C-style string "SM3" 0053 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() { return "SM3"; } 0054 0055 protected: 0056 size_t HashMultipleBlocks(const HashWordType *input, size_t length); 0057 }; 0058 0059 NAMESPACE_END 0060 0061 #endif // CRYPTOPP_SM3_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |