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