[ACR][10/10/2013][Remove]Removing API versioning to support E_OUT_OF_RANGE exception...
[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. This way, the destructors of the derived classes @n
52          * 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 that needs to instantiate
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                                A system error has occurred. @n
85          *                                                                              The method has failed to operate with the openssl library, or
86          *                                                                              the Tizen::Base::ByteBuffer operation has failed.
87          *      @remarks        The specific error code can be accessed using the GetLastResult() method.
88          */
89         virtual Tizen::Base::ByteBuffer* GenerateSecretN(Tizen::Security::IPrivateKey& privateKey, Tizen::Security::IPublicKey& publicKey) = 0;
90
91
92 protected:
93         //
94         //      This method is for internal use only. Using this method can cause behavioral, security-related,
95         //      and consistency-related issues in the application.
96         //
97         //      This method is reserved and may change its name at any time without prior notice.
98         //
99         //      @since 2.0
100         //
101         virtual void IKeyExchange_Reserved1(void) {}
102
103         //
104         //      This method is for internal use only. Using this method can cause behavioral, security-related,
105         //      and consistency-related issues in the application.
106         //
107         //      This method is reserved and may change its name at any time without prior notice.
108         //
109         //      @since 2.0
110         //
111         virtual void IKeyExchange_Reserved2(void) {}
112
113         //
114         //      This method is for internal use only. Using this method can cause behavioral, security-related,
115         //      and consistency-related issues in the application.
116         //
117         //      This method is reserved and may change its name at any time without prior notice.
118         //
119         //      @since 2.0
120         //
121         virtual void IKeyExchange_Reserved3(void) {}
122
123 }; //IKeyExchange
124
125 } } } //Tizen::Security::Crypto
126
127 #endif //_FSEC_CRYPTO_IKEY_EXCHANGE_H_