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 implements 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
43 * for this version of PKCS #5, with an underlying message authentication
44 * scheme. The key length and any other parameters for
45 * the underlying message authentication scheme depend on the scheme.
47 * This is defined in ASN.1 as demonstrated in the following code:
49 * PBMAC1-params ::= SEQUENCE {
50 * keyDerivationFunc AlgorithmIdentifier {{PBMAC1-KDFs}},
51 * messageAuthScheme AlgorithmIdentifier {{PBMAC1-MACs}} }
56 class _OSP_EXPORT_ Pkcs05PbMacParameters
57 : public virtual IAlgorithmParameters
58 , public Tizen::Base::Object
63 * The object is not fully constructed after this constructor is called. @n
64 * For full construction, the Construct() method must be called right after calling this constructor.
68 Pkcs05PbMacParameters(void);
71 * This destructor overrides Tizen::Base::Object::~Object().
75 virtual ~Pkcs05PbMacParameters(void);
78 * Initializes this instance of %Pkcs05PbMacParameters with the Tizen::Base::ByteBuffer instance that contains Password Based Message @n
79 * Authentication Cryptography parameters structure(PBMAC1) in ASN.1 DER format.
83 * @return An error code
84 * @param[in] encodedData DER encoded Tizen::Base::ByteBuffer contains %Pkcs05PbMacParameters.
85 * @exception E_SUCCESS The method is successful.
86 * @exception E_INVALID_ARG The specified input parameter is invalid.
88 result Construct(const Tizen::Base::ByteBuffer& encodedData);
91 * Initializes this %Pkcs05PbMacParameters with specified input parameter values.
95 * @return An error code
96 * @param[in] keyDerivationFunc An instance of AlgorithmIdentifier, holding key derivation function
97 * @param[in] messageAuthScheme An instance of AlgorithmIdentifier, holding message authentication scheme
98 * @exception E_SUCCESS The method is successful.
99 * @exception E_INVALID_ARG The specified input parameter is invalid.
101 result Construct(const AlgorithmIdentifier& keyDerivationFunc, const AlgorithmIdentifier& messageAuthScheme);
104 * Gets the encoded form of the %Pkcs05PbMacParameters. @n
105 * It is assumed that each %Pkcs05PbMacParameters will have only a single form of encoding, for example ASN.1 DER.
109 * @return A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
110 * else @c null if an error occurs.
111 * @exception E_SUCCESS The method is successful.
112 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
113 * @remarks The specific error code can be accessed using the GetLastResult() method.
115 Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
118 * Gets the reference to the AlgorithmIdentifier instance that identifies the underlying key derivation function. @n
119 * 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.
123 * @return A reference to AlgorithmIdentifier holding the underlying key derivation function.
124 * @remarks The specific error code can be accessed using the GetLastResult() method.
126 const AlgorithmIdentifier& GetKeyDerivationAlgorithm(void) const;
129 * Gets the algorithm identifier that identifies the underlying
130 * MAC algorithm. @n It shall be an OID like OID_HMAC_SHA1 or OID_HMAC_SHA2_224, and so on.
134 * @return A reference to AlgorithmIdentifier holding the underlying MAC algorithm
135 * @remarks The specific error code can be accessed using the GetLastResult() method.
137 const AlgorithmIdentifier& GetMacAlgorithm(void) const;
140 * Gets the AlgorithmParameters that identifies the underlying Parameters such as PbKdf2, PbEs2, PbMac1. @n
141 * For this class %AlgorithmParameters will be of PbMac1 type.
145 * @return A pointer to IAlgorithmParameters containing the algorithm identifier of underlying pseudo random function
146 * @remarks The specific error code can be accessed using the GetLastResult() method.
148 virtual IAlgorithmParameters* CloneN(void) const;
151 * Get the PkcsAlgorithmParameterType value.
155 * @return PkcsAlgorithmParameterType holding enum value @c PKCS_ALGO_PARAM_TYPE_PKCS05_MAC for PBMAC parameters
157 virtual PkcsAlgorithmParameterType GetType(void) const;
160 * Checks whether the specified instance of %Pkcs05PbMacParameters equals the current instance.
164 * @return @c true if the specified instance equals the current instance, @n
166 * @param[in] rhs An instance of %Pkcs05PbMacParameters
167 * @exception E_SUCCESS The method is successful.
168 * @exception E_INVALID_ARG The specified input parameter is invalid.
169 * @remarks The specific error code can be accessed using the GetLastResult() method.
171 virtual bool Equals(const Tizen::Base::Object& rhs) const;
174 * Gets the hash value of the current instance of %Pkcs05PbMacParameters.
178 * @return An integer value indicating the hash value of the current instance of %Pkcs05PbMacParameters
180 virtual int GetHashCode(void) const;
183 // This copy constructor is intentionally declared as private to prohibit @n
184 // copying of objects by users.
187 Pkcs05PbMacParameters(const Pkcs05PbMacParameters& rhs);
189 // The implementation of this copy assignment operator is intentionally blank and @n
190 // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
191 // Use Equals() to compare the contents of one instance with the other.
194 Pkcs05PbMacParameters& operator =(const Pkcs05PbMacParameters& rhs);
197 class _Pkcs05PbMacParametersImpl* __pPkcs05PbMacParametersImpl;
198 friend class _Pkcs05PbMacParametersImpl;
200 }; // Pkcs05PbMacParameters
202 } } } // Tizen::Security::Pkcs
204 #endif //_FSEC_PKCS_PKCS_05_PBMAC_PARAMETERS_H_