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.
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.
48 * This is defined in ASN.1 as demonstrated in the following code:
50 * PBMAC1-params ::= SEQUENCE {
51 * keyDerivationFunc AlgorithmIdentifier {{PBMAC1-KDFs}},
52 * messageAuthScheme AlgorithmIdentifier {{PBMAC1-MACs}} }
57 class _OSP_EXPORT_ Pkcs05PbMacParameters
58 : public virtual IAlgorithmParameters
59 , public Tizen::Base::Object
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.
69 Pkcs05PbMacParameters(void);
72 * This destructor overrides Tizen::Base::Object::~Object().
76 virtual ~Pkcs05PbMacParameters(void);
79 * Initializes this instance of %Pkcs05PbMacParameters with the Tizen::Base::ByteBuffer instance that contains Password Based Message @n
80 * Authentication Cyrptography parameters structure(PBMAC1) in ASN.1 DER format.
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.
89 result Construct(const Tizen::Base::ByteBuffer& encodedData);
92 * Initializes this %Pkcs05PbMacParameters with specified input parameter values.
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.
102 result Construct(const AlgorithmIdentifier& keyDerivationFunc, const AlgorithmIdentifier& messageAuthScheme);
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.
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.
116 Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
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.
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.
127 const AlgorithmIdentifier& GetKeyDerivationAlgorithm(void) const;
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.
135 * @return A reference to AlgorithmIdentifier holding the underlying MAC algorithm
136 * @remarks The specific error code can be accessed using the GetLastResult() method.
138 const AlgorithmIdentifier& GetMacAlgorithm(void) const;
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.
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.
149 virtual IAlgorithmParameters* CloneN(void) const;
152 * Get the PkcsAlgorithmParameterType value.
156 * @return PkcsAlgorithmParameterType holding enum value @c PKCS_ALGO_PARAM_TYPE_PKCS05_MAC for PBMAC parameters
158 virtual PkcsAlgorithmParameterType GetType(void) const;
161 * Checks whether the specified instance of %Pkcs05PbMacParameters equals the current instance.
165 * @return @c true if the specified instance equals the current instance, @n
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.
172 virtual bool Equals(const Tizen::Base::Object& rhs) const;
175 * Gets the hash value of the current instance of %Pkcs05PbMacParameters.
179 * @return An integer value indicating the hash value of the current instance of %Pkcs05PbMacParameters
181 virtual int GetHashCode(void) const;
184 // This copy constructor is intentionally declared as private to prohibit @n
185 // copying of objects by users.
188 Pkcs05PbMacParameters(const Pkcs05PbMacParameters& rhs);
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.
195 Pkcs05PbMacParameters& operator =(const Pkcs05PbMacParameters& rhs);
198 class _Pkcs05PbMacParametersImpl* __pPkcs05PbMacParametersImpl;
199 friend class _Pkcs05PbMacParametersImpl;
201 }; // Pkcs05PbMacParameters
203 } } } // Tizen::Security::Pkcs
205 #endif //_FSEC_PKCS_PKCS_05_PBMAC_PARAMETERS_H_