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 Pkcs08 PrivateKeyInfo class.
40 * This class represents the structure of Pkcs08 Private Key Info.
42 * It is defined in ASN.1 as:
44 * PrivateKeyInfo ::= SEQUENCE {
46 * privateKeyAlgorithm AlgorithmIdentifier {{PrivateKeyAlgorithms}},
47 * privateKey PrivateKey,
48 * attributes [0] Attributes OPTIONAL }
53 class _OSP_EXPORT_ Pkcs08PrivateKeyInfo
54 : public Tizen::Base::Object
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.
64 Pkcs08PrivateKeyInfo(void);
67 * This destructor overrides Tizen::Base::Object::~Object().
71 virtual ~Pkcs08PrivateKeyInfo(void);
74 * Initializes this instance of %Pkcs08PrivateKeyInfo with the encoded byte buffer which contain @n
75 * pkcs08 private key info structure(PrivateKeyInfo) in ASN.1 DER format. @n
76 * It parses this encoded buffer and extracts the appropiate values of private key, its algorithm id and attributes.
80 * @return An error code
81 * @param[in] encodedData The instance of Bytebuffer, containing DER encoded PrivateKeyInfo structure.
82 * @exception E_SUCCESS The method is successful.
83 * @exception E_INVALID_ARG The specified input parameter is invalid.
85 result Construct(const Tizen::Base::ByteBuffer& encodedData);
88 * Initializes the %Pkcs08PrivateKeyInfo with supplied input parameters values.
92 * @return An error code.
93 * @param[in] keyAlgorithmId An instance of AlgorithIdentifier, holding algorithm identifier of private key algorithm.
94 * @param[in] privateKey An instance of ByteBuffer holding privatekey.
95 * @exception E_SUCCESS The method is successful.
96 * @exception E_INVALID_ARG The specified input parameter is invalid.
98 result Construct(const AlgorithmIdentifier& keyAlgorithmId, const Tizen::Base::ByteBuffer& privateKey);
101 * This function will provide the implementation of GetVersion API to get the private key syntax version number of PrivateKeyInfo object @n
102 * that is used for storing private key and its related information and default value of this version is 0.
106 * @return An integer valuse contains the version.
109 int GetVersion(void) const;
112 * Gets the reference to AlgorithmIdentifier which identifies the secret key algorithm.
116 * @return A reference to AlgorithmIdentifier Contains the algorithm identifier of Pkcs08PrivateKeyInfo object.
117 * @remarks The specific error code can be accessed using the GetLastResult() method.
119 const AlgorithmIdentifier& GetPrivateKeyAlgorithm(void) const;
122 * This function will provide the implementation of GetPrivateKeyN API to get the reference to ByteBuffer which contains
123 * the private key in binary format.
127 * @return A reference to ByteBuffer Contains the private key of Pkcs08PrivateKeyInfo object.
128 * @remarks The specific error code can be accessed using the GetLastResult() method.
130 const Tizen::Base::ByteBuffer& GetPrivateKey(void) const;
133 * This API will provide the implementation of GetAttributes API to get the Attributes of type Pkcs08Attribute which are extended @n
134 * information of private key in context.
138 * @return Reference to array list, contains the list of attributes of type Pkcs08Attribute.
140 const Tizen::Base::Collection::ArrayList& GetAttributes(void) const;
143 * This function adds Attributes in private key info i.e. extended information of private key in context.
147 * @return An error code
148 * @param[in] attributes An instance of Pkcs08Attribute class..
150 result AddAttribute(const Pkcs08Attribute& attributes);
153 * This function remove Attribute in private key info i.e. extended information of private key in context.
157 * @return An error code
158 * @param[in] attributes An instance of Pkcs08Attribute class.
160 result RemoveAttribute(const Pkcs08Attribute& attributes);
163 * Gets the DER encoded Pkcs08PrivateKeyInfo structure.
167 * @return Pointer to ByteBuffer Contains the DER encoded private key info.
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_