2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FSecCryptoSha2Hash.h
20 * @brief This is the header file for the %Sha2Hash class.
22 * This header file contains the declarations of the %Sha2Hash class.
24 #ifndef _FSEC_CRYPTO_SHA2_HASH_H_
25 #define _FSEC_CRYPTO_SHA2_HASH_H_
27 #include <FSecCryptoIHash.h>
32 namespace Tizen { namespace Security { namespace Crypto
37 * @brief This class implements the SHA-2 hash algorithm.
41 * The %Sha2Hash class implements the SHA-2 hash algorithm. @n
43 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/security/hashing.htm">Hashing</a>.
45 * @see Tizen::Security::Crypto::IHash
46 * @see Tizen::Security::Crypto::Md5Hash
47 * @see Tizen::Security::Crypto::Sha1Hash
49 class _OSP_EXPORT_ Sha2Hash
50 : public virtual IHash
51 , public Tizen::Base::Object
56 * This is the default constructor for this class.
63 * This destructor overrides Tizen::Base::Object::~Object().
67 virtual ~Sha2Hash(void);
70 * Sets the hash algorithm.
74 * @return An error code
75 * @param[in] algorithm The name of the hash algorithm @n
76 * For example, "SHA2/224", "SHA2/256", "SHA2/384", or "SHA2/512".
77 * @exception E_SUCCESS The method is successful.
78 * @exception E_UNSUPPORTED_ALGORITHM The algorithm is not supported.
80 virtual result SetAlgorithm(const Tizen::Base::String& algorithm);
83 * Gets the hashes of the data (single-part).
87 * @return A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
88 * else @c null if an error occurs
89 * @param[in] input An instance of Tizen::Base::ByteBuffer
90 * @exception E_SUCCESS The method is successful.
91 * @exception E_INVALID_ARG The input Tizen::Base::ByteBuffer is empty or contains invalid data.
92 * @exception E_OUT_OF_MEMORY The memory is insufficient.
93 * @exception E_SYSTEM A system error has occurred. @n
94 * The method has failed to operate with the OpenSSL library, or
95 * the Tizen::Base::ByteBuffer operation has failed.
96 * @remarks The specific error code can be accessed using the GetLastResult() method.
98 virtual Tizen::Base::ByteBuffer* GetHashN(const Tizen::Base::ByteBuffer& input) const;
101 * Initializes a multiple-part hash operation.
105 * @return An error code
106 * @exception E_SUCCESS The method is successful.
107 * @exception E_OUT_OF_MEMORY The memory is insufficient.
108 * @exception E_SYSTEM A system error has occurred. @n
109 * The method has failed to operate with the OpenSSL library.
111 virtual result Initialize(void);
114 * Updates a multiple-part hash operation while processing another data part.
118 * @return An error code
119 * @param[in] input An instance of Tizen::Base::ByteBuffer
120 * @exception E_SUCCESS The method is successful.
121 * @exception E_INVALID_ARG The input Tizen::Base::ByteBuffer is empty or contains invalid data.
122 * @exception E_OUT_OF_MEMORY The memory is insufficient.
123 * @exception E_SYSTEM A system error has occurred. @n
124 * The method has failed to operate with the OpenSSL library, or
125 * the Tizen::Base::ByteBuffer operation has failed.
127 virtual result Update(const Tizen::Base::ByteBuffer& input);
130 * Finalizes a multiple-part hash operation.
134 * @return A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
135 * else @c null if an error occurs
136 * @exception E_SUCCESS The method is successful.
137 * @exception E_OUT_OF_MEMORY The memory is insufficient.
138 * @exception E_SYSTEM A system error has occurred. @n
139 * The method has failed to operate with the OpenSSL library, or
140 * the Tizen::Base::ByteBuffer operation has failed.
141 * @remarks The specific error code can be accessed using the GetLastResult() method.
143 virtual Tizen::Base::ByteBuffer* FinalizeN(void);
148 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
152 Sha2Hash(const Sha2Hash& rhs);
155 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
159 Sha2Hash& operator =(const Sha2Hash& rhs);
162 const env_md_st* __pAlgorithm;
163 env_md_ctx_st* __pEvpMdCtx;
165 class _Sha2HashImpl* __pSha2HashImpl;
166 friend class _Sha2HashImpl;
170 } } } //Tizen::Security:Crypto
172 #endif //_FSEC_CRYPTO_SHA2_HASH_H_