Move system-server under server/system.
[platform/framework/native/appfw.git] / inc / FSecPkcsPkcs08PrivateKeyInfo.h
1 //
2 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 //
16
17 /**
18  * @file                FSecPkcsPkcs08PrivateKeyInfo.h
19  * @brief               This is the header file for the %Pkcs08PrivateKeyInfo class.
20  *
21  * This header file contains the declarations of the %Pkcs08PrivateKeyInfo class.
22  */
23
24 #ifndef _FSEC_PKCS_PKCS_08_PRIVATE_KEY_INFO_H_
25 #define _FSEC_PKCS_PKCS_08_PRIVATE_KEY_INFO_H_
26
27 #include <FBaseByteBuffer.h>
28 #include <FSecPkcsAlgorithmIdentifier.h>
29 #include <FSecPkcsPkcs08Attribute.h>
30 #include <FSecPkcsPkcs08AttributeValue.h>
31
32
33 namespace Tizen { namespace Security { namespace Pkcs
34 {
35
36 /**
37  * @class               Pkcs08PrivateKeyInfo
38  * @brief               This class implements the functionalities specified by the %Pkcs08PrivateKeyInfo class.
39  *
40  * @since               2.1
41  *
42  * The %Pkcs08PrivateKeyInfo class implements the functionalities specified by the %Pkcs08PrivateKeyInfo class.
43  * This class represents the structure of Pkcs08 Private Key Info.
44  *
45  * This is defined in ASN.1 as demonstrated in the following code:
46  * @code
47  *                              PrivateKeyInfo ::= SEQUENCE {
48  *                              version Version,
49  *                              privateKeyAlgorithm AlgorithmIdentifier {{PrivateKeyAlgorithms}},
50  *                              privateKey PrivateKey,
51  *                              attributes [0] Attributes OPTIONAL }
52  * @endcode
53  */
54
55 class _OSP_EXPORT_ Pkcs08PrivateKeyInfo
56         : public Tizen::Base::Object
57 {
58
59 public:
60         /**
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.
63          *
64          * @since               2.1
65          */
66         Pkcs08PrivateKeyInfo(void);
67
68         /**
69          * This destructor overrides Tizen::Base::Object::~Object().
70          *
71          * @since               2.1
72          */
73         virtual ~Pkcs08PrivateKeyInfo(void);
74
75         /**
76          * Initializes this instance of %Pkcs08PrivateKeyInfo with the encoded byte buffer that contains  @n
77          * pkcs08 private key info 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.
79          *
80          * @since               2.1
81          *
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.
86          */
87         result Construct(const Tizen::Base::ByteBuffer& encodedData);
88
89         /**
90          * Initializes this instance of %Pkcs08PrivateKeyInfo with the values of the specified input parameters.
91          *
92          * @since               2.1
93          *
94          * @return              An error code.
95          * @param[in]   keyAlgorithmId                  An instance of AlgorithmIdentifier holding algorithm identifier of the private key algorithm
96          * @param[in]   privateKey                                      An instance of Tizen::Base::ByteBuffer holding private key
97          * @exception   E_SUCCESS                                               The method is successful.
98          * @exception   E_INVALID_ARG                           A specified input parameter is invalid.
99          */
100         result Construct(const AlgorithmIdentifier& keyAlgorithmId, const Tizen::Base::ByteBuffer& privateKey);
101
102         /**
103          * Gets the private key syntax version number of PrivateKeyInfo object @n
104          * that is used for storing private key and its related information and default value of this version is @c 0.
105          *
106          * @since               2.1
107          *
108          * @return              An integer value that contains the version
109          *
110          */
111         int GetVersion(void) const;
112
113         /**
114          * Gets the reference to AlgorithmIdentifier that identifies the secret key algorithm.
115          *
116          * @since               2.1
117          *
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.
120          */
121         const AlgorithmIdentifier& GetPrivateKeyAlgorithm(void) const;
122
123         /**
124          * Gets the reference to Tizen::Base::ByteBuffer that contains the private key in binary format.
125          *
126          * @since               2.1
127          *
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.
130          */
131         const Tizen::Base::ByteBuffer& GetPrivateKey(void) const;
132
133         /**
134          * Gets the attributes of the type Pkcs08Attribute that are extended information of the private key in context.
135          *
136          * @since               2.1
137          *
138          * @return              A reference to Tizen::Base::Collection::ArrayList that contains the list of attributes of type Pkcs08Attribute
139          */
140         const Tizen::Base::Collection::ArrayList& GetAttributes(void) const;
141
142         /**
143          * Adds the attributes in private key information that is extended information of the private key in context.
144          *
145          * @since               2.1
146          *
147          * @return              An error code
148          * @param[in]   attributes                                      An instance of Pkcs08Attribute
149          */
150         result AddAttribute(const Pkcs08Attribute& attributes);
151
152         /**
153          * Removes the attribute in private key information that is extended information of the private key in context.
154          *
155          * @since               2.1
156          *
157          * @return              An error code
158          * @param[in]   attributes                                      An instance of Pkcs08Attribute
159          */
160         result RemoveAttribute(const Pkcs08Attribute& attributes);      
161         
162         /**
163          * Gets the DER encoded %Pkcs08PrivateKeyInfo structure.
164          *
165          * @since               2.1
166          *
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.
171          */
172         Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
173
174 private:
175         // This copy constructor is intentionally declared as private to prohibit @n
176         // copying of objects by users.
177         //
178         // @since               2.1
179         Pkcs08PrivateKeyInfo(const Pkcs08PrivateKeyInfo& rhs);
180
181         // The implementation of this copy assignment operator is intentionally blank and @n
182         // declared as private to prohibit copying of objects.
183         //
184         // @since               2.1
185         Pkcs08PrivateKeyInfo& operator =(const Pkcs08PrivateKeyInfo& rhs);
186
187 private:
188         class _Pkcs08PrivateKeyInfoImpl* __pPkcs08PrivateKeyInfoImpl;
189         friend class _Pkcs08PrivateKeyInfoImpl;
190
191 }; //Pkcs08PrivateKeyInfo
192
193 }}} // Tizen::Security::Pkcs
194
195 #endif // _FSEC_PKCS_PKCS_08_PRIVATE_KEY_INFO_H_