Merge "Update deprecated libprivilege-control API functions." into tizen
[platform/framework/native/appfw.git] / inc / FSecPkcsPkcs05PbEs2Parameters.h
1 //
2 // Copyright (c) 2013 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                FSecPkcsPkcs05PbEs2Parameters.h
19  * @brief               This is the header file for the %Pkcs05PbEs2Parameters class.
20  *
21  * This header file contains the declarations of the %Pkcs05PbEs2Parameters class.
22  */
23
24 #ifndef _FSEC_PKCS_PKCS_05_PBES2_PARAMETERS_H_
25 #define _FSEC_PKCS_PKCS_05_PBES2_PARAMETERS_H_
26
27
28 #include <FBaseByteBuffer.h>
29 #include <FSecPkcsIAlgorithmParameters.h>
30 #include <FSecPkcsAlgorithmIdentifier.h>
31 #include <FSecPkcsTypes.h>
32
33 namespace Tizen { namespace Security { namespace Pkcs
34 {
35
36 /**
37  * @class               Pkcs05PbEs2Parameters
38  * @brief               This class provides methods for the functionalities specified by the PKCS05 encryption scheme 2.
39  *
40  * @since               2.1
41  *
42  * The %Pkcs05PbEs2Parameters class implements the functionalities specified by the PKCS05 encryption scheme 2.
43  * PBES2 combines a password-based key derivation function, which is PBKDF2 for PKCS #5 version 2.1, with an underlying 
44  * encryption scheme. The key length and any other parameters for the underlying encryption scheme depends on the scheme.
45  *
46  * This is defined in ASN.1 as demonstrated in the following code:
47  * @code
48  *              PBES2-params ::= SEQUENCE {
49  *              keyDerivationFunc AlgorithmIdentifier {{PBES2-KDFs}},
50  *              encryptionScheme AlgorithmIdentifier {{PBES2-Encs}} }
51  * @endcode
52  *
53  */
54
55 class _OSP_EXPORT_ Pkcs05PbEs2Parameters
56         : public virtual IAlgorithmParameters
57         , public Tizen::Base::Object
58 {
59
60
61 public:
62         /**
63          * The object is not fully constructed after this constructor is called. @n
64          * For full construction, the Construct() method must be called right after calling this constructor.
65          *
66          * @since               2.1
67          */
68         Pkcs05PbEs2Parameters(void);
69
70         /**
71          * This destructor overrides Tizen::Base::Object::~Object().
72          *
73          * @since               2.1
74          */
75         virtual ~Pkcs05PbEs2Parameters(void);
76
77         /**
78          * Initializes this instance of %Pkcs05PbEs2Parameters with the specified encoded Tizen::Base::ByteBuffer, which contains 
79          * Password Based Encryption Parameters Structure(PBES2) in ASN.1 DER format.
80          *
81          * @since               2.1
82          *
83          * @return              An error code
84          * @param[in]   encodedData                             The DER encoded Tizen::Base::ByteBuffer containing %Pkcs05PbEs2Parameters
85          * @exception   E_SUCCESS                               The method is successful.
86          * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
87          */
88         result Construct(const Tizen::Base::ByteBuffer& encodedData);
89
90         /**
91          * Initializes this %Pkcs05PbEs2Parameters with the specified input parameters values.
92          *
93          * @since               2.1
94          *
95          * @return              An error code
96          * @param[in]   keyDerivationFunction           An instance of AlgorithmIdentifier holding key derivation function
97          * @param[in]   encryptionScheme                        An instance of AlgorithmIdentifier holding encryption scheme
98          * @exception   E_SUCCESS                                       The method is successful.
99          * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
100          */
101         result Construct(const AlgorithmIdentifier& keyDerivationFunction, const AlgorithmIdentifier& encryptionScheme);
102
103         /**
104          * Gets the encoded form of the %Pkcs05PbEs2Parameters. @n
105          * It is assumed that each %Pkcs05PbEs2Parameters will have only a single form of encoding example ASN.1 DER.
106          *
107          * @since               2.1
108          *
109          * @return              A pointer to the Tizen::Base::ByteBuffer instance that contains the output, @n
110          *                              else @c null if an error occurs
111          * @exception   E_SUCCESS                                       The method is successful.
112          * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
113          * @remarks             The specific error code can be accessed using the GetLastResult() method.
114          */
115         Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
116
117         /**
118          * Gets a reference to the AlgorithmIdentifier instance, which identifies the underlying key derivation function. @n
119          * It will be an algorithm ID with an OID in the set PBES2-KDFs, which will consist of id-PBKDF2 for this version of PKCS #5.
120          *
121          * @since               2.1
122          *
123          * @return              A reference to the AlgorithmIdentifier instance holding the underlying key derivation function
124          * @remarks             The specific error code can be accessed using the GetLastResult() method.
125          */
126         const AlgorithmIdentifier& GetKeyDerivationAlgorithm(void) const;
127
128         /**
129          * Gets a reference to the AlgorithmIdentifier instance, which identifies the underlying encryption algorithm. @n
130          * It shall be an OID in the set PBES2-Encs, whose definition is left to the application.
131          *
132          * @since               2.1
133          *
134          * @return              A reference to the AlgorithmIdentifier instance holding the underlying encryption algorithm
135          * @remarks             The specific error code can be accessed using the GetLastResult() method.
136          */
137         const AlgorithmIdentifier& GetEncryptionScheme(void) const;
138
139         /**
140          * Gets the AlgorithmParameters that identifies the underlying parameters such as PbKdf2, PbEs2, PbMac1. @n
141          * For this class, %AlgorithmParameters will be of PBES2 type.
142          *
143          * @since               2.1
144          *
145          * @return              A pointer to IAlgorithmParameters containing the algorithm identifier of underlying pseudo random function, @n
146          *                              else @c null if an error occurs
147          * @remarks             The specific error code can be accessed using the GetLastResult() method.
148          */
149         virtual IAlgorithmParameters* CloneN(void) const;
150
151         /**
152          *
153          * Gets the PkcsAlgorithmParameterType value.
154          *
155          * @since               2.1
156          *
157          * @return              The PkcsAlgorithmParameterType instance holding the enum value @c PKCS_ALGO_PARAM_TYPE_PKCS05_PBES02 for PBES2 Parameters
158          *
159          */
160         virtual PkcsAlgorithmParameterType GetType(void) const;
161
162         /**
163          * Checks whether the specified instance of %Pkcs05PbEs2Parameters equals the current instance.
164          *
165          * @since               2.1
166          *
167          * @return              @c true if the specified instance equals the current instance, @n
168          *              else @c false
169          * @param[in]   rhs                                             An instance of %Pkcs05PbEs2Parameters
170          * @exception   E_SUCCESS                               The method is successful.
171          * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
172          * @remarks             The specific error code can be accessed using the GetLastResult() method.
173          */
174         virtual bool Equals(const Tizen::Base::Object& rhs) const;
175
176         /**
177          * Gets the hash value of the current instance of %Pkcs05PbEs2Parameters.
178          *
179          * @since               2.1
180          *
181          * @return              An integer value indicating the hash value of the current instance of %Pkcs05PbEs2Parameters
182          */
183         virtual int GetHashCode(void) const;
184
185 private:
186         // This copy constructor is intentionally declared as private to prohibit @n
187         // copying of objects by users.
188         //
189         // @since               2.1
190         Pkcs05PbEs2Parameters(const Pkcs05PbEs2Parameters& rhs);
191
192         // The implementation of this copy assignment operator is intentionally blank and @n
193         // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
194         // Use Equals() to compare the contents of one instance with the other.
195         //
196         // @since               2.1
197         Pkcs05PbEs2Parameters& operator =(const Pkcs05PbEs2Parameters& rhs);
198
199 private:
200         class _Pkcs05PbEs2ParametersImpl* __pPkcs05PbEs2ParametersImpl;
201         friend class _Pkcs05PbEs2ParametersImpl;
202 };  //Pkcs05PbEs2Parameters
203
204 } } } // Tizen::Security::Pkcs
205
206 #endif // _FSEC_PKCS_PKCS_05_PBES2_PARAMETERS_H_