2 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FSecPkcsPkcs08EncryptedPrivateKeyInfo.h
19 * @brief This is the header file for the %Pkcs08EncryptedPrivateKeyInfo class.
21 * This header file contains the declarations of the %Pkcs08EncryptedPrivateKeyInfo class.
24 #ifndef _FSEC_PKCS_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_
25 #define _FSEC_PKCS_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_
27 #include <FBaseByteBuffer.h>
28 #include <FSecPkcsAlgorithmIdentifier.h>
30 namespace Tizen { namespace Security { namespace Pkcs
34 * @class Pkcs08EncryptedPrivateKeyInfo
35 * @brief This class provides methods to encrypt a private key.
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.
42 * This is defined in ASN.1 as demonstrated in the following code:
44 * EncryptedPrivateKeyInfo ::= SEQUENCE {
45 * encryptionAlgorithm AlgorithmIdentifier {{KeyEncryptionAlgorithms}},
46 * encryptedData EncryptedData
51 class _OSP_EXPORT_ Pkcs08EncryptedPrivateKeyInfo
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.
61 Pkcs08EncryptedPrivateKeyInfo(void);
64 * This destructor overrides Tizen::Base::Object::~Object().
68 virtual ~Pkcs08EncryptedPrivateKeyInfo(void);
71 * Initializes this instance of %Pkcs08EncryptedPrivateKeyInfo with the encoded Tizen::Base::ByteBuffer that contains
72 * the EncryptedPrivateKeyInfo structure(EncryptedPrivateKeyInfo) in ASN.1 DER format.
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.
81 result Construct(const Tizen::Base::ByteBuffer& encodedData);
84 * Initializes this instance of %Pkcs08EncryptedPrivateKeyInfo with the values of the specified input parameters.
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.
94 result Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& encryptedData);
97 * Initializes this instance of %Pkcs08EncryptedPrivateKeyInfo with the values of the specified input parameters.
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.
109 result Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& key, const Tizen::Base::ByteBuffer& encodedPrivateKeyInfo);
112 * Gets a reference to AlgorithmIdentifier that identifies the encryption algorithm under which the private key is encrypted.
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.
119 const AlgorithmIdentifier& GetAlgorithm(void) const;
122 * Gets a pointer to Tizen::Base::ByteBuffer that contains the encrypted private key.
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.
130 Tizen::Base::ByteBuffer* GetEncryptedDataN(void) const;
133 * Decrypts the %Pkcs08EncryptedPrivateKeyInfo object using a key or password.
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.
146 Tizen::Base::ByteBuffer* DecryptN(const Tizen::Base::ByteBuffer& key);
149 * Gets the ASN.1 DER encoded pkcs08 encrypted private key structure.
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.
159 Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
162 // This copy constructor is intentionally declared as private to prohibit @n
163 // copying of objects by users.
166 Pkcs08EncryptedPrivateKeyInfo(const Pkcs08EncryptedPrivateKeyInfo& rhs);
168 // The implementation of this copy assignment operator is intentionally blank and @n
169 // declared as private to prohibit copying of objects.
172 Pkcs08EncryptedPrivateKeyInfo& operator =(const Pkcs08EncryptedPrivateKeyInfo& rhs);
175 class _Pkcs08EncryptedPrivateKeyInfoImpl* __pPkcs08EncryptedPrivateKeyInfoImpl;
176 friend class _Pkcs08EncryptedPrivateKeyInfoImpl;
179 }; //Pkcs08EncryptedPrivateKeyInfo
181 }}} // Tizen::Security::Pkcs
183 #endif // _FSEC_PKCS_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_