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