fixed wrong link
[platform/framework/native/appfw.git] / inc / FSecPkcsPkcs05Schemes.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2013 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                FSecPkcsPkcs05Schemes.h
20  * @brief               This is the header file for the %Pkcs05Schemes class.
21  *
22  * This header file contains the declarations of the %Pkcs05Schemes class.
23  */
24
25 #ifndef _FSEC_PKCS_PKCS_05_SCHEMES_H_
26 #define _FSEC_PKCS_PKCS_05_SCHEMES_H_
27
28 #include <FBaseByteBuffer.h>
29 #include <FSecPkcsPkcs05PbKdf2Parameters.h>
30 #include <FSecPkcsPkcs05PbEs2Parameters.h>
31 #include <FSecPkcsPkcs05PbMacParameters.h>
32
33 namespace Tizen { namespace Security { namespace Pkcs
34 {
35
36 /**
37   * @class              Pkcs05Schemes
38   * @brief              This class implements the functionalities specified by the pkcs05 schemes like key derivation function,
39   *                                             encryption and signature schemes.
40   *
41   * @since              2.1
42   *
43   * The %Pkcs05Schemes class implements the functionalities specified by the pkcs05 schemes like key derivation function,
44   *                                             encryption and signature schemes.
45   */
46
47 class _OSP_EXPORT_ Pkcs05Schemes
48         : public Tizen::Base::Object
49 {
50 public:
51         /**
52          * The object is not fully constructed after this constructor is called. @n
53          * For full construction, the Construct() method must be called right after calling this constructor.
54          *
55          * @since       2.1
56          */
57         Pkcs05Schemes(void);
58
59         /**
60          * This destructor overrides Tizen::Base::Object::~Object().
61          *
62          * @since       2.1
63          */
64         virtual ~Pkcs05Schemes(void);
65
66         /**
67          * Initializes this instance of %Pkcs05Schemes with the values of the specified input parameters.
68          *
69          * @since               2.1
70          *
71          * @return              An error code
72          * @param[in]   password                                        An instance of Tizen::Base::ByteBuffer holding the password
73          * @param[in]   derivedKeyLength        A positive integer that contains the length of derived key @n
74          *                                                                                                                      It is a variable length in PbEs2 based on the underlying encryption operation.
75          * @exception   E_SUCCESS                                       The method is successful.
76          * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
77          */
78         result Construct(const Tizen::Base::ByteBuffer& password, int derivedKeyLength);
79
80         /**
81          * Generates the password based derived key using the PBKDF2 scheme. @n
82          * The length of the derived key is essentially unbounded. However, the maximum effective search space for
83          * the derived key may be limited by the structure of the underlying pseudo random function.
84          *
85          * @since               2.1
86          *
87          * @return              A pointer to Tizen::Base::ByteBuffer that contains the derived key, @n
88          *                              else @c null if an error occurs
89          * @param[in]   params                                          An instance of PbKdf2Parameters containing the Kdf2 parameter,
90          *                                                                                                                      salt value, iteration count, and key length
91          * @exception   E_SUCCESS                                       The method is successful.
92          * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
93          * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
94          * @remarks             The specific error code can be accessed using the GetLastResult() method.
95          */
96         Tizen::Base::ByteBuffer* GenerateKeyKdf2N(const Pkcs05PbKdf2Parameters& params);
97
98         /**
99          * Encrypts the message M under a password P to produce a ciphertext C, by applying selected key derivation function KDF
100          * (which is GenerateKeyKdf2N) and selected underlying encryption scheme (which can be any block chiper).
101          *
102          * @since               2.1
103          *
104          * @return              A pointer to Tizen::Base::ByteBuffer that contains the encrypted message, @n
105          *                              else @c null if an error occurs
106          * @param[in]   params                                          An instance of the PbEs2Parameters parameter structure holding AlgorithmIdentifier for key derivation
107          *                                                                                                                      function and AlgorithmIdentifier for underlying encryption scheme
108          * @param[in]   message                                         An instance of Tizen::Base::ByteBuffer holding the plain text to encrypt
109          * @exception   E_SUCCESS                                       The method is successful.
110          * @exception   E_INVALID_ARG                   A specified input parameter is invalid.
111          * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
112          * @remarks             The specific error code can be accessed using the GetLastResult() method.
113          */
114         Tizen::Base::ByteBuffer* EncryptionScheme2N(const Pkcs05PbEs2Parameters& params, const Tizen::Base::ByteBuffer& message);
115
116         /**
117          * Decrypts the ciphertext C, under a password P to recover message M , by applying selected key derivation function KDF(which is GenerateKeyKdf2N)
118          * and selected underlying decryption algorithm (which can be any block cipher).
119          *
120          * @since               2.1
121          *
122          * @return              A pointer to Tizen::Base::ByteBuffer that contains the plain text message
123          * @param[in]   params                                          An instance of the PbEs2Parameters parameter structure holding AlgorithmIdentifier for key derivation
124          *                                                                                                                      function and AlgorithmIdentifier for underlying encryption scheme
125          * @param[in]   message                                         An instance of Tizen::Base::ByteBuffer holding the cipher text to decrypt
126          * @exception   E_SUCCESS                                       The method is successful.
127          * @exception   E_INVALID_ARG                   A specified input parameter is invalid.
128          * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
129          * @remarks             The specific error code can be accessed using the GetLastResult() method.
130          */
131         Tizen::Base::ByteBuffer* DecryptionScheme2N(const Pkcs05PbEs2Parameters& params, const Tizen::Base::ByteBuffer& message);
132
133         /**
134          * Gets a message M under a password P to generate a message authentication code T,
135          * by applying selected key derivation function KDF(which is GenerateKeyKdf2N) and selected underlying message authentication scheme
136          * (which can be any HMAC algorithm). @n GenerateMacN combines a password-based key derivation function, which shall be
137          * GenerateKeyKdf2N for this version of PKCS #5, with an underlying message authentication scheme
138          * The key length and any other parameters for the underlying message authentication scheme
139          * depend on the scheme.
140          *
141          * @since               2.1
142          *
143          * @return              A pointer to Tizen::Base::ByteBuffer containing the HMAC generated from message, @n
144          *                              else @c null if an error occurs
145          * @param[in]   params                                          An instance of the PbMacParameters parameter structure holding AlgorithmIdentifier for key derivation
146          *                                                                                                                      function and AlgorithmIdentifier for underlying encryption scheme
147          * @param[in]   message                                         An instance of Tizen::Base::ByteBuffer holding the message for which MAC needs to generate
148          * @exception   E_SUCCESS                                       The method is successful.
149          * @exception   E_INVALID_ARG                   A specified input parameter is invalid.
150          * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
151          * @remarks             The specific error code can be accessed using the GetLastResult() method.
152          */
153         Tizen::Base::ByteBuffer* GetPbHMacN(const Pkcs05PbMacParameters& params, const Tizen::Base::ByteBuffer& message);
154
155         /**
156          * Verifies a message M under a password P to verify a message authentication code T,
157          * by applying a selected key derivation function KDF2 and a selected underlying message authentication scheme combines a
158          * password-based key derivation function, which shall be GenerateKeyKdf2N for this version of PKCS #5, with an underlying
159          * message authentication scheme (which can be any SHA-1 or any SHA-2 algorithm). @n The key length and any other parameters
160          * for the underlying message authentication scheme depend on the scheme.
161          *
162          * @since               2.1
163          *
164          * @return              An error code
165          * @param[in]   params                                                  An instance of the PbMacParameters parameter structure holding AlgorithmIdentifier for key derivation
166          *                                                                                                                              function and AlgorithmIdentifier for underlying encryption scheme
167          * @param[in]   message                                                 An instance of Tizen::Base::ByteBuffer holding the message M
168          * @param[in]   mac                                                                     An instance of Tizen::Base::ByteBuffer holding the HMAC mac that needs to verify against the message
169          * @exception   E_SUCCESS                                               The method is successful.
170          * @exception   E_INVALID_ARG                           A specified input parameter is invalid.
171          * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
172          * @remarks             The specific error code can be accessed using the GetLastResult() method.
173          */
174         result VerifyPbMac(const Pkcs05PbMacParameters& params, const Tizen::Base::ByteBuffer& message, const Tizen::Base::ByteBuffer& mac);
175
176 private:
177         // This copy constructor is intentionally declared as private to prohibit @n
178         // copying of objects by users.
179         //
180         // @since               2.1
181         Pkcs05Schemes(const Pkcs05Schemes& rhs);
182
183         // The implementation of this copy assignment operator is intentionally blank and @n
184         // declared as private to prohibit copying of objects.
185         //
186         // @since               2.1
187         Pkcs05Schemes& operator =(const Pkcs05Schemes& rhs);
188
189 private:
190         class _Pkcs05SchemesImpl* __pPkcs05SchemesImpl;
191         friend class _Pkcs05SchemesImpl;
192
193 }; //Pkcs05Schemes
194
195 } } } // Tizen::Security::Pkcs
196
197 #endif //_FSEC_PKCS_PKCS_05_SCHEMES_H_