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 implements to encrypt a private key.An Encrypted private key structure consist
37 * of an encryption algorithm and the encrypted Pkcs08PrivateKeyInfo.
39 * It is defined in ASN.1 as:
41 * EncryptedPrivateKeyInfo ::= SEQUENCE {
42 * encryptionAlgorithm AlgorithmIdentifier {{KeyEncryptionAlgorithms}},
43 * encryptedData EncryptedData
49 class _OSP_EXPORT_ Pkcs08EncryptedPrivateKeyInfo
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.
59 Pkcs08EncryptedPrivateKeyInfo(void);
62 * This destructor overrides Tizen::Base::Object::~Object().
66 virtual ~Pkcs08EncryptedPrivateKeyInfo(void);
69 * Initializes this instance of %Pkcs08EncryptedPrivateKeyInfo with the encoded Bytebuffer which contain @n
70 * EncryptedPrivateKeyInfo structure(EncryptedPrivateKeyInfo) in ASN.1 DER format.
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.
79 result Construct(const Tizen::Base::ByteBuffer& encodedData);
82 * Initializes the %Pkcs08EncryptedPrivateKeyInfo with supplied input parameters values.
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.
92 result Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& encryptedData);
95 * Initializes the %Pkcs08EncryptedPrivateKeyInfo with supplied input parameters values.
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.
107 result Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& key, const Tizen::Base::ByteBuffer& encodedPrivateKeyInfo);
110 * Gets the reference to AlgorithmIdentifier which identifies the encryption algorithm under which private key is encrypted.
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.
117 const AlgorithmIdentifier& GetAlgorithm(void) const;
120 * Gets the pointer to the ByteBuffer which contains encrypted private key.
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.
128 Tizen::Base::ByteBuffer* GetEncryptedDataN(void) const;
131 * This API will provide the implementation of DecryptN to decrypt the Pkcs08EncryptedPrivateKeyInfo Object
132 * using the Key or Password.
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.
145 Tizen::Base::ByteBuffer* DecryptN(const Tizen::Base::ByteBuffer& key);
148 * Gets the ASN.1 DER encoded pkcs08 encrypted private key structure.
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.
158 Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
161 // This copy constructor is intentionally declared as private to prohibit @n
162 // copying of objects by users.
165 Pkcs08EncryptedPrivateKeyInfo(const Pkcs08EncryptedPrivateKeyInfo& rhs);
167 // The implementation of this copy assignment operator is intentionally blank and @n
168 // declared as private to prohibit copying of objects.
171 Pkcs08EncryptedPrivateKeyInfo& operator =(const Pkcs08EncryptedPrivateKeyInfo& rhs);
174 class _Pkcs08EncryptedPrivateKeyInfoImpl* __pPkcs08EncryptedPrivateKeyInfoImpl;
175 friend class _Pkcs08EncryptedPrivateKeyInfoImpl;
178 }; //Pkcs08EncryptedPrivateKeyInfo
180 }}} // Tizen::Security::Pkcs
182 #endif // _FSEC_PKCS_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_