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 FSecCryptoSha1Hash.h
19 * @brief This is the header file for the %Sha1Hash class.
21 * This header file contains the declarations of the %Sha1Hash class.
23 #ifndef _FSEC_CRYPTO_SHA1_HASH_H_
24 #define _FSEC_CRYPTO_SHA1_HASH_H_
26 #include <FSecCryptoIHash.h>
31 namespace Tizen { namespace Security { namespace Crypto
36 * @brief This class implements the SHA-1 hash algorithm.
40 * The %Sha1Hash class implements the SHA-1 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>.
48 class _OSP_EXPORT_ Sha1Hash
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 ~Sha1Hash(void);
69 * Sets the hash algorithm. @n
70 * The %SetAlgorithm() method is not supported by this class. Do not call this method. @n
71 * If this method is called, it returns @c E_UNSUPPORTED_ALGORITHM.
75 * @return An error code
76 * @param[in] algorithm The hash algorithm name @n
77 * For example "SHA2/224", "SHA2/256", "SHA2/384", or "SHA2/512".
78 * @exception E_SUCCESS The method is successful.
79 * @exception E_UNSUPPORTED_ALGORITHM The algorithm is not supported.
80 * @remarks Do not call this method. It is not supported.
82 virtual result SetAlgorithm(const Tizen::Base::String& algorithm);
85 * Gets the hashes of the specified data (single-part).
89 * @return A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
90 * else @c null if an error occurs
91 * @param[in] input An instance of Tizen::Base::ByteBuffer
92 * @exception E_SUCCESS The method is successful.
93 * @exception E_INVALID_ARG The input Tizen::Base::ByteBuffer is empty or contains invalid data.
94 * @exception E_OUT_OF_MEMORY The memory is insufficient.
95 * @exception E_SYSTEM Either of the following conditions has occurred:
96 * - A system error has occurred.
97 * - The method has failed to operate with the OpenSSL library.
98 * - The Tizen::Base::ByteBuffer operation has failed.
99 * @remarks The specific error code can be accessed using the GetLastResult() method.
101 virtual Tizen::Base::ByteBuffer* GetHashN(const Tizen::Base::ByteBuffer& input) const;
104 * Initializes the multiple-part hash operation.
108 * @return An error code
109 * @exception E_SUCCESS The method is successful.
110 * @exception E_OUT_OF_MEMORY The memory is insufficient.
111 * @exception E_SYSTEM A system error has occurred. @n
112 * The method has failed to operate with the OpenSSL library.
114 virtual result Initialize(void);
117 * Updates the multiple-part hash operation while processing another data part.
121 * @return An error code
122 * @param[in] input An instance of Tizen::Base::ByteBuffer
123 * @exception E_SUCCESS The method is successful.
124 * @exception E_INVALID_ARG The input Tizen::Base::ByteBuffer is empty or contains invalid data.
125 * @exception E_OUT_OF_MEMORY The memory is insufficient.
126 * @exception E_SYSTEM Either of the following conditions has occurred:
127 * - A system error has occurred.
128 * - The method has failed to operate with the OpenSSL library.
129 * - The Tizen::Base::ByteBuffer operation has failed.
131 virtual result Update(const Tizen::Base::ByteBuffer& input);
134 * Finalizes the multiple-part hash operation.
138 * @return A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
139 * else @c null if an error occurs
140 * @exception E_SUCCESS The method is successful.
141 * @exception E_OUT_OF_MEMORY The memory is insufficient.
142 * @exception E_SYSTEM Either of the following conditions has occurred:
143 * - A system error has occurred.
144 * - The method has failed to operate with the OpenSSL library.
145 * - The Tizen::Base::ByteBuffer operation has failed.
146 * @remarks The specific error code can be accessed using the GetLastResult() method.
148 virtual Tizen::Base::ByteBuffer* FinalizeN(void);
153 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
157 Sha1Hash(const Sha1Hash& rhs);
160 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
164 Sha1Hash& operator =(const Sha1Hash& rhs);
167 env_md_ctx_st* __pEvpMdCtx;
169 class _Sha1HashImpl* __pSha1HashImpl;
170 friend class _Sha1HashImpl;
174 } } } //Tizen::Security::Crypto
176 #endif //_FSEC_CRYPTO_SHA1_HASH_H_