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 FSecCryptoSha1Hmac.h
19 * @brief This is the header file for the %Sha1Hmac class.
21 * This header file contains the declarations of the %Sha1Hmac class.
23 #ifndef _FSEC_CRYPTO_SHA1_HMAC_H_
24 #define _FSEC_CRYPTO_SHA1_HMAC_H_
26 #include <FSecCryptoIHmac.h>
31 namespace Tizen { namespace Security { namespace Crypto
36 * @brief This class implements the SHA-1 HMAC algorithm.
40 * The %Sha1Hmac class implements the SHA-1 HMAC 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_ Sha1Hmac
49 : public virtual IHmac
50 , public Tizen::Base::Object
55 * This is the default constructor for this class.
62 * This destructor overrides Tizen::Base::Object::~Object().
66 virtual ~Sha1Hmac(void);
69 * Sets the HMAC 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.
75 * @return An error code
76 * @param[in] algorithm The HMAC algorithm name @n
77 * For example, "HMACSHA2/224", "HMACSHA2/256", "HMACSHA2/384", or "HMACSHA2/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 * Sets the secret key.
89 * @return An error code
90 * @param[in] key An instance of ISecretKey
91 * @exception E_SUCCESS The method is successful.
92 * @exception E_INVALID_ARG The specified @c key is invalid.
93 * @exception E_OUT_OF_MEMORY The memory is insufficient.
95 virtual result SetKey(const Tizen::Security::ISecretKey& key);
98 * Gets the HMAC for the specified input.
102 * @return A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
103 * else @c null if an error occurs
104 * @param[in] input An instance of Tizen::Base::ByteBuffer
105 * @exception E_SUCCESS The method is successful.
106 * @exception E_INVALID_ARG The input Tizen::Base::ByteBuffer is empty or contains invalid data.
107 * @exception E_OUT_OF_MEMORY The memory is insufficient.
108 * @exception E_KEY_NOT_FOUND The specified key is not found.
109 * @exception E_SYSTEM Either of the following conditions has occurred:
110 * - A system error has occurred.
111 * - The method has failed to operate with the OpenSSL library.
112 * @remarks The specific error code can be accessed using the GetLastResult() method.
114 virtual Tizen::Base::ByteBuffer* GetHmacN(const Tizen::Base::ByteBuffer& input) const;
117 * Initializes the multiple-part HMAC operation.
121 * @return An error code
122 * @exception E_SUCCESS The method is successful.
123 * @exception E_OUT_OF_MEMORY The memory is insufficient.
124 * @exception E_KEY_NOT_FOUND The specified key is not found.
125 * @exception E_SYSTEM Either of the following conditions has occurred:
126 * - A system error has occurred.
127 * - The method has failed to operate with the OpenSSL library.
129 virtual result Initialize(void);
132 * Updates the 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 Either of the following conditions has occurred:
142 * - A system error has occurred.
143 * - The method has failed to operate with the OpenSSL library.
144 * - The Tizen::Base::ByteBuffer operation has failed.
146 virtual result Update(const Tizen::Base::ByteBuffer& input);
149 * Finalizes the multiple-part HMAC operation.
153 * @return A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
154 * else @c null if an error occurs
155 * @exception E_SUCCESS The method is successful.
156 * @exception E_OUT_OF_MEMORY The memory is insufficient.
157 * @exception E_SYSTEM Either of the following conditions has occurred:
158 * - A system error has occurred.
159 * - The method has failed to operate with the OpenSSL library.
160 * - The Tizen::Base::ByteBuffer operation has failed.
161 * @remarks The specific error code can be accessed using the GetLastResult() method.
163 virtual Tizen::Base::ByteBuffer* FinalizeN(void);
168 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
172 Sha1Hmac(const Sha1Hmac& rhs);
175 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
179 Sha1Hmac& operator =(const Sha1Hmac& rhs);
182 hmac_ctx_st* __pSha1HmacCtx;
183 Tizen::Base::ByteBuffer __keyBytes;
185 class _Sha1HmacImpl* __pSha1HmacImpl;
186 friend class _Sha1HmacImpl;
190 } } } //Tizen::Security::Crypto
192 #endif //_FSEC_CRYPTO_SHA1_HMAC_H_