update doxygen comments
[platform/framework/native/appfw.git] / inc / FSecPkcsPkcs08EncryptedPrivateKeyInfo.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                FSecPkcsPkcs08EncryptedPrivateKeyInfo.h
20  * @brief               This is the header file for the %Pkcs08EncryptedPrivateKeyInfo class.
21  *
22  * This header file contains the declarations of the %Pkcs08EncryptedPrivateKeyInfo class.
23  */
24
25 #ifndef _FSEC_PKCS_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_
26 #define _FSEC_PKCS_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_
27
28 #include <FBaseByteBuffer.h>
29 #include <FSecPkcsAlgorithmIdentifier.h>
30
31 namespace Tizen { namespace Security { namespace Pkcs
32 {
33
34 /**
35  * @class               Pkcs08EncryptedPrivateKeyInfo
36  * @brief               This class provides methods to encrypt a private key.
37  *
38  * @since               2.1
39  *
40  * The %Pkcs08EncryptedPrivateKeyInfo class provides methods to encrypt a private key. An encrypted private key structure consist
41  *                                      of an encryption algorithm and the encrypted Pkcs08PrivateKeyInfo.
42  *
43  *                              This is defined in ASN.1 as demonstrated in the following code:
44  * @code
45  *                              EncryptedPrivateKeyInfo ::= SEQUENCE {
46  *                              encryptionAlgorithm AlgorithmIdentifier {{KeyEncryptionAlgorithms}},
47  *                              encryptedData EncryptedData
48  *                              }
49  * @endcode
50  */
51
52 class _OSP_EXPORT_ Pkcs08EncryptedPrivateKeyInfo
53 {
54
55 public:
56         /**
57          * The object is not fully constructed after this constructor is called. @n
58          * For full construction, the Construct() method must be called right after calling this constructor.
59          *
60          * @since               2.1
61          */
62         Pkcs08EncryptedPrivateKeyInfo(void);
63
64         /**
65          * This destructor overrides Tizen::Base::Object::~Object().
66          *
67          * @since               2.1
68          */
69         virtual ~Pkcs08EncryptedPrivateKeyInfo(void);
70
71         /**
72          * Initializes this instance of %Pkcs08EncryptedPrivateKeyInfo with the encoded Tizen::Base::ByteBuffer that contains  @n
73          * the EncryptedPrivateKeyInfo structure(EncryptedPrivateKeyInfo) in ASN.1 DER format.
74          *
75          * @since               2.1
76          *
77          * @return              An error code
78          * @param[in]   encodedData                                     The DER encoded Tizen::Base::ByteBuffer that contains the Pkcs08 EncryptedPrivateKeyInfo structure
79          * @exception   E_SUCCESS                                               The method is successful.
80          * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
81          */
82         result Construct(const Tizen::Base::ByteBuffer& encodedData);
83
84         /**
85          * Initializes this instance of %Pkcs08EncryptedPrivateKeyInfo with the values of the specified input parameters.
86          *
87          * @since               2.1
88          *
89          * @return              An error code
90          * @param[in]   algorithmId                                     An instance of AlgorithmIdentifier
91          * @param[in]   encryptedData                           An encrypted private key
92          * @exception   E_SUCCESS                                               The method is successful.
93          * @exception   E_INVALID_ARG                           A specified input parameter is invalid.
94          */
95         result Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& encryptedData);
96
97         /**
98          * Initializes this instance of %Pkcs08EncryptedPrivateKeyInfo with the values of the specified input parameters.
99          *
100          * @since               2.1
101          *
102          * @return              An error code
103          * @param[in]   algorithmId                                             An instance of AlgorithmIdentifier that identifies the secret key algorithm
104          * @param[in]   key                                                                             The key for encrypting privateKeyInfo
105          * @param[in]   encodedPrivateKeyInfo   An instance of Tizen::Base::ByteBuffer containing encoded privateKeyInfo
106          * @exception   E_SUCCESS                                                       The method is successful.
107          * @exception   E_INVALID_ARG                                   A specified input parameter is invalid.
108          *
109          */
110         result Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& key, const Tizen::Base::ByteBuffer& encodedPrivateKeyInfo);
111
112         /**
113          * Gets a reference to AlgorithmIdentifier that identifies the encryption algorithm under which the private key is encrypted.
114          *
115          * @since               2.1
116          *
117          * @return              A reference to AlgorithmIdentifier that contains the algorithm identifier of %Pkcs08EncryptedPrivateKeyInfo object
118          * @remarks             The specific error code can be accessed using the GetLastResult() method.
119          */
120         const AlgorithmIdentifier& GetAlgorithm(void) const;
121
122         /**
123          * Gets a pointer to Tizen::Base::ByteBuffer that contains the encrypted private key.
124          *
125          * @since               2.1
126          *
127          * @return              A pointer to Tizen::Base::ByteBuffer class that contains the private key of the %Pkcs08EncryptedPrivateKeyInfo object, @n
128          *                              else @c null if an error occurs
129          * @remarks             The specific error code can be accessed using the GetLastResult() method.
130          */
131         Tizen::Base::ByteBuffer* GetEncryptedDataN(void) const;
132
133         /**
134          * Decrypts the %Pkcs08EncryptedPrivateKeyInfo object using a key or password.
135          *
136          * @since               2.1
137          *
138          * @return              A pointer to Tizen::Base::ByteBuffer that contains the decrypted private key of the %Pkcs08EncryptedPrivateKeyInfo object, @n
139          *                              else @c null if an error occurs
140          * @param[in]   key                             An instance of Tizen::Base::ByteBuffer holding a key to decrypt the private key using a particular @n
141          *                                                                                      secret key algorithm
142          * @exception   E_SUCCESS                                               The method is successful.
143          * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
144          * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
145          * @remarks             The specific error code can be accessed using the GetLastResult() method.
146          */
147         Tizen::Base::ByteBuffer* DecryptN(const Tizen::Base::ByteBuffer& key);
148
149         /**
150          * Gets the ASN.1 DER encoded pkcs08 encrypted private key structure.
151          *
152          * @since               2.1
153          *
154          * @return              A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
155          *                                              else @c null if an error occurs
156          * @exception   E_SUCCESS                                               The method is successful.
157          * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
158          * @remarks             The specific error code can be accessed using the GetLastResult() method.
159          */
160         Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
161
162 private:
163         // This copy constructor is intentionally declared as private to prohibit @n
164         // copying of objects by users.
165         //
166         // @since               2.1
167         Pkcs08EncryptedPrivateKeyInfo(const Pkcs08EncryptedPrivateKeyInfo& rhs);
168
169         // The implementation of this copy assignment operator is intentionally blank and @n
170         // declared as private to prohibit copying of objects.
171         //
172         // @since               2.1
173         Pkcs08EncryptedPrivateKeyInfo& operator =(const Pkcs08EncryptedPrivateKeyInfo& rhs);
174
175 private:
176         class _Pkcs08EncryptedPrivateKeyInfoImpl* __pPkcs08EncryptedPrivateKeyInfoImpl;
177         friend class _Pkcs08EncryptedPrivateKeyInfoImpl;
178
179
180 }; //Pkcs08EncryptedPrivateKeyInfo
181
182 }}} // Tizen::Security::Pkcs
183
184 #endif // _FSEC_PKCS_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_