Add IPC sync result for SerialPort::Write()
[platform/framework/native/appfw.git] / inc / FSecKeyPair.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                FSecKeyPair.h
19  * @brief               This is the header file for the %KeyPair class.
20  *
21  * This header file contains the declarations of the %KeyPair class.
22  */
23 #ifndef _FSEC_KEY_PAIR_H_
24 #define _FSEC_KEY_PAIR_H_
25
26 #include <FSecIKey.h>
27 #include <FSecIPublicKey.h>
28 #include <FSecIPrivateKey.h>
29 #include <FBaseObject.h>
30
31
32 namespace Tizen { namespace Security
33 {
34
35 /**
36  *      @class          KeyPair
37  *      @brief          This class is a simple holder for a key pair (a public and a private key).
38  *
39  *      @since          2.0
40  *
41  *      The %KeyPair class manages a pair of keys comprising of a public and a private key, which are used in asymmetric ciphers. 
42  *      The key pairs are mainly used to encrypt messages and provide digital signatures. @n
43  *
44  *      For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/security/key_mgmt_and_csprng.htm">Key Management and CSPRNG</a>.
45  *
46  *      @see    IKeyPairGenerator
47  *      @see    Tizen::Security::IPublicKey
48  *      @see    Tizen::Security::IPrivateKey
49  */
50 class _OSP_EXPORT_ KeyPair
51         : public Tizen::Base::Object
52 {
53
54 public:
55         /**
56          * The object is not fully constructed after this constructor is called. For full construction, @n
57          * the Construct() method must be called right after calling this constructor.
58          *
59          *      @since          2.0
60          */
61         KeyPair(void);
62
63         /**
64          * This destructor overrides Tizen::Base::Object::~Object().
65          *
66          *      @since          2.0
67          */
68         virtual ~KeyPair(void);
69
70         /**
71          *      Constructs and initializes the current instance of %KeyPair with the specified public and private keys.
72          *
73          *      @since          2.0
74          *
75          *      @return         An error code
76          *      @param[in]      publicKey                               An instance of IPublicKey
77          *      @param[in]      privateKey                              An instance of IPrivateKey
78          *      @exception      E_SUCCESS                               The method is successful.
79          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
80          *      @exception      E_INVALID_ARG                   The specified @c publicKey or @c privateKey is invalid.
81          */
82         result Construct(Tizen::Security::IPublicKey& publicKey, Tizen::Security::IPrivateKey& privateKey);
83
84         /**
85          *      Gets the public key component of the current instance of %KeyPair.
86          *
87          *      @since          2.0
88          *
89          *      @return         A pointer to IPublicKey
90          */
91         Tizen::Security::IPublicKey* GetPublicKey(void) const;
92
93         /**
94          *      Gets the private key component of the current instance of %KeyPair.
95          *
96          *      @since          2.0
97          *
98          *      @return         A pointer to IPrivateKey
99          */
100         Tizen::Security::IPrivateKey* GetPrivateKey(void) const;
101
102         /**
103          *      Sets the public key.
104          *
105          *      @since          2.0
106          *
107          *      @return         An error code
108          *      @param[in]      pubKey                                  An instance of Tizen::Base::ByteBuffer that contains the public key
109          *      @exception      E_SUCCESS                               The method is successful.
110          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
111          *      @exception      E_INVALID_ARG                   The specified @c pubKey is invalid.
112          *      @remarks        Only ASN.1 encoding format is supported for input buffer.
113          */
114         result SetPublicKey(const Tizen::Base::ByteBuffer& pubKey);
115
116         /**
117          *      Sets the private key.
118          *
119          *      @since          2.0
120          *
121          *      @return         An error code
122          *      @param[in]      privKey                                 An instance of Tizen::Base::ByteBuffer that contains the private key
123          *      @exception      E_SUCCESS                               The method is successful.
124          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
125          *      @exception      E_INVALID_ARG                   The specified @c privKey is invalid.
126          *      @remarks        Only ASN.1 encoding format is supported for input buffer.
127          */
128         result SetPrivateKey(const Tizen::Base::ByteBuffer& privKey);
129
130 private:
131
132         //
133         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
134         //
135         // @since 2.0
136         //
137         KeyPair(const KeyPair& rhs);
138
139         //
140         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
141         //
142         // @since 2.0
143         //
144         KeyPair& operator =(const KeyPair& rhs);
145
146 private:
147         Tizen::Security::IPublicKey* __pPubKey;
148         Tizen::Security::IPrivateKey* __pPriKey;
149
150         class _KeyPairImpl* __pKeyPairImpl;
151         friend class _KeyPairImpl;
152
153 }; //KeyPair
154
155 } } //Tizen::Security
156
157 #endif // _FSEC_KEY_PAIR_H_