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 FSecPkcsPkcs08PrivateKeyInfo.h
19 * @brief This is the header file for the %Pkcs08PrivateKeyInfo class.
21 * This header file contains the declarations of the %Pkcs08PrivateKeyInfo class.
24 #ifndef _FSEC_PKCS_PKCS_08_PRIVATE_KEY_INFO_H_
25 #define _FSEC_PKCS_PKCS_08_PRIVATE_KEY_INFO_H_
27 #include <FBaseByteBuffer.h>
28 #include <FSecPkcsAlgorithmIdentifier.h>
29 #include <FSecPkcsPkcs08Attribute.h>
30 #include <FSecPkcsPkcs08AttributeValue.h>
33 namespace Tizen { namespace Security { namespace Pkcs
37 * @class Pkcs08PrivateKeyInfo
38 * @brief This class implements the functionalities specified by the %Pkcs08PrivateKeyInfo class.
42 * The %Pkcs08PrivateKeyInfo class implements the functionalities specified by the %Pkcs08PrivateKeyInfo class.
43 * This class represents the structure of Pkcs08 Private Key Info.
45 * This is defined in ASN.1 as demonstrated in the following code:
47 * PrivateKeyInfo ::= SEQUENCE {
49 * privateKeyAlgorithm AlgorithmIdentifier {{PrivateKeyAlgorithms}},
50 * privateKey PrivateKey,
51 * attributes [0] Attributes OPTIONAL }
55 class _OSP_EXPORT_ Pkcs08PrivateKeyInfo
56 : public Tizen::Base::Object
61 * The object is not fully constructed after this constructor is called. @n
62 * For full construction, the Construct() method must be called right after calling this constructor.
66 Pkcs08PrivateKeyInfo(void);
69 * This destructor overrides Tizen::Base::Object::~Object().
73 virtual ~Pkcs08PrivateKeyInfo(void);
76 * Initializes this instance of %Pkcs08PrivateKeyInfo with the encoded byte buffer that contains pkcs08 private key info
77 * structure(PrivateKeyInfo) in ASN.1 DER format. @n
78 * It parses this encoded buffer and extracts the appropriate values of private key, its algorithm ID, and attributes.
82 * @return An error code
83 * @param[in] encodedData An instance of Tizen::Base::ByteBuffer containing DER encoded PrivateKeyInfo structure
84 * @exception E_SUCCESS The method is successful.
85 * @exception E_INVALID_ARG The specified input parameter is invalid.
87 result Construct(const Tizen::Base::ByteBuffer& encodedData);
90 * Initializes this instance of %Pkcs08PrivateKeyInfo with the values of the specified input parameters.
94 * @return An error code.
95 * @param[in] keyAlgorithmId An instance of AlgorithmIdentifier holding the algorithm identifier of the private key algorithm
96 * @param[in] privateKey An instance of Tizen::Base::ByteBuffer holding the private key
97 * @exception E_SUCCESS The method is successful.
98 * @exception E_INVALID_ARG A specified input parameter is invalid.
100 result Construct(const AlgorithmIdentifier& keyAlgorithmId, const Tizen::Base::ByteBuffer& privateKey);
103 * Gets the private key syntax version number of PrivateKeyInfo object that is used for storing private key and its related
104 * information and default value of this version is @c 0.
108 * @return An integer value that contains the version
111 int GetVersion(void) const;
114 * Gets a reference to AlgorithmIdentifier that identifies the secret key algorithm.
118 * @return A reference to AlgorithmIdentifier that contains the algorithm identifier of the %Pkcs08PrivateKeyInfo object
119 * @remarks The specific error code can be accessed using the GetLastResult() method.
121 const AlgorithmIdentifier& GetPrivateKeyAlgorithm(void) const;
124 * Gets a reference to Tizen::Base::ByteBuffer that contains the private key in binary format.
128 * @return A reference to Tizen::Base::ByteBuffer that contains the private key of the %Pkcs08PrivateKeyInfo object
129 * @remarks The specific error code can be accessed using the GetLastResult() method.
131 const Tizen::Base::ByteBuffer& GetPrivateKey(void) const;
134 * Gets the attributes of the type Pkcs08Attribute that are the extended information of the private key in context.
138 * @return A reference to Tizen::Base::Collection::ArrayList that contains the list of attributes of type Pkcs08Attribute
140 const Tizen::Base::Collection::ArrayList& GetAttributes(void) const;
143 * Adds the attributes in private key information that is the extended information of the private key in context.
147 * @return An error code
148 * @param[in] attributes An instance of Pkcs08Attribute
150 result AddAttribute(const Pkcs08Attribute& attributes);
153 * Removes the attributes from the private key information that is the extended information of the private key in context.
157 * @return An error code
158 * @param[in] attributes An instance of Pkcs08Attribute
160 result RemoveAttribute(const Pkcs08Attribute& attributes);
163 * Gets the DER encoded %Pkcs08PrivateKeyInfo structure.
167 * @return A pointer to Tizen::Base::ByteBuffer that contains the DER encoded private key information
168 * @exception E_SUCCESS The method is successful.
169 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
170 * @remarks The specific error code can be accessed using the GetLastResult() method.
172 Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
175 // This copy constructor is intentionally declared as private to prohibit @n
176 // copying of objects by users.
179 Pkcs08PrivateKeyInfo(const Pkcs08PrivateKeyInfo& rhs);
181 // The implementation of this copy assignment operator is intentionally blank and @n
182 // declared as private to prohibit copying of objects.
185 Pkcs08PrivateKeyInfo& operator =(const Pkcs08PrivateKeyInfo& rhs);
188 class _Pkcs08PrivateKeyInfoImpl* __pPkcs08PrivateKeyInfoImpl;
189 friend class _Pkcs08PrivateKeyInfoImpl;
191 }; //Pkcs08PrivateKeyInfo
193 }}} // Tizen::Security::Pkcs
195 #endif // _FSEC_PKCS_PKCS_08_PRIVATE_KEY_INFO_H_