Add IPC sync result for SerialPort::Write()
[platform/framework/native/appfw.git] / inc / FSecCryptoMd5Hmac.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                FSecCryptoMd5Hmac.h
19  * @brief               This is the header file for the %Md5Hmac class.
20  *
21  * This header file contains the declarations of the %Md5Hmac class.
22  */
23 #ifndef _FSEC_CRYPTO_MD5_HMAC_H_
24 #define _FSEC_CRYPTO_MD5_HMAC_H_
25
26 #include <FSecCryptoIHmac.h>
27
28 struct hmac_ctx_st;
29
30
31 namespace Tizen { namespace Security { namespace Crypto
32 {
33
34 /**
35  *      @class          Md5Hmac
36  *      @brief          This class implements the MD5 HMAC algorithm.
37  *
38  *      @since          2.0
39  *
40  *  The %Md5Hmac class implements the basic hash procedure to encrypt messages using the Hash Message Authentication Code (HMAC) 
41  *  algorithm, which provides a hash with a secret key.
42  *
43  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/security/hashing.htm">Hashing</a>.
44  *
45  *      @see  IHmac
46  *  @see  Sha1Hmac
47  *  @see  Sha2Hmac
48  */
49 class _OSP_EXPORT_ Md5Hmac
50         : public virtual IHmac
51         , public Tizen::Base::Object
52 {
53
54 public:
55         /**
56          *      This is the default constructor for this class.
57          *
58          * @since               2.0
59          */
60         Md5Hmac(void);
61
62         /**
63          *      This destructor overrides Tizen::Base::Object::~Object().
64          *
65          *      @since          2.0
66          */
67         virtual ~Md5Hmac(void);
68
69         /**
70          *      Sets the HMAC algorithm. @n
71          *      The %SetAlgorithm() method is not supported by this class. Do not call this method.
72          *      If this method is called, it returns @c E_UNSUPPORTED_ALGORITHM.
73          *
74          *      @since          2.0
75          *
76          *      @return         An error code
77          *      @param[in]      algorithm                                       The HMAC algorithm name @n
78          *                                                                                      For example, "HMACSHA2/224", "HMACSHA2/256", "HMACSHA2/384", or "HMACSHA2/512".
79          *      @exception      E_SUCCESS                                       The method is successful.
80          *      @exception      E_UNSUPPORTED_ALGORITHM         The algorithm is not supported.
81          *      @remarks        Do not call this method. It is not supported.
82          */
83         virtual result SetAlgorithm(const Tizen::Base::String& algorithm);
84
85         /**
86          *      Sets the secret key.
87          *
88          *      @since          2.0
89          *
90          *      @return         An error code
91          *      @param[in]      key                                             An instance of ISecretKey
92          *      @exception      E_SUCCESS                               The method is successful.
93          *      @exception      E_INVALID_ARG                   The specified key is invalid.
94          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
95          */
96         virtual result SetKey(const Tizen::Security::ISecretKey& key);
97
98         /**
99          *      Gets the HMAC for the specified input.
100          *
101          *      @since          2.0
102          *
103          *      @return         A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
104          *                              else @c null if an error occurs
105          *      @param[in]      input                                   An instance of Tizen::Base::ByteBuffer
106          *      @exception      E_SUCCESS                               The method is successful.
107          *      @exception      E_INVALID_ARG                   The input Tizen::Base::ByteBuffer is empty or contains invalid data.
108          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
109          *      @exception      E_KEY_NOT_FOUND                 The specified key is not found.
110          *      @exception      E_SYSTEM                                Either of the following conditions has occurred:
111          *                                                                              - A system error has occurred.
112          *                                                                              - The method has failed to operate with the OpenSSL library.
113          *                                                                              - The Tizen::Base::ByteBuffer operation has failed.
114          *      @remarks        The specific error code can be accessed using the GetLastResult() method.
115          */
116         virtual Tizen::Base::ByteBuffer* GetHmacN(const Tizen::Base::ByteBuffer& input) const;
117
118         /**
119          *      Initializes the multiple-part HMAC operation.
120          *
121          *      @since          2.0
122          *
123          *      @return         An error code
124          *      @exception      E_SUCCESS                               The method is successful.
125          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
126          *      @exception      E_KEY_NOT_FOUND                 The specified key is not found.
127          *      @exception      E_SYSTEM                                A system error has occurred. @n
128          *                                                                              The method has failed to operate with the OpenSSL library.
129          */
130         virtual result Initialize(void);
131
132         /**
133          *      Updates the multiple-part HMAC operation while processing another data part.
134          *
135          *      @since          2.0
136          *
137          *      @return         An error code
138          *      @param[in]      input                                   An instance of Tizen::Base::ByteBuffer
139          *      @exception      E_SUCCESS                               The method is successful.
140          *      @exception      E_INVALID_ARG                   The input Tizen::Base::ByteBuffer is empty or contains invalid data.
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          */
147         virtual result Update(const Tizen::Base::ByteBuffer& input);
148
149         /**
150          *      Finalizes a multiple-part HMAC operation.
151          *
152          *      @since          2.0
153          *
154          *      @return         A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
155          *                              else @c null if an error occurs
156          *      @exception      E_SUCCESS                               The method is successful.
157          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
158          *      @exception      E_SYSTEM                                Either of the following conditions has occurred:
159          *                                                                              - A system error has occurred.
160          *                                                                              - The method has failed to operate with the OpenSSL library.
161          *                                                                              - The Tizen::Base::ByteBuffer operation has failed.
162          *      @remarks        The specific error code can be accessed using the GetLastResult() method.
163          */
164         virtual Tizen::Base::ByteBuffer* FinalizeN(void);
165
166 private:
167
168         //
169         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
170         //
171         // @since 2.0
172         //
173         Md5Hmac(const Md5Hmac& rhs);
174
175         //
176         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
177         //
178         // @since 2.0
179         //
180         Md5Hmac& operator =(const Md5Hmac& rhs);
181
182 private:
183         hmac_ctx_st* __pMd5HmacCtx;
184         Tizen::Base::ByteBuffer __keyBytes;
185
186         class _Md5HmacImpl* __pMd5HmacImpl;
187         friend class _Md5HmacImpl;
188
189 }; //Md5Hmac
190
191 } } } //Tizen::Security::Crypto
192
193 #endif //_FSEC_CRYPTO_MD5_HMAC_H_