sync with tizen_2.0
[platform/framework/native/appfw.git] / inc / FSecIKeyPairGenerator.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                        FSecIKeyPairGenerator.h
20  * @brief               This is the header file for the %IKeyPairGenerator interface.
21  *
22  * This header file contains the declarations of the %IKeyPairGenerator interface.
23  */
24 #ifndef _FSEC_IKEY_PAIR_GENERATOR_H_
25 #define _FSEC_IKEY_PAIR_GENERATOR_H_
26
27 #include <FBaseString.h>
28 #include <FSecKeyPair.h>
29
30
31 namespace Tizen { namespace Security
32 {
33
34 /**
35  * @interface   IKeyPairGenerator
36  * @brief               This interface provides the abstract methods for generating a pair of public and private keys.
37  *
38  * @since               2.0
39  *
40  * The %IKeyPairGenerator interface provides the abstract methods for generating a pair of public and private keys. @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                 Tizen::Security::KeyPair
45  */
46 class _OSP_EXPORT_ IKeyPairGenerator
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 ~IKeyPairGenerator(void){}
57
58         /**
59          * Constructs and initializes an instance of %IKeyPairGenerator with the specified modulus size.
60          *
61          * @since               2.0
62          *
63          * @return              An error code
64          * @param[in]   modulusBitSize          The modulus size in bits
65          * @exception   E_SUCCESS                       The method is successful.
66          * @exception   E_INVALID_ARG           The specified @c modulusBitSize is invalid. @n
67          *                                                      The modulus size must be atleast greater than or equal to @c 1024 bits @n
68          *                                                      to generate cryptographically secure keys.
69          */
70         virtual result Construct(int modulusBitSize) = 0;
71
72         /**
73          * Generates a new key pair.
74          *
75          * @since               2.0
76          *
77          * @return              A pointer to the KeyPair class, @n
78          *                              else @c null if the method fails to generate the key pair
79          * @exception   E_SUCCESS                                       The method is successful.
80          * @exception   E_UNSUPPORTED_ALGORITHM         The requested algorithm is not supported.
81          * @exception   E_OUT_OF_MEMORY                         The memory is insufficient.
82          * @exception   E_SYSTEM                                        A system error has occurred. @n
83          *                                                                                      The method has failed to operate with the OpenSSL library.
84          * @remarks The specific error code can be accessed using the GetLastResult() method.
85          */
86         virtual Tizen::Security::KeyPair* GenerateKeyPairN(void) const = 0;
87
88 protected:
89         //
90         // This method is for internal use only. Using this method can cause behavioral, security-related,
91         // and consistency-related issues in the application.
92         //
93         // This method is reserved and may change its name at any time without prior notice.
94         //
95         // @since 2.0
96         //
97         virtual void IKeyPairGenerator_Reserved1(void) {}
98
99 }; //IKeyPairGenerator
100
101 } } //Tizen::Security
102
103 #endif // _FSEC_IKEY_PAIR_GENERATOR_H_