2 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FSecPkcsAlgorithmIdentifier.h
19 * @brief This is the header file for the %AlgorithmIdentifier class.
21 * This header file contains the declarations of the %AlgorithmIdentifier class.
24 #ifndef _FSEC_PKCS_ALGORITHM_IDENTIFIER_H_
25 #define _FSEC_PKCS_ALGORITHM_IDENTIFIER_H_
27 #include <FBaseByteBuffer.h>
28 #include <FSecPkcsIAlgorithmParameters.h>
30 namespace Tizen { namespace Security { namespace Pkcs
34 * @class AlgorithmIdentifier
35 * @brief This class implements the ASN.1 specified %AlgorithmIdentifier, which is used for
36 * creating the standard %AlgorithmIdentifier object.
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.
44 * This is defined in ASN.1 as demonstrated in the following code:
46 * AlgorithmIdentifier { ALGORITHM-IDENTIFIER:InfoObjectSet }
49 * algorithm ALGORITHM-IDENTIFIER.&id({InfoObjectSet}),
50 * parameters ALGORITHM-IDENTIFIER.&Type({InfoObjectSet}
51 * {@algorithm}) OPTIONAL }
52 * ALGORITHM-IDENTIFIER ::= TYPE-IDENTIFIER
57 class _OSP_EXPORT_ AlgorithmIdentifier
58 : public Tizen::Base::Object
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.
67 AlgorithmIdentifier(void);
70 * This destructor overrides Tizen::Base::Object::~Object().
74 virtual ~AlgorithmIdentifier(void);
77 * Initializes the %AlgorithmIdentifier with supplied input parameter values.
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.
91 result Construct(const Tizen::Base::String& objectId, const IAlgorithmParameters* pParams = null);
94 * Initializes this instance of %AlgorithmIdentifier with the DER encoded Tizen::Base::ByteBuffer that contains @n
95 * the ASN.1 specified %AlgorithmIdentifier structure.
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.
104 result Construct(const Tizen::Base::ByteBuffer& encodedData);
107 * Checks whether the specified instance of %AlgorithmIdentifier equals the current instance.
111 * @return @c true if the specified instance equals the current instance, @n
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.
118 virtual bool Equals(const Tizen::Base::Object& rhs) const;
121 * Gets the hash value of the current instance of %AlgorithmIdentifier.
125 * @return An integer value indicating the hash value of the current instance of %AlgorithmIdentifier
127 virtual int GetHashCode(void) const;
130 * Gets the copy of %AlgorithmIdentifier instance.
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.
138 AlgorithmIdentifier* CloneN(void) const;
141 * Gets the parameters of algorithm.
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.
149 IAlgorithmParameters* GetParametersN(void) const;
152 * Gets the object ID value of an algorithm in string format.
156 * @return Object ID of %AlgorithmIdentifier in string format like 1.2.3.4
159 Tizen::Base::String GetAlgorithmObjectId(void) const;
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.
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.
173 Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
176 // This copy constructor is intentionally declared as private to prohibit @n
177 // copying of objects by users.
180 AlgorithmIdentifier(const AlgorithmIdentifier& rhs);
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.
187 AlgorithmIdentifier& operator =(const AlgorithmIdentifier& rhs);
190 class _AlgorithmIdentifierImpl* __pAlgorithmIdentifierImpl;
191 friend class _AlgorithmIdentifierImpl;
192 }; // AlgorithmIdentifier
194 } } } // Tizen::Security::Pkcs
196 #endif //_FSEC_PKCS_ALGORITHM_IDENTIFIER_H_