sync with tizen_2.0
[platform/framework/native/appfw.git] / inc / FSecPrivateKey.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                        FSecPrivateKey.h
20  * @brief               This is the header file for the %PrivateKey class.
21  *
22  * This header file contains the declarations of the %PrivateKey class.
23  */
24 #ifndef _FSEC_PRIVATE_KEY_H_
25 #define _FSEC_PRIVATE_KEY_H_
26
27 #include <FSecIKey.h>
28 #include <FSecIPrivateKey.h>
29
30
31 namespace Tizen { namespace Security
32 {
33
34 /**
35  *      @class          PrivateKey
36  *      @brief          This class specifies the RSA private key.
37  *
38  *  @since      2.0
39  *
40  *  The %PrivateKey class manages a private key, which is used in asymmetric ciphers. The RSA algorithm decrypts the data using the private key. @n
41  *
42  * 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>.
43  *
44  *      @see    IKey
45  *      @see    IPrivateKey
46  *      @see    IKeyPairGenerator
47  */
48 class _OSP_EXPORT_ PrivateKey
49         : public virtual IKey
50         , public virtual IPrivateKey
51         , public Tizen::Base::Object
52 {
53
54 public:
55         /**
56          *      This is the default constructor for this class.
57          *
58          * @since       2.0
59          */
60         PrivateKey(void);
61
62         /**
63          * This destructor overrides Tizen::Base::Object::~Object().
64          *
65          * @since       2.0
66          */
67         virtual ~PrivateKey(void);
68
69         /**
70          *      Gets the name of the primary encoding format of the current instance of %PrivateKey.
71          *
72          * @since       2.0
73          *
74          *      @return         The primary encoding format of a key
75          */
76         virtual Tizen::Base::String GetFormat(void) const;
77
78         /**
79          *      Gets the private key in its primary encoding format.
80          *
81          *      @since           2.0
82          *
83          *      @return         A pointer to the Tizen::Base::ByteBuffer class, @n
84          *                                      else @c null if an error occurs
85          *      @exception      E_SUCCESS                               The method is successful.
86          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
87          *  @remarks    The specific error code can be accessed using the GetLastResult() method.
88          */
89         virtual Tizen::Base::ByteBuffer* GetEncodedN(void) const;
90
91         /**
92          *      Sets the private key buffer.
93          *
94          * @since           2.0
95          *
96          *      @return         An error code
97          *      @param[in]      keyBuffer                               An instance of Tizen::Base::ByteBuffer
98          *      @exception      E_SUCCESS                               The method is successful.
99          *      @exception      E_INVALID_ARG               The specified @c keyBuffer is invalid.
100          *      @remarks        Only ASN.1 encoding format is supported for input buffer.
101          */
102         virtual result SetKey(const Tizen::Base::ByteBuffer& keyBuffer);
103
104 private:
105
106         //
107         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
108         //
109         // @since 2.0
110         //
111         PrivateKey(const PrivateKey& rhs);
112
113         //
114         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
115         //
116         // @since 2.0
117         //
118         PrivateKey& operator =(const PrivateKey& rhs);
119
120 private:
121         Tizen::Base::String __algorithm;
122         Tizen::Base::String __encodedFormat;
123         Tizen::Base::ByteBuffer __keyBytes;
124
125         class _PrivateKeyImpl* __pPrivateKeyImpl;
126         friend class _PrivateKeyImpl;
127
128 }; // PrivateKey
129
130 } } // Tizen::Security
131
132 #endif //_FSEC_PRIVATE_KEY_H_