2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FSecCryptoSha2Hash.h
19 * @brief This is the header file for the %Sha2Hash class.
21 * This header file contains the declarations of the %Sha2Hash class.
23 #ifndef _FSEC_CRYPTO_SHA2_HASH_H_
24 #define _FSEC_CRYPTO_SHA2_HASH_H_
26 #include <FSecCryptoIHash.h>
31 namespace Tizen { namespace Security { namespace Crypto
36 * @brief This class implements the SHA-2 hash algorithm.
40 * The %Sha2Hash class implements the SHA-2 hash algorithm. @n
42 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/security/hashing.htm">Hashing</a>.
44 * @see Tizen::Security::Crypto::IHash
45 * @see Tizen::Security::Crypto::Md5Hash
46 * @see Tizen::Security::Crypto::Sha1Hash
48 class _OSP_EXPORT_ Sha2Hash
49 : public virtual IHash
50 , public Tizen::Base::Object
55 * This is the default constructor for this class.
62 * This destructor overrides Tizen::Base::Object::~Object().
66 virtual ~Sha2Hash(void);
69 * Sets the hash algorithm.
73 * @return An error code
74 * @param[in] algorithm The hash algorithm name @n
75 * For example, "SHA2/224", "SHA2/256", "SHA2/384", or "SHA2/512".
76 * @exception E_SUCCESS The method is successful.
77 * @exception E_UNSUPPORTED_ALGORITHM The algorithm is not supported.
79 virtual result SetAlgorithm(const Tizen::Base::String& algorithm);
82 * Gets the hashes of the specified data (single-part).
86 * @return A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
87 * else @c null if an error occurs
88 * @param[in] input An instance of Tizen::Base::ByteBuffer
89 * @exception E_SUCCESS The method is successful.
90 * @exception E_INVALID_ARG The input Tizen::Base::ByteBuffer is empty or contains invalid data.
91 * @exception E_OUT_OF_MEMORY The memory is insufficient.
92 * @exception E_SYSTEM Either of the following conditions has occurred:
93 * - A system error has occurred.
94 * - The method has failed to operate with the OpenSSL library.
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 the 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 Either of the following conditions has occurred:
109 * - A system error has occurred.
110 * - The method has failed to operate with the OpenSSL library.
112 virtual result Initialize(void);
115 * Updates the multiple-part hash operation while processing another data part.
119 * @return An error code
120 * @param[in] input An instance of Tizen::Base::ByteBuffer
121 * @exception E_SUCCESS The method is successful.
122 * @exception E_INVALID_ARG The input Tizen::Base::ByteBuffer is empty or contains invalid data.
123 * @exception E_OUT_OF_MEMORY The memory is insufficient.
124 * @exception E_SYSTEM Either of the following conditions has occurred:
125 * - A system error has occurred.
126 * - The method has failed to operate with the OpenSSL library.
127 * - The Tizen::Base::ByteBuffer operation has failed.
129 virtual result Update(const Tizen::Base::ByteBuffer& input);
132 * Finalizes the multiple-part hash operation.
136 * @return A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
137 * else @c null if an error occurs
138 * @exception E_SUCCESS The method is successful.
139 * @exception E_OUT_OF_MEMORY The memory is insufficient.
140 * @exception E_SYSTEM Either of the following conditions has occurred:
141 * - A system error has occurred.
142 * - The method has failed to operate with the OpenSSL library.
143 * - The Tizen::Base::ByteBuffer operation has failed.
144 * @remarks The specific error code can be accessed using the GetLastResult() method.
146 virtual Tizen::Base::ByteBuffer* FinalizeN(void);
151 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
155 Sha2Hash(const Sha2Hash& rhs);
158 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
162 Sha2Hash& operator =(const Sha2Hash& rhs);
165 const env_md_st* __pAlgorithm;
166 env_md_ctx_st* __pEvpMdCtx;
168 class _Sha2HashImpl* __pSha2HashImpl;
169 friend class _Sha2HashImpl;
173 } } } //Tizen::Security:Crypto
175 #endif //_FSEC_CRYPTO_SHA2_HASH_H_