Merge "Modify DataSet::CloneN to deep copy" into tizen_2.1
[platform/framework/native/appfw.git] / inc / FSecPkcsInitialVector.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2013 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                FSecPkcsInitialVector.h
20  * @brief               This is the header file for the %InitialVector class.
21  *
22  * This header file contains the declarations of the %InitialVector class.
23  */
24
25 #ifndef _FSEC_PKCS_INITIAL_VECTOR_H_
26 #define _FSEC_PKCS_INITIAL_VECTOR_H_
27
28 #include <FBaseByteBuffer.h>
29 #include <FSecPkcsIAlgorithmParameters.h>
30 #include <FSecPkcsTypes.h>
31
32 namespace Tizen { namespace Security { namespace Pkcs
33 {
34
35 /**
36  * @class               InitialVector
37  * @brief               This class implements the functionalities specified by the InitialVector class.
38  *                                      This class represents the Initial Vector parameter for symmetric ciphers like DES, AES, DES_EDE.
39  *                                      This InitialVector Parameters will be used by both Pkcs05 and Pkcs08 related classes at the time of encryption.
40  * @since               2.1
41  *
42  *
43  */
44
45 class _OSP_EXPORT_ InitialVector
46         : public virtual IAlgorithmParameters
47         , public Tizen::Base::Object
48 {
49
50 public:
51         /**
52          * The object is not fully constructed after this constructor is called. @n
53          * For full construction, the Construct() method must be called right after calling this constructor.
54          *
55          * @since               2.1
56          */
57         InitialVector(void);
58
59         /**
60         * This destructor overrides Tizen::Base::Object::~Object().
61         *
62         * @since                2.1
63         */
64
65         virtual ~InitialVector(void);
66
67         /**
68          * Initializes this instance of %InitialVector with the specified input buffer.
69          *
70          * @since               2.1
71          *
72          * @return              An error code
73          *
74          * @param[in]   initialVector           An instance of ByteBuffer, holding the initial vector data.
75          * @exception   E_SUCCESS                               The method is successful.
76          * @exception   E_INVALID_ARG           The specified input parameter is invalid.
77          */
78         result Construct(const Tizen::Base::ByteBuffer& initialVector);
79
80         /**
81          * Get copy of this instance.
82          *
83          * @since               2.1
84          *
85          * @return              A pointer to IAlgorithmParameters, containing the copy of this instance.
86          * @remarks             The specific error code can be accessed using the GetLastResult() method.
87          */
88         virtual IAlgorithmParameters* CloneN(void) const;
89
90         /**
91          * Get the algorithm parameter type enum value for Initial Vector.
92          *
93          * @since               2.1
94          *
95          * @return              PkcsAlgorithmParameterType              Enum value  containing the PKCS_ALGO_PARAM_TYPE_IV value for Initial vector parameter.
96          *
97          */
98         virtual PkcsAlgorithmParameterType GetType(void) const;
99
100         /**
101          * Checks whether the specified instance of %InitialVector equals the current instance.
102          *
103          * @since               2.1
104          *
105          * @return              @c true if the specified instance equals the current instance, @n
106          *              else @c false
107          * @param[in]   rhs                                     An instance of %InitialVector
108          * @exception   E_SUCCESS                               The method is successful.
109          * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
110          * @remarks             The specific error code can be accessed using the GetLastResult() method.
111          */
112         virtual bool Equals(const Tizen::Base::Object& rhs) const;
113
114         /**
115          * Gets the hash value of the current instance of %InitialVector.
116          *
117          * @since               2.1
118          *
119          * @return              An integer value indicating the hash value of the current instance of %InitialVector
120          */
121         virtual int GetHashCode(void) const;
122
123         /**
124          * Get the instance of byte buffer that contains the Initial vector value.
125          *
126          * @since               2.1
127          *
128          * @return              A reference to the ByteBuffer class that contains the output.
129          */
130         const Tizen::Base::ByteBuffer& GetInitialVector(void) const;
131
132         /**
133          * Gets the encoded form of the InitialVector. @n
134          * It is assumed that each InitialVector type will have only a single form of encoding that is DER encoding.
135          *
136          * @since               2.1
137          *
138          * @return              Pointer to the DER encoded ByteBuffer, @n
139          *                                                      else @c null if an error occurs.
140          * @exception   E_SUCCESS                                               The method is successful.
141          * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
142          * @remarks             The specific error code can be accessed using the GetLastResult() method.
143          */
144         Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
145
146 private:
147         // This copy constructor is intentionally declared as private to prohibit @n
148         // copying of objects by users.
149         //
150         // @since               2.1
151         InitialVector(const InitialVector& rhs);
152
153         // The implementation of this copy assignment operator is intentionally blank and @n
154         // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
155         // Use Equals() to compare the contents of one instance with the other.
156         //
157         // @since               2.1
158         InitialVector& operator =(const InitialVector& rhs);
159
160 private:
161         class _InitialVectorImpl* __pInitialVectorImpl;
162         friend class _InitialVectorImpl;
163
164 }; // InitialVector
165
166 } } } //Tizen::Security::Pkcs
167
168 #endif //_FSEC_PKCS_INITIAL_VECTOR_H_