sync with tizen_2.0
[platform/framework/native/appfw.git] / inc / FSecCryptoIKeyExchange.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file                FSecCryptoIKeyExchange.h
20  * @brief               This is the header file for the %IKeyExchange interface.
21  *
22  * This header file contains the declarations of the %IKeyExchange interface.
23  */
24 #ifndef _FSEC_CRYPTO_IKEY_EXCHANGE_H_
25 #define _FSEC_CRYPTO_IKEY_EXCHANGE_H_
26
27 #include <FBaseByteBuffer.h>
28 #include <FSecCryptoTypes.h>
29 #include <FSecKeyPair.h>
30 #include <FSecIKeyParameters.h>
31
32 namespace Tizen { namespace Security { namespace Crypto
33 {
34
35 /**
36  *      @interface      IKeyExchange
37  *      @brief          This interface provides methods for the Key Exchange algorithm.
38  *
39  *      @since          2.0
40  *
41  *      The %IKeyExchange interface provides methods to exchange secure keys between two communicating users. @n
42  *
43  *      For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/security/key_exchange_algorithm.htm">Key exchanging</a>.
44  *
45  *      @see    KeyPairGenerator
46  */
47 class _OSP_EXPORT_ IKeyExchange
48 {
49
50 public:
51         /**
52          * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes @n
53          * are called when the destructor of this interface is called.
54          *
55          *      @since          2.0
56          */
57         virtual ~IKeyExchange(void) {}
58
59         /**
60          *      Initializes this instance of %IKeyExchange with the specified key parameters.
61          *
62          *      @since          2.0
63          *
64          *      @return         An error code
65          *      @param[in]      keyParameters                   The domain parameters of the key exchange algorithm that needs to instantiate
66          *      @exception      E_SUCCESS                               The method is successful.
67          *      @exception      E_INVALID_ARG                   The specified input parameter is invalid.
68          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
69          *      @remarks        The key parameters can be @c null depending on the underlying key exchange algorithm.
70          */
71         virtual result Construct(const Tizen::Security::IKeyParameters& keyParameters) = 0;
72
73         /**
74          *      Generates the final version of the shared secret amongst the two parties.
75          *
76          *      @since          2.0
77          *
78          *      @return         A pointer to the Tizen::Base::ByteBuffer class that contains the generated secret key, @n
79          *                              else @c null if the method fails to generate the secret key
80          *      @param[in]      privateKey                              The private key component of the first party to instantiate
81          *      @param[in]      publicKey                               The public key component of the second party to instantiate
82          *      @exception      E_SUCCESS                               The method is successful.
83          *      @exception      E_INVALID_ARG                   A specified input parameter is invalid.
84          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
85          *      @exception      E_SYSTEM                                A system error has occurred. @n
86          *                                                                              The method has failed to operate with the openssl library, or
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_