2 // Open Service Platform
3 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FSecPkcsPkcs08EncryptedPrivateKeyInfo.h
20 * @brief This is the header file for the %Pkcs08EncryptedPrivateKeyInfo class.
22 * This header file contains the declarations of the %Pkcs08EncryptedPrivateKeyInfo class.
25 #ifndef _FSEC_PKCS_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_
26 #define _FSEC_PKCS_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_
28 #include <FBaseByteBuffer.h>
29 #include <FSecPkcsAlgorithmIdentifier.h>
31 namespace Tizen { namespace Security { namespace Pkcs
35 * @class Pkcs08EncryptedPrivateKeyInfo
36 * @brief This class provides methods to encrypt a private key.
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.
43 * This is defined in ASN.1 as demonstrated in the following code:
45 * EncryptedPrivateKeyInfo ::= SEQUENCE {
46 * encryptionAlgorithm AlgorithmIdentifier {{KeyEncryptionAlgorithms}},
47 * encryptedData EncryptedData
52 class _OSP_EXPORT_ Pkcs08EncryptedPrivateKeyInfo
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.
62 Pkcs08EncryptedPrivateKeyInfo(void);
65 * This destructor overrides Tizen::Base::Object::~Object().
69 virtual ~Pkcs08EncryptedPrivateKeyInfo(void);
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.
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.
82 result Construct(const Tizen::Base::ByteBuffer& encodedData);
85 * Initializes this instance of %Pkcs08EncryptedPrivateKeyInfo with the values of the specified input parameters.
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.
95 result Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& encryptedData);
98 * Initializes this instance of %Pkcs08EncryptedPrivateKeyInfo with the values of the specified input parameters.
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.
110 result Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& key, const Tizen::Base::ByteBuffer& encodedPrivateKeyInfo);
113 * Gets a reference to AlgorithmIdentifier that identifies the encryption algorithm under which the private key is encrypted.
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.
120 const AlgorithmIdentifier& GetAlgorithm(void) const;
123 * Gets a pointer to Tizen::Base::ByteBuffer that contains the encrypted private key.
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.
131 Tizen::Base::ByteBuffer* GetEncryptedDataN(void) const;
134 * Decrypts the %Pkcs08EncryptedPrivateKeyInfo object using a key or password.
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.
147 Tizen::Base::ByteBuffer* DecryptN(const Tizen::Base::ByteBuffer& key);
150 * Gets the ASN.1 DER encoded pkcs08 encrypted private key structure.
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.
160 Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
163 // This copy constructor is intentionally declared as private to prohibit @n
164 // copying of objects by users.
167 Pkcs08EncryptedPrivateKeyInfo(const Pkcs08EncryptedPrivateKeyInfo& rhs);
169 // The implementation of this copy assignment operator is intentionally blank and @n
170 // declared as private to prohibit copying of objects.
173 Pkcs08EncryptedPrivateKeyInfo& operator =(const Pkcs08EncryptedPrivateKeyInfo& rhs);
176 class _Pkcs08EncryptedPrivateKeyInfoImpl* __pPkcs08EncryptedPrivateKeyInfoImpl;
177 friend class _Pkcs08EncryptedPrivateKeyInfoImpl;
180 }; //Pkcs08EncryptedPrivateKeyInfo
182 }}} // Tizen::Security::Pkcs
184 #endif // _FSEC_PKCS_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_