2 // Open Service Platform
3 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FSecPkcsPkcs05PbMacParameters.h
20 * @brief This is the header file for the %Pkcs05PbMacParameters class.
22 * This header file contains the declarations of the %Pkcs05PbMacParameters class.
25 #ifndef _FSEC_PKCS_PKCS_05_PBMAC_PARAMETERS_H_
26 #define _FSEC_PKCS_PKCS_05_PBMAC_PARAMETERS_H_
28 #include <FBaseByteBuffer.h>
29 #include <FSecPkcsIAlgorithmParameters.h>
30 #include <FSecPkcsAlgorithmIdentifier.h>
31 #include <FSecPkcsTypes.h>
33 namespace Tizen { namespace Security { namespace Pkcs
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.
44 * It is defined in ASN.1 as:
46 * PBMAC1-params ::= SEQUENCE {
47 * keyDerivationFunc AlgorithmIdentifier {{PBMAC1-KDFs}},
48 * messageAuthScheme AlgorithmIdentifier {{PBMAC1-MACs}} }
53 class _OSP_EXPORT_ Pkcs05PbMacParameters
54 : public virtual IAlgorithmParameters
55 , public Tizen::Base::Object
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.
65 Pkcs05PbMacParameters(void);
68 * This destructor overrides Tizen::Base::Object::~Object().
72 virtual ~Pkcs05PbMacParameters(void);
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.
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.
85 result Construct(const Tizen::Base::ByteBuffer& encodedData);
88 * Initializes the %Pkcs05PbMacParameters with supplied input parameters values.
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.
98 result Construct(const AlgorithmIdentifier& keyDerivationFunc, const AlgorithmIdentifier& messageAuthScheme);
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.
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.
112 Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
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.
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.
123 const AlgorithmIdentifier& GetKeyDerivationAlgorithm(void) const;
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.
131 * @return A reference to AlgorithmIdentifier holding the underlying MAC algorithm.
132 * @remarks The specific error code can be accessed using the GetLastResult() method.
134 const AlgorithmIdentifier& GetMacAlgorithm(void) const;
137 * Get the AlgorithmParameters which identifies the underlying Parameters like PbKdf2,PbEs2,PbMac1.
138 * For this class AlgorithmParameters will be of PbMac1 type.
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.
145 virtual IAlgorithmParameters* CloneN(void) const;
148 * Get the PkcsAlgorithmParameterType value.
152 * @return PkcsAlgorithmParameterType holding enum value PKCS_ALGO_PARAM_TYPE_PKCS05_MAC for PBMAC Parameters.
154 virtual PkcsAlgorithmParameterType GetType(void) const;
157 * Checks whether the specified instance of %Pkcs05PbMacParameters equals the current instance.
161 * @return @c true if the specified instance equals the current instance, @n
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.
168 virtual bool Equals(const Tizen::Base::Object& rhs) const;
171 * Gets the hash value of the current instance of %Pkcs05PbMacParameters.
175 * @return An integer value indicating the hash value of the current instance of %Pkcs05PbMacParameters
177 virtual int GetHashCode(void) const;
180 // This copy constructor is intentionally declared as private to prohibit @n
181 // copying of objects by users.
184 Pkcs05PbMacParameters(const Pkcs05PbMacParameters& rhs);
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.
191 Pkcs05PbMacParameters& operator =(const Pkcs05PbMacParameters& rhs);
194 class _Pkcs05PbMacParametersImpl* __pPkcs05PbMacParametersImpl;
195 friend class _Pkcs05PbMacParametersImpl;
197 }; // Pkcs05PbMacParameters
199 } } } // Tizen::Security::Pkcs
201 #endif //_FSEC_PKCS_PKCS_05_PBMAC_PARAMETERS_H_