sync with tizen_2.0
[platform/framework/native/appfw.git] / inc / FSecCryptoSha1Hash.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  *      @file           FSecCryptoSha1Hash.h
20  *      @brief          This is the header file for the %Sha1Hash class.
21  *
22  *      This header file contains the declarations of the %Sha1Hash class.
23  */
24 #ifndef _FSEC_CRYPTO_SHA1_HASH_H_
25 #define _FSEC_CRYPTO_SHA1_HASH_H_
26
27 #include <FSecCryptoIHash.h>
28
29 struct env_md_ctx_st;
30
31
32 namespace Tizen { namespace Security { namespace Crypto
33 {
34
35 /**
36  *      @class          Sha1Hash
37  *      @brief          This class implements the SHA-1 hash algorithm.
38  *
39  *      @since          2.0
40  *
41  *      The %Sha1Hash class implements the SHA-1 hash algorithm. @n
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    IHash
46  *      @see    Md5Hash
47  *      @see    Sha2Hash
48  */
49 class _OSP_EXPORT_ Sha1Hash
50         : public virtual IHash
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         Sha1Hash(void);
61
62         /**
63          * This destructor overrides Tizen::Base::Object::~Object().
64          *
65          *      @since          2.0
66          */
67         virtual ~Sha1Hash(void);
68
69         /**
70          *      Sets the hash algorithm. @n
71          *      The %SetAlgorithm() method is not supported by this class. Do not call this method. @n
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 name of the hash algorithm @n
78          *                                                                              For example "SHA2/224", "SHA2/256", "SHA2/386", or "SHA2/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          *      Gets the hashes of a data (single-part).
87          *
88          *      @since          2.0
89          *
90          *      @return         A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
91          *                              else @c null if an error occurs
92          *      @param[in]      input                                   An instance of Tizen::Base::ByteBuffer
93          *      @exception      E_SUCCESS                               The method is successful.
94          *      @exception      E_INVALID_ARG                   The input Tizen::Base::ByteBuffer is empty or contains invalid data.
95          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
96          *      @exception      E_SYSTEM                                A system error has occurred. @n
97          *                                                                              The method has failed to operate with the OpenSSL library, or
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 a 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                                A system error has occurred. @n
112          *                                                                              The method has failed to operate with the OpenSSL library.
113          */
114         virtual result Initialize(void);
115
116         /**
117          *      Updates a multiple-part hash operation while processing another data part.
118          *
119          *      @since          2.0
120          *
121          *      @return         An error code
122          *      @param[in]      input                                   An instance of Tizen::Base::ByteBuffer
123          *      @exception      E_SUCCESS                               The method is successful.
124          *      @exception      E_INVALID_ARG                   The input Tizen::Base::ByteBuffer is empty or contains invalid data.
125          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
126          *      @exception      E_SYSTEM                                A system error has occurred. @n
127          *                                                                              The method has failed to operate with the OpenSSL library, or
128          *                                                                              the Tizen::Base::ByteBuffer operation has failed.
129          */
130         virtual result Update(const Tizen::Base::ByteBuffer& input);
131
132         /**
133          *      Finalizes a multiple-part hash operation.
134          *
135          *      @since          2.0
136          *
137          *      @return         A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
138          *                              else @c null if an error occurs
139          *      @exception      E_SUCCESS                               The method is successful.
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.
144          *      @remarks        The specific error code can be accessed using the GetLastResult() method.
145          */
146         virtual Tizen::Base::ByteBuffer* FinalizeN(void);
147
148 private:
149
150         //
151         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
152         //
153         // @since 2.0
154         //
155         Sha1Hash(const Sha1Hash& rhs);
156
157         //
158         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
159         //
160         // @since 2.0
161         //
162         Sha1Hash& operator =(const Sha1Hash& rhs);
163
164 private:
165         env_md_ctx_st* __pEvpMdCtx;
166
167         class _Sha1HashImpl* __pSha1HashImpl;
168         friend class _Sha1HashImpl;
169
170 }; //Sha1Hash
171
172 } } } //Tizen::Security::Crypto
173
174 #endif //_FSEC_CRYPTO_SHA1_HASH_H_