e67efab6a963000cef8042263528dff950904200
[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.
42  *              %AlgorithmIdentifier structure consists the OID value of the algorithm along with the parameters of that 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 supplied 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          *                                                                      Object IDs are defined by standard bodies for algorithms and other crypto objects.
84          *                                                                      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 the specified algorithm. For example, for Symmetric algorithms Initial vector, IV is required as an input. The default value of this parameter is @c null.
87          * @exception   E_SUCCESS                                               The method is successful.
88          * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
89          * @exception   E_UNSUPPORTED_ALGORITHM         The object ID of the input algorithm is not supported.
90          */
91         result Construct(const Tizen::Base::String& objectId, const IAlgorithmParameters* pParams = null);
92
93         /**
94          * Initializes this instance of %AlgorithmIdentifier with the DER encoded Tizen::Base::ByteBuffer that contains @n
95          * the ASN.1 specified %AlgorithmIdentifier structure.
96          *
97          * @since               2.1
98          *
99          * @return              An error code
100          * @param[in]   encodedData                                     An instance of DER encoded Tizen::Base::ByteBuffer
101          * @exception   E_SUCCESS                                               The method is successful.
102          * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
103          */
104         result Construct(const Tizen::Base::ByteBuffer& encodedData);
105
106         /**
107          * Checks whether the specified instance of %AlgorithmIdentifier equals the current instance.
108          *
109          * @since                       2.1
110          *
111          * @return              @c true if the specified instance equals the current instance, @n
112          *            else @c false
113          * @param[in]   rhs                                                                     An instance of %AlgorithmIdentifier
114          * @exception   E_SUCCESS                               The method is successful.
115          * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
116          * @remarks             The specific error code can be accessed using the GetLastResult() method.
117          */
118         virtual bool Equals(const Tizen::Base::Object& rhs) const;
119
120         /**
121          * Gets the hash value of the current instance of %AlgorithmIdentifier.
122          *
123          * @since               2.1
124          *
125          * @return              An integer value indicating the hash value of the current instance of %AlgorithmIdentifier
126          */
127         virtual int GetHashCode(void) const;
128
129         /**
130          * Gets the copy of %AlgorithmIdentifier instance.
131          *
132          * @since               2.1
133          *
134          * @return              Pointer to %AlgorithmIdentifier, containing the copy of the specified instance, @n
135          *                                              else @c null if an error occurs
136          * @remarks             The specific error code can be accessed using the GetLastResult() method.
137          */
138         AlgorithmIdentifier* CloneN(void) const;
139
140         /**
141          * Gets the parameters of algorithm.
142          *
143          * @since               2.1
144          *
145          * @return              Pointer to IAlgorithmParameters, containing the parameter list of algorithm, @n
146          *                                              else @c null if an no parameters exist
147          * @remarks             The specific error code can be accessed using the GetLastResult() method.
148          */
149         IAlgorithmParameters* GetParametersN(void) const;
150
151         /**
152          * Gets the object ID value of an algorithm in string format.
153          *
154          * @since                       2.1
155          *
156          * @return              Object ID of %AlgorithmIdentifier in string format like 1.2.3.4
157          *
158          */
159         Tizen::Base::String GetAlgorithmObjectId(void) const;
160
161         /**
162          * Gets the encoded form of the %AlgorithmIdentifier. @n
163          * It is assumed that each %AlgorithmIdentifier type will have only a single form of encoding that is DER encoding.
164          *
165          * @since               2.1
166          *
167          * @return              Pointer to the DER encoded Tizen::Base::ByteBuffer, @n
168          *                                              else @c null if an error occurs
169          * @exception   E_SUCCESS                                               The method is successful.
170          * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
171          * @remarks             The specific error code can be accessed using the GetLastResult() method.
172          */
173         Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
174
175 private:
176         // This copy constructor is intentionally declared as private to prohibit @n
177         // copying of objects by users.
178         //
179         // @since               2.1
180         AlgorithmIdentifier(const AlgorithmIdentifier& rhs);
181
182         // The implementation of this copy assignment operator is intentionally blank and @n
183         // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
184         // Use Equals() to compare the contents of one instance with the other.
185         //
186         // @since               2.1
187         AlgorithmIdentifier& operator =(const AlgorithmIdentifier& rhs);
188
189 private:
190         class _AlgorithmIdentifierImpl* __pAlgorithmIdentifierImpl;
191         friend class _AlgorithmIdentifierImpl;
192 }; // AlgorithmIdentifier
193
194 } } } // Tizen::Security::Pkcs
195
196 #endif //_FSEC_PKCS_ALGORITHM_IDENTIFIER_H_