2 // Open Service Platform
3 // Copyright (c) 2012 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 FSecKeaKeyParameters.h
20 * @brief This is the header file for the %KeaKeyParameters class.
22 * This header file contains the declarations of the %KeaKeyParameters class.
24 #ifndef _FSEC_KEA_KEY_PARAMETERS_H_
25 #define _FSEC_KEA_KEY_PARAMETERS_H_
27 #include <FBaseString.h>
28 #include <FBaseByteBuffer.h>
29 #include <FSecISecretKey.h>
30 #include <FSecCryptoTypes.h>
31 #include <FSecIKeyParameters.h>
34 namespace Tizen { namespace Security
38 * @class KeaKeyParameters
39 * @brief This class provides parameters for a Key Exchange mechanism using the KEA algorithm.
43 * The %KeaKeyParameters class provides a subset of domain parameters for the KEA algorithm.
44 * For example, a prime number and a generator value are used to exchange keys between the two parties. @n
46 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/security/key_exchange_algorithm.htm">Key exchanging</a>.
50 * The following example demonstrates how to use the %KeaKeyParameters class.
53 * void GetParameterExample(void)
55 * result r = E_SUCCESS;
56 * KeyPairGenerator *pKeyPairGen = null;
57 * IKeyParameters *pKeyParams = null;
61 * ByteBuffer* pResult = null;
63 * // Generates the key.
64 * pKeyPairGen = new KeyPairGenerator();
65 * if (null == pKeyPairGen)
70 * r = pKeyPairGen->Construct(size, "KEA");
76 * pKeyParams = pKeyPairGen->GenerateKeyParametersN();
77 * if (null == pKeyParams)
82 * pResult = pKeyParams->GetParameterValueN(KEY_PARAMETER_KEA_P);
83 * if (null == pResult)
88 * nResult = pKeyParams->GetParameterSize(KEY_PARAMETER_KEA_PRIVATE_KEY_SIZE);
99 class _OSP_EXPORT_ KeaKeyParameters
100 : public IKeyParameters
101 , public Tizen::Base::Object
106 * The object is not fully constructed after this constructor is called. For full construction, @n
107 * the Construct() method must be called right after calling this constructor.
111 KeaKeyParameters(void);
114 * This destructor overrides Tizen::Base::Object::~Object().
118 virtual ~KeaKeyParameters(void);
121 * Constructs and initializes an instance of %KeaKeyParameters with the specified key parameters.
125 * @return An error code
126 * @param[in] primeNumber The prime number to instantiate
127 * @param[in] generatorNumber The generator value to instantiate
128 * @param[in] privateKeySize The size of the private key to instantiate
129 * @exception E_SUCCESS The method is successful.
130 * @exception E_INVALID_ARG A specified input parameter is invalid.
131 * @exception E_OUT_OF_MEMORY The memory is insufficient.
134 result Construct(const Tizen::Base::ByteBuffer& primeNumber, const Tizen::Base::ByteBuffer& generatorNumber, int privateKeySize);
137 * Gets the Tizen::Base::ByteBuffer value of parameters for the specified key parameter type.
141 * @return A pointer to the Tizen::Base::ByteBuffer class that contains the parameter values, @n
142 * else @c null if an error occurs
143 * @param[in] paramType The parameter type @n
144 * For example, @c KEY_PARAMETER_KEA_P.
145 * @exception E_SUCCESS The method is successful.
146 * @exception E_OUT_OF_MEMORY The memory is insufficient.
147 * @exception E_UNSUPPORTED_TYPE The specified @c paramType is not supported.
148 * @remarks The specific error code can be accessed using the GetLastResult() method.
150 virtual Tizen::Base::ByteBuffer* GetParameterValueN(KeyParameterType paramType) const;
153 * Gets the size of the private key component.
157 * @return The size of the private key component
158 * @param[in] paramType The parameter type @n
159 * For example, @c KEY_PARAMETER_PRIVATE_KEY_SIZE.
160 * @exception E_SUCCESS The method is successful.
161 * @exception E_UNSUPPORTED_TYPE The specified @c paramType is not supported.
162 * @remarks The specific error code can be accessed using the GetLastResult() method.
164 virtual int GetParameterSize(KeyParameterType paramType) const;
169 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
173 KeaKeyParameters(const KeaKeyParameters& rhs);
176 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
180 KeaKeyParameters& operator =(const KeaKeyParameters& rhs);
183 Tizen::Base::ByteBuffer __prime;
184 Tizen::Base::ByteBuffer __generator;
185 int __privateKeySize;
187 class _KeaKeyParametersImpl* __pKeaKeyParametersImpl;
188 friend class _KeaKeyParametersImpl;
192 } } //Tizen::Security
194 #endif //_FSEC_KEA_KEY_EXCHANGE_PARAMS_H