2 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FSecPkcsPkcs05PbMacParameters.h
19 * @brief This is the header file for the %Pkcs05PbMacParameters class.
21 * This header file contains the declarations of the %Pkcs05PbMacParameters class.
24 #ifndef _FSEC_PKCS_PKCS_05_PBMAC_PARAMETERS_H_
25 #define _FSEC_PKCS_PKCS_05_PBMAC_PARAMETERS_H_
27 #include <FBaseByteBuffer.h>
28 #include <FSecPkcsIAlgorithmParameters.h>
29 #include <FSecPkcsAlgorithmIdentifier.h>
30 #include <FSecPkcsTypes.h>
32 namespace Tizen { namespace Security { namespace Pkcs
36 * @class Pkcs05PbMacParameters
37 * @brief This class provides methods for the functionalities specified by the PKCS05 MAC scheme.
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
46 * This is defined in ASN.1 as demonstrated in the following code:
48 * PBMAC1-params ::= SEQUENCE {
49 * keyDerivationFunc AlgorithmIdentifier {{PBMAC1-KDFs}},
50 * messageAuthScheme AlgorithmIdentifier {{PBMAC1-MACs}} }
55 class _OSP_EXPORT_ Pkcs05PbMacParameters
56 : public virtual IAlgorithmParameters
57 , public Tizen::Base::Object
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.
67 Pkcs05PbMacParameters(void);
70 * This destructor overrides Tizen::Base::Object::~Object().
74 virtual ~Pkcs05PbMacParameters(void);
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.
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.
87 result Construct(const Tizen::Base::ByteBuffer& encodedData);
90 * Initializes this %Pkcs05PbMacParameters with specified input parameter values.
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.
100 result Construct(const AlgorithmIdentifier& keyDerivationFunc, const AlgorithmIdentifier& messageAuthScheme);
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.
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.
114 Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
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.
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.
125 const AlgorithmIdentifier& GetKeyDerivationAlgorithm(void) const;
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.
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.
136 const AlgorithmIdentifier& GetMacAlgorithm(void) const;
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.
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.
147 virtual IAlgorithmParameters* CloneN(void) const;
150 * Gets the PkcsAlgorithmParameterType value.
154 * @return An instance of PkcsAlgorithmParameterType holding the enum value @c PKCS_ALGO_PARAM_TYPE_PKCS05_MAC for PBMAC parameters
156 virtual PkcsAlgorithmParameterType GetType(void) const;
159 * Checks whether the specified instance of %Pkcs05PbMacParameters equals the current instance.
163 * @return @c true if the specified instance equals the current instance, @n
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.
170 virtual bool Equals(const Tizen::Base::Object& rhs) const;
173 * Gets the hash value of the current instance of %Pkcs05PbMacParameters.
177 * @return An integer value indicating the hash value of the current instance of %Pkcs05PbMacParameters
179 virtual int GetHashCode(void) const;
182 // This copy constructor is intentionally declared as private to prohibit @n
183 // copying of objects by users.
186 Pkcs05PbMacParameters(const Pkcs05PbMacParameters& rhs);
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.
193 Pkcs05PbMacParameters& operator =(const Pkcs05PbMacParameters& rhs);
196 class _Pkcs05PbMacParametersImpl* __pPkcs05PbMacParametersImpl;
197 friend class _Pkcs05PbMacParametersImpl;
199 }; // Pkcs05PbMacParameters
201 } } } // Tizen::Security::Pkcs
203 #endif //_FSEC_PKCS_PKCS_05_PBMAC_PARAMETERS_H_