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