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