Flush app registry before releasing file lock
[platform/framework/native/appfw.git] / inc / FSecCryptoMd5Hash.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                FSecCryptoMd5Hash.h
19  * @brief               This is the header file for the %Md5Hash class.
20  *
21  * This header file contains the declarations of the %Md5Hash class.
22  */
23 #ifndef _FSEC_CRYPTO_MD5_HASH_H_
24 #define _FSEC_CRYPTO_MD5_HASH_H_
25
26 #include <FSecCryptoIHash.h>
27
28 struct env_md_ctx_st;
29
30
31 namespace Tizen { namespace Security { namespace Crypto
32 {
33
34 /**
35  *      @class          Md5Hash
36  *      @brief          This class implements the MD5 hash algorithm.
37  *
38  * @since               2.0
39  *
40  *      The %Md5Hash class implements the basic hash procedure to encrypt messages using the Message-Digest 5 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    IHash
45  *      @see    Sha1Hash
46  *      @see    Sha2Hash
47  */
48 class _OSP_EXPORT_ Md5Hash
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         Md5Hash(void);
60
61         /**
62          *      This destructor overrides Tizen::Base::Object::~Object().
63          *
64          *      @since          2.0
65          */
66         virtual ~Md5Hash(void);
67
68         /**
69          *      Sets the hash algorithm. @n
70          *      The %SetAlgorithm() method is not supported by this class. Do not call this method.
71          *      If this method is called, it returns @c E_UNSUPPORTED_ALGORITHM.
72          *
73          *      @since          2.0
74          *
75          *      @return         An error code
76          *      @param[in]      algorithm                                       The name of the hash algorithm @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.
81          */
82         virtual result SetAlgorithm(const Tizen::Base::String& algorithm);
83
84         /**
85          *      Gets the hashes of the data (single-part).
86          *
87          *      @since          2.0
88          *
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.
100          */
101         virtual Tizen::Base::ByteBuffer* GetHashN(const Tizen::Base::ByteBuffer& input) const;
102
103         /**
104          *      Initializes the multiple-part hash operation.
105          *
106          *      @since          2.0
107          *
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                                Either of the following conditions has occurred:
112          *                                                                              - A system error has occurred.
113          *                                                                              - The method has failed to operate with the openssl library.
114          */
115         virtual result Initialize(void);
116
117         /**
118          *      Updates the multiple-part hash operation while processing another data part.
119          *
120          *      @since          2.0
121          *
122          *      @return         An error code
123          *      @param[in]      input                                   An instance of Tizen::Base::ByteBuffer
124          *      @exception      E_SUCCESS                               The method is successful.
125          *      @exception      E_INVALID_ARG                   The input Tizen::Base::ByteBuffer is empty or contains invalid data.
126          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
127          *      @exception      E_SYSTEM                                Either of the following conditions has occurred:
128          *                                                                              - A system error has occurred.
129          *                                                                              - The method has failed to operate with the OpenSSL library.
130          *                                                                              - The Tizen::Base::ByteBuffer operation has failed.
131          */
132         virtual result Update(const Tizen::Base::ByteBuffer& input);
133
134         /**
135          *      Finalizes the multiple-part hash operation.
136          *
137          *      @since          2.0
138          *
139          *      @return         A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
140          *                              else @c null if an error occurs
141          *      @exception      E_SUCCESS                               The method is successful.
142          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
143          *      @exception      E_SYSTEM                                Either of the following conditions has occurred:
144          *                                                                              - A system error has occurred.
145          *                                                                              - The method has failed to operate with the OpenSSL library.
146          *                                                                              - The Tizen::Base::ByteBuffer operation has failed.
147          *      @remarks        The specific error code can be accessed using the GetLastResult() method.
148          */
149         virtual Tizen::Base::ByteBuffer* FinalizeN(void);
150
151 private:
152
153         //
154         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
155         //
156         // @since 2.0
157         //
158         Md5Hash(const Md5Hash& rhs);
159
160         //
161         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
162         //
163         // @since 2.0
164         //
165         Md5Hash& operator =(const Md5Hash& rhs);
166
167 private:
168         env_md_ctx_st* __pEvpMdCtx;
169
170         class _Md5HashImpl* __pMd5HashImpl;
171         friend class _Md5HashImpl;
172
173 }; //Md5Hash
174
175 } } } //Tizen::Security::Crypto
176
177 #endif //_FSEC_CRYPTO_MD5_HASH_H_