2 // Open Service Platform
3 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FSecPkcsPkcs08PrivateKeyInfo.h
20 * @brief This is the header file for the %Pkcs08PrivateKeyInfo class.
22 * This header file contains the declarations of the %Pkcs08PrivateKeyInfo class.
25 #ifndef _FSEC_PKCS_PKCS_08_PRIVATE_KEY_INFO_H_
26 #define _FSEC_PKCS_PKCS_08_PRIVATE_KEY_INFO_H_
28 #include <FBaseByteBuffer.h>
29 #include <FSecPkcsAlgorithmIdentifier.h>
30 #include <FSecPkcsPkcs08Attribute.h>
31 #include <FSecPkcsPkcs08AttributeValue.h>
34 namespace Tizen { namespace Security { namespace Pkcs
38 * @class Pkcs08PrivateKeyInfo
39 * @brief This class implements the functionalities specified by the %Pkcs08PrivateKeyInfo class.
43 * The %Pkcs08PrivateKeyInfo class implements the functionalities specified by the %Pkcs08PrivateKeyInfo class.
44 * This class represents the structure of Pkcs08 Private Key Info.
46 * This is defined in ASN.1 as demonstrated in the following code:
48 * PrivateKeyInfo ::= SEQUENCE {
50 * privateKeyAlgorithm AlgorithmIdentifier {{PrivateKeyAlgorithms}},
51 * privateKey PrivateKey,
52 * attributes [0] Attributes OPTIONAL }
56 class _OSP_EXPORT_ Pkcs08PrivateKeyInfo
57 : 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 Pkcs08PrivateKeyInfo(void);
70 * This destructor overrides Tizen::Base::Object::~Object().
74 virtual ~Pkcs08PrivateKeyInfo(void);
77 * Initializes this instance of %Pkcs08PrivateKeyInfo with the encoded byte buffer that contains @n
78 * pkcs08 private key info structure(PrivateKeyInfo) in ASN.1 DER format. @n
79 * It parses this encoded buffer and extracts the appropiate values of private key, its algorithm ID, and attributes.
83 * @return An error code
84 * @param[in] encodedData An instance of Tizen::Base::Bytebuffer containing DER encoded PrivateKeyInfo structure
85 * @exception E_SUCCESS The method is successful.
86 * @exception E_INVALID_ARG The specified input parameter is invalid.
88 result Construct(const Tizen::Base::ByteBuffer& encodedData);
91 * Initializes this instance of %Pkcs08PrivateKeyInfo with the values of the specified input parameters.
95 * @return An error code.
96 * @param[in] keyAlgorithmId An instance of AlgorithmIdentifier holding algorithm identifier of the private key algorithm
97 * @param[in] privateKey An instance of Tizen::Base::ByteBuffer holding private key
98 * @exception E_SUCCESS The method is successful.
99 * @exception E_INVALID_ARG A specified input parameter is invalid.
101 result Construct(const AlgorithmIdentifier& keyAlgorithmId, const Tizen::Base::ByteBuffer& privateKey);
104 * Gets the private key syntax version number of PrivateKeyInfo object @n
105 * that is used for storing private key and its related information and default value of this version is @c 0.
109 * @return An integer value that contains the version
112 int GetVersion(void) const;
115 * Gets the reference to AlgorithmIdentifier that identifies the secret key algorithm.
119 * @return A reference to AlgorithmIdentifier that contains the algorithm identifier of the %Pkcs08PrivateKeyInfo object
120 * @remarks The specific error code can be accessed using the GetLastResult() method.
122 const AlgorithmIdentifier& GetPrivateKeyAlgorithm(void) const;
125 * Gets the reference to Tizen::Base::ByteBuffer that contains the private key in binary format.
129 * @return A reference to Tizen::Base::ByteBuffer that contains the private key of the %Pkcs08PrivateKeyInfo object
130 * @remarks The specific error code can be accessed using the GetLastResult() method.
132 const Tizen::Base::ByteBuffer& GetPrivateKey(void) const;
135 * Gets the attributes of the type Pkcs08Attribute that are extended information of the private key in context.
139 * @return A reference to Tizen::Base::Collection::ArrayList that contains the list of attributes of type Pkcs08Attribute
141 const Tizen::Base::Collection::ArrayList& GetAttributes(void) const;
144 * Adds the attributes in private key information that is extended information of the private key in context.
148 * @return An error code
149 * @param[in] attributes An instance of Pkcs08Attribute
151 result AddAttribute(const Pkcs08Attribute& attributes);
154 * Removes the attribute in private key information that is extended information of the private key in context.
158 * @return An error code
159 * @param[in] attributes An instance of Pkcs08Attribute
161 result RemoveAttribute(const Pkcs08Attribute& attributes);
164 * Gets the DER encoded %Pkcs08PrivateKeyInfo structure.
168 * @return A pointer to Tizen::Base::ByteBuffer that contains the DER encoded private key information
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 Pkcs08PrivateKeyInfo(const Pkcs08PrivateKeyInfo& rhs);
182 // The implementation of this copy assignment operator is intentionally blank and @n
183 // declared as private to prohibit copying of objects.
186 Pkcs08PrivateKeyInfo& operator =(const Pkcs08PrivateKeyInfo& rhs);
189 class _Pkcs08PrivateKeyInfoImpl* __pPkcs08PrivateKeyInfoImpl;
190 friend class _Pkcs08PrivateKeyInfoImpl;
192 }; //Pkcs08PrivateKeyInfo
194 }}} // Tizen::Security::Pkcs
196 #endif // _FSEC_PKCS_PKCS_08_PRIVATE_KEY_INFO_H_