Merge "Update deprecated libprivilege-control API functions." into tizen
[platform/framework/native/appfw.git] / inc / FSecPkcsAlgorithmIdentifier.h
1 //
2 // Copyright (c) 2013 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                FSecPkcsAlgorithmIdentifier.h
19  * @brief               This is the header file for the %AlgorithmIdentifier class.
20  *
21  * This header file contains the declarations of the %AlgorithmIdentifier class.
22  */
23
24 #ifndef _FSEC_PKCS_ALGORITHM_IDENTIFIER_H_
25 #define _FSEC_PKCS_ALGORITHM_IDENTIFIER_H_
26
27 #include <FBaseByteBuffer.h>
28 #include <FSecPkcsIAlgorithmParameters.h>
29
30 namespace Tizen { namespace Security { namespace Pkcs
31 {
32
33 /**
34  * @class               AlgorithmIdentifier
35  * @brief               This class implements the ASN.1 specified %AlgorithmIdentifier, which is used for
36  *                              creating the standard %AlgorithmIdentifier object.
37  *
38  * @since               2.1
39  *
40  * The %AlgorithmIdentifier class implements the ASN.1 specified %AlgorithmIdentifier, which is used for
41  * creating the standard %AlgorithmIdentifier object. The %AlgorithmIdentifier structure consists of the OID value of the 
42  * algorithm along with the parameters of the algorithm.
43  *
44  * This is defined in ASN.1 as demonstrated in the following code:
45  * @code
46  *              AlgorithmIdentifier { ALGORITHM-IDENTIFIER:InfoObjectSet }
47  *              ::=
48  *              SEQUENCE {
49  *              algorithm ALGORITHM-IDENTIFIER.&id({InfoObjectSet}),
50  *              parameters ALGORITHM-IDENTIFIER.&Type({InfoObjectSet}
51  *              {@algorithm}) OPTIONAL }
52  *              ALGORITHM-IDENTIFIER ::= TYPE-IDENTIFIER
53  * @endcode
54  *
55  */
56
57 class _OSP_EXPORT_ AlgorithmIdentifier
58         : public Tizen::Base::Object
59 {
60 public:
61         /**
62          * The object is not fully constructed after this constructor is called. @n
63          * For full construction, the Construct() method must be called right after calling this constructor.
64          *
65          * @since               2.1
66          */
67         AlgorithmIdentifier(void);
68
69         /**
70          * This destructor overrides Tizen::Base::Object::~Object().
71          *
72          * @since               2.1
73          */
74         virtual ~AlgorithmIdentifier(void);
75
76         /**
77          * Initializes the %AlgorithmIdentifier with the specified input parameter values.
78          *
79          * @since               2.1
80          *
81          * @return              An error code
82          * @param[in]   objectId                        The object identifier of a particular algorithm @n
83          *                                                                      The object IDs are defined by standard bodies for algorithms and other crypto objects. @n
84          *                                                                      The object ID of %AlgorithmIdentifier can be described in string format like 1.2.3.4
85          * @param[in]   pParams                         A pointer to the AlgorithmParameters object @n 
86          *                                                                      This is an optional parameter and contains a list of user specified input parameters for 
87          *                                                                      the specified algorithm. For example, for Symmetric algorithms Initial vector, IV is required 
88          *                                                                      as an input. The default value of this parameter is @c null.
89          * @exception   E_SUCCESS                                       The method is successful.
90          * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
91          * @exception   E_UNSUPPORTED_ALGORITHM         The object ID of the input algorithm is not supported.
92          */
93         result Construct(const Tizen::Base::String& objectId, const IAlgorithmParameters* pParams = null);
94
95         /**
96          * Initializes this instance of %AlgorithmIdentifier with the DER encoded Tizen::Base::ByteBuffer that contains
97          * the ASN.1 specified %AlgorithmIdentifier structure.
98          *
99          * @since               2.1
100          *
101          * @return              An error code
102          * @param[in]   encodedData                     An instance of DER encoded Tizen::Base::ByteBuffer
103          * @exception   E_SUCCESS                       The method is successful.
104          * @exception   E_INVALID_ARG           The specified input parameter is invalid.
105          */
106         result Construct(const Tizen::Base::ByteBuffer& encodedData);
107
108         /**
109          * Checks whether the specified instance of %AlgorithmIdentifier equals the current instance.
110          *
111          * @since               2.1
112          *
113          * @return              @c true if the specified instance equals the current instance, @n
114          *                              else @c false
115          * @param[in]   rhs                                     An instance of %AlgorithmIdentifier
116          * @exception   E_SUCCESS                       The method is successful.
117          * @exception   E_INVALID_ARG           The specified input parameter is invalid.
118          * @remarks             The specific error code can be accessed using the GetLastResult() method.
119          */
120         virtual bool Equals(const Tizen::Base::Object& rhs) const;
121
122         /**
123          * Gets the hash value of the current instance of %AlgorithmIdentifier.
124          *
125          * @since               2.1
126          *
127          * @return              An integer value indicating the hash value of the current instance of %AlgorithmIdentifier
128          */
129         virtual int GetHashCode(void) const;
130
131         /**
132          * Gets the copy of the %AlgorithmIdentifier instance.
133          *
134          * @since               2.1
135          *
136          * @return              A pointer to the %AlgorithmIdentifier instance that is the copy of the specified instance, @n
137          *                              else @c null if an error occurs
138          * @remarks             The specific error code can be accessed using the GetLastResult() method.
139          */
140         AlgorithmIdentifier* CloneN(void) const;
141
142         /**
143          * Gets the parameters of algorithm.
144          *
145          * @since               2.1
146          *
147          * @return              A pointer to the IAlgorithmParameters instance containing the parameter list of algorithm, @n
148          *                              else @c null if no parameters exist
149          * @remarks             The specific error code can be accessed using the GetLastResult() method.
150          */
151         IAlgorithmParameters* GetParametersN(void) const;
152
153         /**
154          * Gets the object ID value of an algorithm in string format.
155          *
156          * @since               2.1
157          *
158          * @return              The object ID of %AlgorithmIdentifier in string format like 1.2.3.4
159          *
160          */
161         Tizen::Base::String GetAlgorithmObjectId(void) const;
162
163         /**
164          * Gets the encoded form of the %AlgorithmIdentifier. @n
165          * It is assumed that each %AlgorithmIdentifier type will have only a single form of encoding that is DER encoding.
166          *
167          * @since               2.1
168          *
169          * @return              A pointer to the DER encoded Tizen::Base::ByteBuffer, @n
170          *                              else @c null if an error occurs
171          * @exception   E_SUCCESS                                               The method is successful.
172          * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
173          * @remarks             The specific error code can be accessed using the GetLastResult() method.
174          */
175         Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
176
177 private:
178         // This copy constructor is intentionally declared as private to prohibit @n
179         // copying of objects by users.
180         //
181         // @since               2.1
182         AlgorithmIdentifier(const AlgorithmIdentifier& rhs);
183
184         // The implementation of this copy assignment operator is intentionally blank and @n
185         // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
186         // Use Equals() to compare the contents of one instance with the other.
187         //
188         // @since               2.1
189         AlgorithmIdentifier& operator =(const AlgorithmIdentifier& rhs);
190
191 private:
192         class _AlgorithmIdentifierImpl* __pAlgorithmIdentifierImpl;
193         friend class _AlgorithmIdentifierImpl;
194 }; // AlgorithmIdentifier
195
196 } } } // Tizen::Security::Pkcs
197
198 #endif //_FSEC_PKCS_ALGORITHM_IDENTIFIER_H_