2 // Copyright (c) 2012 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 FSecKeaKeyParameters.h
19 * @brief This is the header file for the %KeaKeyParameters class.
21 * This header file contains the declarations of the %KeaKeyParameters class.
23 #ifndef _FSEC_KEA_KEY_PARAMETERS_H_
24 #define _FSEC_KEA_KEY_PARAMETERS_H_
26 #include <FBaseString.h>
27 #include <FBaseByteBuffer.h>
28 #include <FSecISecretKey.h>
29 #include <FSecCryptoTypes.h>
30 #include <FSecIKeyParameters.h>
33 namespace Tizen { namespace Security
37 * @class KeaKeyParameters
38 * @brief This class provides parameters for a Key Exchange mechanism using the KEA algorithm.
42 * The %KeaKeyParameters class provides a subset of domain parameters for the KEA algorithm.
43 * For example, a prime number and a generator value are used to exchange keys between the two parties. @n
45 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/security/key_exchange_algorithm.htm">Key exchanging</a>.
49 * The following example demonstrates how to use the %KeaKeyParameters class.
52 * void GetParameterExample(void)
54 * result r = E_SUCCESS;
55 * KeyPairGenerator *pKeyPairGen = null;
56 * IKeyParameters *pKeyParams = null;
60 * ByteBuffer* pResult = null;
62 * // Generates the key.
63 * pKeyPairGen = new KeyPairGenerator();
64 * if (null == pKeyPairGen)
69 * r = pKeyPairGen->Construct(size, "KEA");
75 * pKeyParams = pKeyPairGen->GenerateKeyParametersN();
76 * if (null == pKeyParams)
81 * pResult = pKeyParams->GetParameterValueN(KEY_PARAMETER_KEA_P);
82 * if (null == pResult)
87 * nResult = pKeyParams->GetParameterSize(KEY_PARAMETER_KEA_PRIVATE_KEY_SIZE);
98 class _OSP_EXPORT_ KeaKeyParameters
99 : public IKeyParameters
100 , public Tizen::Base::Object
105 * The object is not fully constructed after this constructor is called. For full construction, @n
106 * the Construct() method must be called right after calling this constructor.
110 KeaKeyParameters(void);
113 * This destructor overrides Tizen::Base::Object::~Object().
117 virtual ~KeaKeyParameters(void);
120 * Constructs and initializes an instance of %KeaKeyParameters with the specified key parameters.
124 * @return An error code
125 * @param[in] primeNumber The prime number to instantiate
126 * @param[in] generatorNumber The generator value to instantiate
127 * @param[in] privateKeySize The size of the private key to instantiate
128 * @exception E_SUCCESS The method is successful.
129 * @exception E_INVALID_ARG A specified input parameter is invalid.
130 * @exception E_OUT_OF_MEMORY The memory is insufficient.
133 result Construct(const Tizen::Base::ByteBuffer& primeNumber, const Tizen::Base::ByteBuffer& generatorNumber, int privateKeySize);
136 * Gets the Tizen::Base::ByteBuffer value of parameters for the specified key parameter type.
140 * @return A pointer to the Tizen::Base::ByteBuffer class that contains the parameter values, @n
141 * else @c null if an error occurs
142 * @param[in] paramType The parameter type @n
143 * For example, @c KEY_PARAMETER_KEA_P.
144 * @exception E_SUCCESS The method is successful.
145 * @exception E_OUT_OF_MEMORY The memory is insufficient.
146 * @exception E_UNSUPPORTED_TYPE The specified @c paramType is not supported.
147 * @remarks The specific error code can be accessed using the GetLastResult() method.
149 virtual Tizen::Base::ByteBuffer* GetParameterValueN(KeyParameterType paramType) const;
152 * Gets the size of the private key component.
156 * @return The size of the private key component
157 * @param[in] paramType The parameter type @n
158 * For example, @c KEY_PARAMETER_PRIVATE_KEY_SIZE.
159 * @exception E_SUCCESS The method is successful.
160 * @exception E_UNSUPPORTED_TYPE The specified @c paramType is not supported.
161 * @remarks The specific error code can be accessed using the GetLastResult() method.
163 virtual int GetParameterSize(KeyParameterType paramType) const;
168 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
172 KeaKeyParameters(const KeaKeyParameters& rhs);
175 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
179 KeaKeyParameters& operator =(const KeaKeyParameters& rhs);
182 Tizen::Base::ByteBuffer __prime;
183 Tizen::Base::ByteBuffer __generator;
184 int __privateKeySize;
186 class _KeaKeyParametersImpl* __pKeaKeyParametersImpl;
187 friend class _KeaKeyParametersImpl;
191 } } //Tizen::Security
193 #endif //_FSEC_KEA_KEY_EXCHANGE_PARAMS_H