b00d0ec5ab28cb21c8e5822eafe6f933a0f25d71
[platform/framework/native/appfw.git] / inc / FSecIKey.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                        FSecIKey.h
19  * @brief               This is the header file for the %IKey interface.
20  *
21  * This header file contains the declarations of the %IKey interface.
22  */
23 #ifndef _FSEC_IKEY_H_
24 #define _FSEC_IKEY_H_
25
26 #include <FBase.h>
27
28 namespace Tizen { namespace Security
29 {
30
31 /**
32  * @interface   IKey
33  * @brief                This interface provides methods that help in setting the buffer for the key. These methods also extract the encoding format of the key.
34  *
35  * @since               2.0
36  *
37  * The %IKey interface provides methods that help in setting the buffer for the key. These methods also extract the encoding format of the key. @n
38  *
39  * 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>.
40  *
41  * @see Tizen::Security::IPrivateKey
42  * @see Tizen::Security::IPublicKey
43  * @see Tizen::Security::ISecretKey
44  * @see Tizen::Security::PrivateKey
45  * @see Tizen::Security::PublicKey
46  * @see Tizen::Security::SecretKey
47  */
48 class _OSP_EXPORT_ IKey
49 {
50
51 public:
52         /**
53          * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes @n
54          * are called when the destructor of this interface is called.
55          *
56          * @since       2.0
57          */
58         virtual ~IKey(void){}
59
60         /**
61          * Gets the name of the primary encoding format of the key.
62          *
63          * @since               2.0
64          *
65          * @return              The primary encoding format of the key
66          */
67         virtual Tizen::Base::String GetFormat(void) const = 0;
68
69         /**
70          * Gets the key in its primary encoding format.
71          *
72          * @since               2.0
73          *
74          * @return              A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
75          *                              else @c null if an error occurs
76          * @exception   E_SUCCESS                       The method is successful.
77          * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
78          * @remarks     The specific error code can be accessed using the GetLastResult() method.
79          */
80         virtual Tizen::Base::ByteBuffer* GetEncodedN(void) const = 0;
81
82         /**
83          * Sets the key buffer.
84          *
85          * @since               2.0
86          *
87          * @return              An error code
88          * @param[in]   keyBuffer                       An instance of Tizen::Base::ByteBuffer
89          * @exception   E_SUCCESS                       The method is successful.
90          * @exception   E_INVALID_ARG           The specified @c keyBuffer is invalid.
91          */
92         virtual result SetKey(const Tizen::Base::ByteBuffer& keyBuffer) = 0;
93
94 protected:
95         //
96         // This method is for internal use only. Using this method can cause behavioral, security-related,
97         // and consistency-related issues in the application.
98         //
99         // This method is reserved and may change its name at any time without prior notice.
100         //
101         // @since 2.0
102         //
103         virtual void IKey_Reserved1(void) {}
104
105 }; //IKey
106
107 } } //Tizen::Security
108
109 #endif // _FSEC_IKEY_H_