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 FSecDhKeyParameters.h
20 * @brief This is the header file for the %DhKeyParameters class.
22 * This header file contains the declarations of the %DhKeyParameters class.
24 #ifndef _FSEC_DH_KEY_PARAMETERS_H_
25 #define _FSEC_DH_KEY_PARAMETERS_H_
27 #include <FSecIKeyParameters.h>
30 namespace Tizen { namespace Security
34 * @class DhKeyParameters
35 * @brief This class provides methods for retrieving the parameters for the Diffie-Hellman (DH) algorithm.
39 * The %DhKeyParameters class provides a subset of the domain parameters for the DH algorithm.
40 * For example, a prime number and a generator value are used to exchange keys between two parties. @n
42 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/security/key_exchange_algorithm.htm">Key exchanging</a>.
46 * The following example demonstrates how to use the %DhKeyParameters class.
49 * void GetParameterExample(void)
51 * result r = E_SUCCESS;
52 * KeyPairGenerator *pKeyPairGen = null;
53 * IKeyParameters *pKeyParams = null;
57 * ByteBuffer* pResult = null;
59 * // Generates the key.
60 * pKeyPairGen = new KeyPairGenerator();
61 * if (null == pKeyPairGen)
66 * r = pKeyPairGen->Construct(size, L"DH");
72 * pKeyParams = pKeyPairGen->GenerateKeyParametersN();
73 * if (null == pKeyParams)
78 * pResult = pKeyParams->GetParameterValueN(KEY_PARAMETER_DH_P);
79 * if (null == pResult)
84 * nResult = pKeyParams->GetParameterSize(KEY_PARAMETER_DH_PRIVATE_KEY_SIZE);
95 class _OSP_EXPORT_ DhKeyParameters
96 : public IKeyParameters
97 , public Tizen::Base::Object
102 * The object is not fully constructed after this constructor is called. For full construction, @n
103 * the Construct() method must be called right after calling this constructor.
107 DhKeyParameters(void);
110 * This destructor overrides Tizen::Base::Object::~Object().
114 virtual ~DhKeyParameters(void);
117 * Constructs and initializes this instance of IKeyParameters with the specified key parameters.
121 * @return An error code
122 * @param[in] primeNumber The prime number 'p' to instantiate
123 * @param[in] generatorNumber The generator value 'g' to instantiate
124 * @param[in] privateKeySize The size of the private key to instantiate
125 * @exception E_SUCCESS The method is successful.
126 * @exception E_INVALID_ARG A specified input parameter is invalid.
127 * @exception E_OUT_OF_MEMORY The memory is insufficient.
129 result Construct(const Tizen::Base::ByteBuffer& primeNumber, const Tizen::Base::ByteBuffer& generatorNumber, int privateKeySize);
132 * Gets the value of domain parameters (in Tizen::Base::ByteBuffer format) for the specified key parameter type.
136 * @return A pointer to the Tizen::Base::ByteBuffer class that contains the parameter values, @n
137 * else @c null if an error occurs
138 * @param[in] paramType The type of the parameter
139 * @exception E_SUCCESS The method is successful.
140 * @exception E_OUT_OF_MEMORY The memory is insufficient.
141 * @exception E_UNSUPPORTED_TYPE The specified @c paramType is not supported.
142 * @remarks The specific error code can be accessed using the GetLastResult() method.
144 virtual Tizen::Base::ByteBuffer* GetParameterValueN(KeyParameterType paramType) const;
147 * Gets the size of the private key component.
151 * @return The size of the private key component
152 * @param[in] paramType The type of the parameter
153 * @exception E_SUCCESS The method is successful.
154 * @exception E_UNSUPPORTED_TYPE The specified @c paramType is not supported.
155 * @remarks The specific error code can be accessed using the GetLastResult() method.
157 virtual int GetParameterSize(KeyParameterType paramType) const;
162 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
166 DhKeyParameters(const DhKeyParameters& rhs);
169 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
173 DhKeyParameters& operator =(const DhKeyParameters& rhs);
176 Tizen::Base::ByteBuffer __prime;
177 Tizen::Base::ByteBuffer __generator;
178 int __privateKeySize;
180 class _DhKeyParametersImpl* __pDhKeyParametersImpl;
181 friend class _DhKeyParametersImpl;
185 } } //Tizen::Security
187 #endif //_FSEC_DH_KEY_PARAMETERS_H_