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 FSecPkcsPkcs05PbEs2Parameters.h
19 * @brief This is the header file for the %Pkcs05PbEs2Parameters class.
21 * This header file contains the declarations of the %Pkcs05PbEs2Parameters class.
24 #ifndef _FSEC_PKCS_PKCS_05_PBES2_PARAMETERS_H_
25 #define _FSEC_PKCS_PKCS_05_PBES2_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 Pkcs05PbEs2Parameters
38 * @brief This class implements the functionalities specified by the PKCS05 encryption scheme 2.
42 * The %Pkcs05PbEs2Parameters class implements the functionalities specified by the PKCS05 encryption scheme 2.
43 * PBES2 combines a password-based key derivation function, which is PBKDF2
44 * for PKCS #5 version 2.1, with an underlying encryption scheme.
45 * The key length and any other parameters for the underlying encryption scheme depends on the scheme.
47 * This is defined in ASN.1 as demonstrated in the following code:
49 * PBES2-params ::= SEQUENCE {
50 * keyDerivationFunc AlgorithmIdentifier {{PBES2-KDFs}},
51 * encryptionScheme AlgorithmIdentifier {{PBES2-Encs}} }
56 class _OSP_EXPORT_ Pkcs05PbEs2Parameters
57 : public virtual IAlgorithmParameters
58 , 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 Pkcs05PbEs2Parameters(void);
72 * This destructor overrides Tizen::Base::Object::~Object().
76 virtual ~Pkcs05PbEs2Parameters(void);
79 * Initializes this instance of %Pkcs05PbEs2Parameters with the encoded Tizen::Base::ByteBuffer, which contain Password Based Encryption Parameters Structure(PBES2) in ASN.1 DER format.
83 * @return An error code
84 * @param[in] encodedData The DER encoded Tizen::Base::ByteBuffer containing %Pkcs05PbEs2Parameters
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 %Pkcs05PbEs2Parameters with specified input parameters values.
95 * @return An error code
96 * @param[in] keyDerivationFunction An instance of AlgorithmIdentifier, holding key derivation function
97 * @param[in] encryptionScheme An instance of AlgorithmIdentifier, holding encryption 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& keyDerivationFunction, const AlgorithmIdentifier& encryptionScheme);
104 * Gets the encoded form of the %Pkcs05PbEs2Parameters. @n
105 * It is assumed that each %Pkcs05PbEs2Parameters will have only a single form of encoding 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, which 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 reference to the AlgorithmIdentifier instance, which identifies the underlying encryption algorithm. @n
130 * It shall be an OID in the set PBES2-Encs, whose definition is left to the application.
134 * @return A reference to AlgorithmIdentifier holding the underlying encryption algorithm
135 * @remarks The specific error code can be accessed using the GetLastResult() method.
137 const AlgorithmIdentifier& GetEncryptionScheme(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 PBES2 type.
145 * @return A pointer to IAlgorithmParameters containing the algorithm identifier of underlying pseudo random function, @n
146 * else @c null if an error occurs
147 * @remarks The specific error code can be accessed using the GetLastResult() method.
149 virtual IAlgorithmParameters* CloneN(void) const;
153 * Gets the PkcsAlgorithmParameterType value.
157 * @return PkcsAlgorithmParameterType holding enum value @c PKCS_ALGO_PARAM_TYPE_PKCS05_PBES02 for PBES2 Parameters
160 virtual PkcsAlgorithmParameterType GetType(void) const;
163 * Checks whether the specified instance of %Pkcs05PbEs2Parameters equals the current instance.
167 * @return @c true if the specified instance equals the current instance, @n
169 * @param[in] rhs An instance of %Pkcs05PbEs2Parameters
170 * @exception E_SUCCESS The method is successful.
171 * @exception E_INVALID_ARG The specified input parameter is invalid.
172 * @remarks The specific error code can be accessed using the GetLastResult() method.
174 virtual bool Equals(const Tizen::Base::Object& rhs) const;
177 * Gets the hash value of the current instance of %Pkcs05PbEs2Parameters.
181 * @return An integer value indicating the hash value of the current instance of %Pkcs05PbEs2Parameters
183 virtual int GetHashCode(void) const;
186 // This copy constructor is intentionally declared as private to prohibit @n
187 // copying of objects by users.
190 Pkcs05PbEs2Parameters(const Pkcs05PbEs2Parameters& rhs);
192 // The implementation of this copy assignment operator is intentionally blank and @n
193 // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
194 // Use Equals() to compare the contents of one instance with the other.
197 Pkcs05PbEs2Parameters& operator =(const Pkcs05PbEs2Parameters& rhs);
200 class _Pkcs05PbEs2ParametersImpl* __pPkcs05PbEs2ParametersImpl;
201 friend class _Pkcs05PbEs2ParametersImpl;
202 }; //Pkcs05PbEs2Parameters
204 } } } // Tizen::Security::Pkcs
206 #endif // _FSEC_PKCS_PKCS_05_PBES2_PARAMETERS_H_