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