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 FSecDhKeyParameters.h
19 * @brief This is the header file for the %DhKeyParameters class.
21 * This header file contains the declarations of the %DhKeyParameters class.
23 #ifndef _FSEC_DH_KEY_PARAMETERS_H_
24 #define _FSEC_DH_KEY_PARAMETERS_H_
26 #include <FSecIKeyParameters.h>
29 namespace Tizen { namespace Security
33 * @class DhKeyParameters
34 * @brief This class provides methods for retrieving the parameters for the Diffie-Hellman (DH) algorithm.
38 * The %DhKeyParameters class provides a subset of the domain parameters for the DH algorithm.
39 * For example, a prime number and a generator value are used to exchange keys between two parties. @n
41 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/security/key_exchange_algorithm.htm">Key exchanging</a>.
45 * The following example demonstrates how to use the %DhKeyParameters class.
48 * void GetParameterExample(void)
50 * result r = E_SUCCESS;
51 * KeyPairGenerator *pKeyPairGen = null;
52 * IKeyParameters *pKeyParams = null;
56 * ByteBuffer* pResult = null;
58 * // Generates the key.
59 * pKeyPairGen = new KeyPairGenerator();
60 * if (null == pKeyPairGen)
65 * r = pKeyPairGen->Construct(size, L"DH");
71 * pKeyParams = pKeyPairGen->GenerateKeyParametersN();
72 * if (null == pKeyParams)
77 * pResult = pKeyParams->GetParameterValueN(KEY_PARAMETER_DH_P);
78 * if (null == pResult)
83 * nResult = pKeyParams->GetParameterSize(KEY_PARAMETER_DH_PRIVATE_KEY_SIZE);
94 class _OSP_EXPORT_ DhKeyParameters
95 : public IKeyParameters
96 , public Tizen::Base::Object
101 * The object is not fully constructed after this constructor is called. For full construction, @n
102 * the Construct() method must be called right after calling this constructor.
106 DhKeyParameters(void);
109 * This destructor overrides Tizen::Base::Object::~Object().
113 virtual ~DhKeyParameters(void);
116 * Constructs and initializes this instance of IKeyParameters with the specified key parameters.
120 * @return An error code
121 * @param[in] primeNumber The prime number 'p' to instantiate
122 * @param[in] generatorNumber The generator value 'g' to instantiate
123 * @param[in] privateKeySize The size of the private key to instantiate
124 * @exception E_SUCCESS The method is successful.
125 * @exception E_INVALID_ARG A specified input parameter is invalid.
126 * @exception E_OUT_OF_MEMORY The memory is insufficient.
128 result Construct(const Tizen::Base::ByteBuffer& primeNumber, const Tizen::Base::ByteBuffer& generatorNumber, int privateKeySize);
131 * Gets the value of domain parameters (in Tizen::Base::ByteBuffer format) for the specified key parameter type.
135 * @return A pointer to the Tizen::Base::ByteBuffer class that contains the parameter values, @n
136 * else @c null if an error occurs
137 * @param[in] paramType The type of the parameter
138 * @exception E_SUCCESS The method is successful.
139 * @exception E_OUT_OF_MEMORY The memory is insufficient.
140 * @exception E_UNSUPPORTED_TYPE The specified @c paramType is not supported.
141 * @remarks The specific error code can be accessed using the GetLastResult() method.
143 virtual Tizen::Base::ByteBuffer* GetParameterValueN(KeyParameterType paramType) const;
146 * Gets the size of the private key component.
150 * @return The size of the private key component
151 * @param[in] paramType The type of the parameter
152 * @exception E_SUCCESS The method is successful.
153 * @exception E_UNSUPPORTED_TYPE The specified @c paramType is not supported.
154 * @remarks The specific error code can be accessed using the GetLastResult() method.
156 virtual int GetParameterSize(KeyParameterType paramType) const;
161 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
165 DhKeyParameters(const DhKeyParameters& rhs);
168 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
172 DhKeyParameters& operator =(const DhKeyParameters& rhs);
175 Tizen::Base::ByteBuffer __prime;
176 Tizen::Base::ByteBuffer __generator;
177 int __privateKeySize;
179 class _DhKeyParametersImpl* __pDhKeyParametersImpl;
180 friend class _DhKeyParametersImpl;
184 } } //Tizen::Security
186 #endif //_FSEC_DH_KEY_PARAMETERS_H_