dc073cdd40000485e3fd6dfe16c112c617b53482
[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  *
40  * @since               2.1
41  *
42  * The %Pkcs05PbMacParameters class implements the functionalities specified by the PKCS05 MAC scheme.
43  *                                      PBMAC1 combines a password-based key derivation function, which will be PBKDF2
44  *                                      for this version of PKCS #5, with an underlying message authentication
45  *                                      scheme. The key length and any other parameters for
46  *                                      the underlying message authentication scheme depend on the scheme.
47  *
48  *                              This is defined in ASN.1 as demonstrated in the following code:
49  * @code
50  *                              PBMAC1-params ::= SEQUENCE {
51  *                              keyDerivationFunc AlgorithmIdentifier {{PBMAC1-KDFs}},
52  *                              messageAuthScheme AlgorithmIdentifier {{PBMAC1-MACs}} }
53  * @endcode
54  *
55  */
56
57 class _OSP_EXPORT_ Pkcs05PbMacParameters
58         : public virtual IAlgorithmParameters
59         , public Tizen::Base::Object
60 {
61
62 public:
63         /**
64          * The object is not fully constructed after this constructor is called. @n
65          * For full construction, the Construct() method must be called right after calling this constructor.
66          *
67          * @since                       2.1
68          */
69         Pkcs05PbMacParameters(void);
70
71         /**
72          * This destructor overrides Tizen::Base::Object::~Object().
73          *
74          * @since                       2.1
75          */
76         virtual ~Pkcs05PbMacParameters(void);
77
78         /**
79          * Initializes this instance of %Pkcs05PbMacParameters with the Tizen::Base::ByteBuffer instance that contains Password Based Message  @n
80          * Authentication Cryptography parameters structure(PBMAC1) in ASN.1 DER format.
81          *
82          * @since               2.1
83          *
84          * @return              An error code
85          * @param[in]   encodedData                             DER encoded Tizen::Base::ByteBuffer contains %Pkcs05PbMacParameters.
86          * @exception   E_SUCCESS                                       The method is successful.
87          * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
88          */
89         result Construct(const Tizen::Base::ByteBuffer& encodedData);
90
91         /**
92          * Initializes this %Pkcs05PbMacParameters with specified input parameter values.
93          *
94          * @since               2.1
95          *
96          * @return              An error code
97          * @param[in]   keyDerivationFunc               An instance of AlgorithmIdentifier, holding key derivation function
98          * @param[in]   messageAuthScheme               An instance of AlgorithmIdentifier, holding message authentication scheme
99          * @exception   E_SUCCESS                                               The method is successful.
100          * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
101          */
102         result Construct(const AlgorithmIdentifier& keyDerivationFunc, const AlgorithmIdentifier& messageAuthScheme);
103
104         /**
105          * Gets the encoded form of the %Pkcs05PbMacParameters. @n
106          * It is assumed that each %Pkcs05PbMacParameters will have only a single form of encoding, for example ASN.1 DER.
107          *
108          * @since               2.1
109          *
110          * @return              A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
111          *                                              else @c null if an error occurs.
112          * @exception   E_SUCCESS                               The method is successful.
113          * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
114          * @remarks             The specific error code can be accessed using the GetLastResult() method.
115          */
116         Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
117
118         /**
119          * Gets the reference to the AlgorithmIdentifier instance that identifies the underlying key derivation function. @n
120          * It will be an algorithm ID with an OID in the set PBES2-KDFs, which for this version of PKCS #5 will consist of ID-PBKDF2.
121          *
122          * @since               2.1
123          *
124          * @return              A reference to AlgorithmIdentifier holding the underlying key derivation function.
125          * @remarks             The specific error code can be accessed using the GetLastResult() method.
126          */
127         const AlgorithmIdentifier& GetKeyDerivationAlgorithm(void) const;
128
129         /**
130          * Gets the algorithm identifier that identifies the underlying
131          * MAC algorithm. @n It shall be an OID like OID_HMAC_SHA1 or OID_HMAC_SHA2_224, and so on.
132          *
133          * @since               2.1
134          *
135          * @return              A reference to AlgorithmIdentifier holding the underlying MAC algorithm
136          * @remarks             The specific error code can be accessed using the GetLastResult() method.
137          */
138         const AlgorithmIdentifier& GetMacAlgorithm(void) const;
139
140         /**
141          * Gets the AlgorithmParameters that identifies the underlying Parameters such as PbKdf2, PbEs2, PbMac1. @n
142          * For this class %AlgorithmParameters will be of PbMac1 type.
143          *
144          * @since               2.1
145          *
146          * @return              A pointer to IAlgorithmParameters containing the algorithm identifier of underlying pseudo random function
147          * @remarks             The specific error code can be accessed using the GetLastResult() method.
148          */
149         virtual IAlgorithmParameters* CloneN(void) const;
150
151         /**
152          * Get the PkcsAlgorithmParameterType value.
153          *
154          * @since               2.1
155          *
156          * @return              PkcsAlgorithmParameterType holding enum value @c PKCS_ALGO_PARAM_TYPE_PKCS05_MAC for PBMAC parameters
157          */
158         virtual PkcsAlgorithmParameterType GetType(void) const;
159
160         /**
161          * Checks whether the specified instance of %Pkcs05PbMacParameters 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 %Pkcs05PbMacParameters
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 %Pkcs05PbMacParameters.
176          *
177          * @since               2.1
178          *
179          * @return              An integer value indicating the hash value of the current instance of %Pkcs05PbMacParameters
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         Pkcs05PbMacParameters(const Pkcs05PbMacParameters& 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         Pkcs05PbMacParameters& operator =(const Pkcs05PbMacParameters& rhs);
196
197 private:
198         class _Pkcs05PbMacParametersImpl* __pPkcs05PbMacParametersImpl;
199         friend class _Pkcs05PbMacParametersImpl;
200
201 };  // Pkcs05PbMacParameters
202
203 } } } // Tizen::Security::Pkcs
204
205 #endif //_FSEC_PKCS_PKCS_05_PBMAC_PARAMETERS_H_