2 // Copyright (c) 2012 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.
19 * @brief This is the header file for the %KeyPair class.
21 * This header file contains the declarations of the %KeyPair class.
23 #ifndef _FSEC_KEY_PAIR_H_
24 #define _FSEC_KEY_PAIR_H_
27 #include <FSecIPublicKey.h>
28 #include <FSecIPrivateKey.h>
29 #include <FBaseObject.h>
32 namespace Tizen { namespace Security
37 * @brief This class is a simple holder for a key pair (a public and a private key).
41 * The %KeyPair class manages a pair of keys comprising of a public and a private key, which are used in asymmetric ciphers.
42 * The key pairs are mainly used to encrypt messages and provide digital signatures. @n
44 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/security/key_mgmt_and_csprng.htm">Key Management and CSPRNG</a>.
46 * @see IKeyPairGenerator
47 * @see Tizen::Security::IPublicKey
48 * @see Tizen::Security::IPrivateKey
50 class _OSP_EXPORT_ KeyPair
51 : public Tizen::Base::Object
56 * The object is not fully constructed after this constructor is called. For full construction, @n
57 * the Construct() method must be called right after calling this constructor.
64 * This destructor overrides Tizen::Base::Object::~Object().
68 virtual ~KeyPair(void);
71 * Constructs and initializes the current instance of %KeyPair with the specified public and private keys.
75 * @return An error code
76 * @param[in] publicKey An instance of IPublicKey
77 * @param[in] privateKey An instance of IPrivateKey
78 * @exception E_SUCCESS The method is successful.
79 * @exception E_OUT_OF_MEMORY The memory is insufficient.
80 * @exception E_INVALID_ARG The specified @c publicKey or @c privateKey is invalid.
82 result Construct(Tizen::Security::IPublicKey& publicKey, Tizen::Security::IPrivateKey& privateKey);
85 * Gets the public key component of the current instance of %KeyPair.
89 * @return A pointer to IPublicKey
91 Tizen::Security::IPublicKey* GetPublicKey(void) const;
94 * Gets the private key component of the current instance of %KeyPair.
98 * @return A pointer to IPrivateKey
100 Tizen::Security::IPrivateKey* GetPrivateKey(void) const;
103 * Sets the public key.
107 * @return An error code
108 * @param[in] pubKey An instance of Tizen::Base::ByteBuffer that contains the public key
109 * @exception E_SUCCESS The method is successful.
110 * @exception E_OUT_OF_MEMORY The memory is insufficient.
111 * @exception E_INVALID_ARG The specified @c pubKey is invalid.
112 * @remarks Only ASN.1 encoding format is supported for input buffer.
114 result SetPublicKey(const Tizen::Base::ByteBuffer& pubKey);
117 * Sets the private key.
121 * @return An error code
122 * @param[in] privKey An instance of Tizen::Base::ByteBuffer that contains the private key
123 * @exception E_SUCCESS The method is successful.
124 * @exception E_OUT_OF_MEMORY The memory is insufficient.
125 * @exception E_INVALID_ARG The specified @c privKey is invalid.
126 * @remarks Only ASN.1 encoding format is supported for input buffer.
128 result SetPrivateKey(const Tizen::Base::ByteBuffer& privKey);
133 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
137 KeyPair(const KeyPair& rhs);
140 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
144 KeyPair& operator =(const KeyPair& rhs);
147 Tizen::Security::IPublicKey* __pPubKey;
148 Tizen::Security::IPrivateKey* __pPriKey;
150 class _KeyPairImpl* __pKeyPairImpl;
151 friend class _KeyPairImpl;
155 } } //Tizen::Security
157 #endif // _FSEC_KEY_PAIR_H_