Fix the boiler plate codes
[platform/framework/native/appfw.git] / inc / FSecCryptoSha2Hash.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 //
16
17 /**
18  *      @file           FSecCryptoSha2Hash.h
19  *      @brief          This is the header file for the %Sha2Hash class.
20  *
21  *      This header file contains the declarations of the %Sha2Hash class.
22  */
23 #ifndef _FSEC_CRYPTO_SHA2_HASH_H_
24 #define _FSEC_CRYPTO_SHA2_HASH_H_
25
26 #include <FSecCryptoIHash.h>
27
28 struct env_md_st;
29 struct env_md_ctx_st;
30
31 namespace Tizen { namespace Security { namespace Crypto
32 {
33
34 /**
35  *      @class  Sha2Hash
36  *      @brief  This class implements the SHA-2 hash algorithm.
37  *
38  *      @since  2.0
39  *
40  *      The %Sha2Hash class implements the SHA-2 hash algorithm. @n
41  *
42  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/security/hashing.htm">Hashing</a>.
43  *
44  *      @see            Tizen::Security::Crypto::IHash
45  *      @see            Tizen::Security::Crypto::Md5Hash
46  *      @see            Tizen::Security::Crypto::Sha1Hash
47  */
48 class _OSP_EXPORT_ Sha2Hash
49         : public virtual IHash
50         , public Tizen::Base::Object
51 {
52
53 public:
54         /**
55          *      This is the default constructor for this class.
56          *
57          *      @since          2.0
58          */
59         Sha2Hash(void);
60
61         /**
62          * This destructor overrides Tizen::Base::Object::~Object().
63          *
64          *      @since          2.0
65          */
66         virtual ~Sha2Hash(void);
67
68         /**
69          *      Sets the hash algorithm.
70          *
71          *      @since          2.0
72          *
73          *      @return         An error code
74          *      @param[in]      algorithm                               The name of the hash algorithm @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.
78          */
79         virtual result SetAlgorithm(const Tizen::Base::String& algorithm);
80
81         /**
82          *      Gets the hashes of the data (single-part).
83          *
84          *      @since          2.0
85          *
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                                A system error has occurred. @n
93          *                                                                              The method has failed to operate with the OpenSSL library, or
94          *                                                                              the Tizen::Base::ByteBuffer operation has failed.
95          *      @remarks        The specific error code can be accessed using the GetLastResult() method.
96          */
97         virtual Tizen::Base::ByteBuffer* GetHashN(const Tizen::Base::ByteBuffer& input) const;
98
99         /**
100          *      Initializes a multiple-part hash operation.
101          *
102          *      @since          2.0
103          *
104          *      @return         An error code
105          *      @exception      E_SUCCESS                               The method is successful.
106          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
107          *      @exception      E_SYSTEM                                A system error has occurred. @n
108          *                                                                              The method has failed to operate with the OpenSSL library.
109          */
110         virtual result Initialize(void);
111
112         /**
113          *      Updates a multiple-part hash operation while processing another data part.
114          *
115          *      @since          2.0
116          *
117          *      @return         An error code
118          *      @param[in]      input                                   An instance of Tizen::Base::ByteBuffer
119          *      @exception      E_SUCCESS                               The method is successful.
120          *      @exception      E_INVALID_ARG                   The input Tizen::Base::ByteBuffer is empty or contains invalid data.
121          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
122          *      @exception      E_SYSTEM                                A system error has occurred. @n
123          *                                                                              The method has failed to operate with the OpenSSL library, or
124          *                                                                              the Tizen::Base::ByteBuffer operation has failed.
125          */
126         virtual result Update(const Tizen::Base::ByteBuffer& input);
127
128         /**
129          *      Finalizes a multiple-part hash operation.
130          *
131          *      @since          2.0
132          *
133          *      @return         A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
134          *                              else @c null if an error occurs
135          *      @exception      E_SUCCESS                               The method is successful.
136          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
137          *      @exception      E_SYSTEM                                A system error has occurred. @n
138          *                                                                              The method has failed to operate with the OpenSSL library, or
139          *                                                                              the Tizen::Base::ByteBuffer operation has failed.
140          *      @remarks        The specific error code can be accessed using the GetLastResult() method.
141          */
142         virtual Tizen::Base::ByteBuffer* FinalizeN(void);
143
144 private:
145
146         //
147         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
148         //
149         // @since 2.0
150         //
151         Sha2Hash(const Sha2Hash& rhs);
152
153         //
154         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
155         //
156         // @since 2.0
157         //
158         Sha2Hash& operator =(const Sha2Hash& rhs);
159
160 private:
161         const env_md_st* __pAlgorithm;
162         env_md_ctx_st* __pEvpMdCtx;
163
164         class _Sha2HashImpl* __pSha2HashImpl;
165         friend class _Sha2HashImpl;
166
167 }; //Sha2Hash
168
169 } } } //Tizen::Security:Crypto
170
171 #endif //_FSEC_CRYPTO_SHA2_HASH_H_