sync with tizen_2.0
[platform/framework/native/appfw.git] / inc / FSecISecureRandom.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                FSecISecureRandom.h
20  * @brief               This is the header file for the %ISecureRandom interface.
21  *
22  * This header file contains the declarations of the %ISecureRandom interface.
23  */
24 #ifndef _FSEC_ISECURE_RANDOM_H_
25 #define _FSEC_ISECURE_RANDOM_H_
26
27 #include <FBaseString.h>
28 #include <FBaseByteBuffer.h>
29
30 namespace Tizen { namespace Security
31 {
32
33 /**
34  *      @interface      ISecureRandom
35  *      @brief          This interface provides the abstract methods for generating a secure random object.
36  *
37  *  @since      2.0
38  *
39  *  The %ISecureRandom interface provides the abstract methods for generating a secure random object. @n
40  *
41  * 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>.
42  *
43  *      @see    Tizen::Security::AesSecureRandom
44  *      @see    Tizen::Security::DesSecureRandom
45  *      @see    Tizen::Security::DesEdeSecureRandom
46  */
47 class _OSP_EXPORT_ ISecureRandom
48 {
49
50 public:
51         /**
52          * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes @n
53          * are called when the destructor of this interface is called.
54          *
55          * @since               2.0
56          */
57         virtual ~ISecureRandom(void) {}
58
59         /**
60          *      Generates a user-specified number of random bytes.
61          *
62          *      @since          2.0
63          *
64          *      @return         A pointer to the Tizen::Base::ByteBuffer class, @n
65          *                              else @c null if an error occurs
66          *      @param[in]      numBytes                                The number of random bytes to generate
67          *      @exception      E_SUCCESS                               The method is successful.
68          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
69          *      @exception      E_INVALID_ARG                   The specified @c numBytes is @c 0 or negative.
70          *      @exception      E_SYSTEM                                A system error has occurred. @n
71          *                                                                              The method has failed to operate with the OpenSSL library, or the Tizen::Base::ByteBuffer operation has failed.
72          * @remarks The specific error code can be accessed using the GetLastResult() method.
73
74          */
75         virtual Tizen::Base::ByteBuffer* GenerateRandomBytesN(int numBytes) = 0;
76
77 protected:
78         //
79         // This method is for internal use only. Using this method can cause behavioral, security-related,
80         // and consistency-related issues in the application.
81         //
82         // This method is reserved and may change its name at any time without prior notice.
83         //
84         // @since 2.0
85         //
86         virtual void ISecureRandom_Reserved1(void) {}
87
88 }; //ISecureRandom
89
90 } } //Tizen::Security
91
92 #endif // _FSEC_ISECURE_RANDOM_H_