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. The key pairs are mainly used to encrypt messages and provide digital signatures. @n
43 * 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>.
45 * @see IKeyPairGenerator
46 * @see Tizen::Security::IPublicKey
47 * @see Tizen::Security::IPrivateKey
49 class _OSP_EXPORT_ KeyPair
50 : public Tizen::Base::Object
55 * The object is not fully constructed after this constructor is called. For full construction, @n
56 * the Construct() method must be called right after calling this constructor.
63 * This destructor overrides Tizen::Base::Object::~Object().
67 virtual ~KeyPair(void);
70 * Constructs and initializes the current instance of %KeyPair with the specified public and private keys.
74 * @return An error code
75 * @param[in] publicKey An instance of IPublicKey
76 * @param[in] privateKey An instance of IPrivateKey
77 * @exception E_SUCCESS The method is successful.
78 * @exception E_OUT_OF_MEMORY The memory is insufficient.
79 * @exception E_INVALID_ARG The specified @c publicKey or @c privateKey is invalid.
81 result Construct(Tizen::Security::IPublicKey& publicKey, Tizen::Security::IPrivateKey& privateKey);
84 * Gets the public key component of the current instance of %KeyPair.
88 * @return A pointer to IPublicKey
90 Tizen::Security::IPublicKey* GetPublicKey(void) const;
93 * Gets the private key component of the current instance of %KeyPair.
97 * @return A pointer to IPrivateKey
99 Tizen::Security::IPrivateKey* GetPrivateKey(void) const;
102 * Sets the public key.
106 * @return An error code
107 * @param[in] pubKey An instance of Tizen::Base::ByteBuffer that contains the public key
108 * @exception E_SUCCESS The method is successful.
109 * @exception E_OUT_OF_MEMORY The memory is insufficient.
110 * @exception E_INVALID_ARG The specified @c pubKey is invalid.
111 * @remarks Only ASN.1 encoding format is supported for input buffer.
113 result SetPublicKey(const Tizen::Base::ByteBuffer& pubKey);
116 * Sets the private key.
120 * @return An error code
121 * @param[in] privKey An instance of Tizen::Base::ByteBuffer that contains the private key
122 * @exception E_SUCCESS The method is successful.
123 * @exception E_OUT_OF_MEMORY The memory is insufficient.
124 * @exception E_INVALID_ARG The specified @c privKey is invalid.
125 * @remarks Only ASN.1 encoding format is supported for input buffer.
127 result SetPrivateKey(const Tizen::Base::ByteBuffer& privKey);
132 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
136 KeyPair(const KeyPair& rhs);
139 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
143 KeyPair& operator =(const KeyPair& rhs);
146 Tizen::Security::IPublicKey* __pPubKey;
147 Tizen::Security::IPrivateKey* __pPriKey;
149 class _KeyPairImpl* __pKeyPairImpl;
150 friend class _KeyPairImpl;
154 } } //Tizen::Security
156 #endif // _FSEC_KEY_PAIR_H_