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