2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FSecCryptoMd5Hmac.h
20 * @brief This is the header file for the %Md5Hmac class.
22 * This header file contains the declarations of the %Md5Hmac class.
24 #ifndef _FSEC_CRYPTO_MD5_HMAC_H_
25 #define _FSEC_CRYPTO_MD5_HMAC_H_
27 #include <FSecCryptoIHmac.h>
32 namespace Tizen { namespace Security { namespace Crypto
37 * @brief This class implements the MD5 HMAC algorithm.
41 * The %Md5Hmac class implements the basic hash procedure to encrypt messages using the Hash Message Authentication Code (HMAC) algorithm, which provides a hash with a secret key. @n
43 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/security/hashing.htm">Hashing</a>.
49 class _OSP_EXPORT_ Md5Hmac
50 : public virtual IHmac
51 , public Tizen::Base::Object
56 * This is the default constructor for this class.
63 * This destructor overrides Tizen::Base::Object::~Object().
67 virtual ~Md5Hmac(void);
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.
76 * @return An error code
77 * @param[in] algorithm The name of the HMAC algorithm @n
78 * For example, "HMACSHA2/224", "HMACSHA2/256", "HMACSHA2/386", 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.
83 virtual result SetAlgorithm(const Tizen::Base::String& algorithm);
86 * Sets the secret key.
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.
96 virtual result SetKey(const Tizen::Security::ISecretKey& key);
99 * Gets the HMAC with the specified input.
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 A system error has occurred. @n
111 * The method has failed to operate with the OpenSSL library, or
112 * the Tizen::Base::ByteBuffer operation has failed.
113 * @remarks The specific error code can be accessed using the GetLastResult() method.
115 virtual Tizen::Base::ByteBuffer* GetHmacN(const Tizen::Base::ByteBuffer& input) const;
118 * Initializes a multiple-part HMAC operation.
122 * @return An error code
123 * @exception E_SUCCESS The method is successful.
124 * @exception E_OUT_OF_MEMORY The memory is insufficient.
125 * @exception E_KEY_NOT_FOUND The specified key is not found.
126 * @exception E_SYSTEM A system error has occurred. @n
127 * The method has failed to operate with the OpenSSL library.
129 virtual result Initialize(void);
132 * Updates a multiple-part HMAC operation while processing another data part.
136 * @return An error code
137 * @param[in] input An instance of Tizen::Base::ByteBuffer
138 * @exception E_SUCCESS The method is successful.
139 * @exception E_INVALID_ARG The input Tizen::Base::ByteBuffer is empty or contains invalid data.
140 * @exception E_OUT_OF_MEMORY The memory is insufficient.
141 * @exception E_SYSTEM A system error has occurred. @n
142 * The method has failed to operate with the OpenSSL library, or
143 * the Tizen::Base::ByteBuffer operation has failed.
145 virtual result Update(const Tizen::Base::ByteBuffer& input);
148 * Finalizes a multiple-part HMAC operation.
152 * @return A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
153 * else @c null if an error occurs
154 * @exception E_SUCCESS The method is successful.
155 * @exception E_OUT_OF_MEMORY The memory is insufficient.
156 * @exception E_SYSTEM A system error has occurred. @n
157 * The method has failed to operate with the OpenSSL library, or
158 * the Tizen::Base::ByteBuffer operation has failed.
159 * @remarks The specific error code can be accessed using the GetLastResult() method.
161 virtual Tizen::Base::ByteBuffer* FinalizeN(void);
166 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
170 Md5Hmac(const Md5Hmac& rhs);
173 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
177 Md5Hmac& operator =(const Md5Hmac& rhs);
180 hmac_ctx_st* __pMd5HmacCtx;
181 Tizen::Base::ByteBuffer __keyBytes;
183 class _Md5HmacImpl* __pMd5HmacImpl;
184 friend class _Md5HmacImpl;
188 } } } //Tizen::Security::Crypto
190 #endif //_FSEC_CRYPTO_MD5_HMAC_H_