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