Fix the boiler plate codes
[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. The key pairs are mainly used to encrypt messages and provide digital signatures. @n
42  *
43  *      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>.
44  *
45  *  @see        IKeyPairGenerator
46  *  @see        Tizen::Security::IPublicKey
47  *  @see        Tizen::Security::IPrivateKey
48  */
49 class _OSP_EXPORT_ KeyPair
50         : public Tizen::Base::Object
51 {
52
53 public:
54         /**
55          * The object is not fully constructed after this constructor is called. For full construction, @n
56          * the Construct() method must be called right after calling this constructor.
57          *
58          *      @since          2.0
59          */
60         KeyPair(void);
61
62         /**
63          * This destructor overrides Tizen::Base::Object::~Object().
64          *
65          *      @since          2.0
66          */
67         virtual ~KeyPair(void);
68
69         /**
70          *      Constructs and initializes the current instance of %KeyPair with the specified public and private keys.
71          *
72          *      @since          2.0
73          *
74          *      @return         An error code
75          *      @param[in]      publicKey                               An instance of IPublicKey
76          *      @param[in]      privateKey                              An instance of IPrivateKey
77          *      @exception      E_SUCCESS                               The method is successful.
78          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
79          *      @exception      E_INVALID_ARG                   The specified @c publicKey or @c privateKey is invalid.
80          */
81         result Construct(Tizen::Security::IPublicKey& publicKey, Tizen::Security::IPrivateKey& privateKey);
82
83         /**
84          *      Gets the public key component of the current instance of %KeyPair.
85          *
86          *      @since          2.0
87          *
88          *      @return         A pointer to IPublicKey
89          */
90         Tizen::Security::IPublicKey* GetPublicKey(void) const;
91
92         /**
93          *      Gets the private key component of the current instance of %KeyPair.
94          *
95          *      @since          2.0
96          *
97          *      @return         A pointer to IPrivateKey
98          */
99         Tizen::Security::IPrivateKey* GetPrivateKey(void) const;
100
101         /**
102          *      Sets the public key.
103          *
104          *      @since          2.0
105          *
106          *      @return         An error code
107          *      @param[in]      pubKey                                  An instance of Tizen::Base::ByteBuffer that contains the public key
108          *      @exception      E_SUCCESS                               The method is successful.
109          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
110          *      @exception      E_INVALID_ARG                   The specified @c pubKey is invalid.
111          *      @remarks        Only ASN.1 encoding format is supported for input buffer.
112          */
113         result SetPublicKey(const Tizen::Base::ByteBuffer& pubKey);
114
115         /**
116          *      Sets the private key.
117          *
118          *      @since          2.0
119          *
120          *      @return         An error code
121          *      @param[in]      privKey                                 An instance of Tizen::Base::ByteBuffer that contains the private key
122          *      @exception      E_SUCCESS                               The method is successful.
123          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
124          *      @exception      E_INVALID_ARG                   The specified @c privKey is invalid.
125          *      @remarks        Only ASN.1 encoding format is supported for input buffer.
126          */
127         result SetPrivateKey(const Tizen::Base::ByteBuffer& privKey);
128
129 private:
130
131         //
132         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
133         //
134         // @since 2.0
135         //
136         KeyPair(const KeyPair& rhs);
137
138         //
139         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
140         //
141         // @since 2.0
142         //
143         KeyPair& operator =(const KeyPair& rhs);
144
145 private:
146         Tizen::Security::IPublicKey* __pPubKey;
147         Tizen::Security::IPrivateKey* __pPriKey;
148
149         class _KeyPairImpl* __pKeyPairImpl;
150         friend class _KeyPairImpl;
151
152 }; //KeyPair
153
154 } } //Tizen::Security
155
156 #endif // _FSEC_KEY_PAIR_H_