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