Merge "Remove the memory leak on osp-security-service" into tizen_2.2
[platform/framework/native/appfw.git] / inc / FSecCryptoIKeyExchange.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 //
16
17 /**
18  * @file                FSecCryptoIKeyExchange.h
19  * @brief               This is the header file for the %IKeyExchange interface.
20  *
21  * This header file contains the declarations of the %IKeyExchange interface.
22  */
23 #ifndef _FSEC_CRYPTO_IKEY_EXCHANGE_H_
24 #define _FSEC_CRYPTO_IKEY_EXCHANGE_H_
25
26 #include <FBaseByteBuffer.h>
27 #include <FSecCryptoTypes.h>
28 #include <FSecKeyPair.h>
29 #include <FSecIKeyParameters.h>
30
31 namespace Tizen { namespace Security { namespace Crypto
32 {
33
34 /**
35  *      @interface      IKeyExchange
36  *      @brief          This interface provides methods for the Key Exchange algorithm.
37  *
38  *      @since          2.0
39  *
40  *      The %IKeyExchange interface provides methods to exchange secure keys between two communicating users. @n
41  *
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>.
43  *
44  *      @see    KeyPairGenerator
45  */
46 class _OSP_EXPORT_ IKeyExchange
47 {
48
49 public:
50         /**
51          * This polymorphic destructor should be overridden if required. @n 
52          * This way, the destructors of the derived classes are called when the destructor of this interface is called.
53          *
54          *      @since          2.0
55          */
56         virtual ~IKeyExchange(void) {}
57
58         /**
59          *      Initializes this instance of %IKeyExchange with the specified key parameters.
60          *
61          *      @since          2.0
62          *
63          *      @return         An error code
64          *      @param[in]      keyParameters                   The domain parameters of the key exchange algorithm
65          *      @exception      E_SUCCESS                               The method is successful.
66          *      @exception      E_INVALID_ARG                   The specified input parameter is invalid.
67          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
68          *      @remarks        The key parameters can be @c null depending on the underlying key exchange algorithm.
69          */
70         virtual result Construct(const Tizen::Security::IKeyParameters& keyParameters) = 0;
71
72         /**
73          *      Generates the final version of the shared secret amongst the two parties.
74          *
75          *      @since          2.0
76          *
77          *      @return         A pointer to the Tizen::Base::ByteBuffer class that contains the generated secret key, @n
78          *                              else @c null if the method fails to generate the secret key
79          *      @param[in]      privateKey                              The private key component of the first party to instantiate
80          *      @param[in]      publicKey                               The public key component of the second party to instantiate
81          *      @exception      E_SUCCESS                               The method is successful.
82          *      @exception      E_INVALID_ARG                   A specified input parameter is invalid.
83          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
84          *      @exception      E_SYSTEM                                Either of the following conditions has occurred:
85          *                                                                              - A system error has occurred.
86          *                                                                              - The method has failed to operate with the OpenSSL library.
87          *                                                                              - The Tizen::Base::ByteBuffer operation has failed.
88          *      @remarks        The specific error code can be accessed using the GetLastResult() method.
89          */
90         virtual Tizen::Base::ByteBuffer* GenerateSecretN(Tizen::Security::IPrivateKey& privateKey, Tizen::Security::IPublicKey& publicKey) = 0;
91
92
93 protected:
94         //
95         //      This method is for internal use only. Using this method can cause behavioral, security-related,
96         //      and consistency-related issues in the application.
97         //
98         //      This method is reserved and may change its name at any time without prior notice.
99         //
100         //      @since 2.0
101         //
102         virtual void IKeyExchange_Reserved1(void) {}
103
104         //
105         //      This method is for internal use only. Using this method can cause behavioral, security-related,
106         //      and consistency-related issues in the application.
107         //
108         //      This method is reserved and may change its name at any time without prior notice.
109         //
110         //      @since 2.0
111         //
112         virtual void IKeyExchange_Reserved2(void) {}
113
114         //
115         //      This method is for internal use only. Using this method can cause behavioral, security-related,
116         //      and consistency-related issues in the application.
117         //
118         //      This method is reserved and may change its name at any time without prior notice.
119         //
120         //      @since 2.0
121         //
122         virtual void IKeyExchange_Reserved3(void) {}
123
124 }; //IKeyExchange
125
126 } } } //Tizen::Security::Crypto
127
128 #endif //_FSEC_CRYPTO_IKEY_EXCHANGE_H_