2 // Open Service Platform
3 // Copyright (c) 2012 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 FSecCryptoRsaSignature.h
20 * @brief This is the header file for the %RsaSignature class.
22 * This header file contains the declarations of the %RsaSignature class.
24 #ifndef _FSEC_CRYPTO_RSA_SIGNATURE_H_
25 #define _FSEC_CRYPTO_RSA_SIGNATURE_H_
27 #include <FSecCryptoISignature.h>
31 namespace Tizen { namespace Security { namespace Crypto
36 * @brief This class implements the Rivest Shamir Adleman (RSA) signatures.
40 * The %RsaSignature class implements the Rivest Shamir Adleman (RSA) signatures. @n
42 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/security/ciphers.htm">Ciphers</a>.
45 * @see IKeyPairGenerator
52 class _OSP_EXPORT_ RsaSignature
53 : public virtual ISignature
54 , public Tizen::Base::Object
59 * This is the default constructor for this class.
66 * This destructor overrides Tizen::Base::Object::~Object().
70 virtual ~RsaSignature(void);
73 * Sets an asymmetric private key for signature.
77 * @return An error code
78 * @param[in] key An instance of IKey
79 * @exception E_SUCCESS The method is successful.
80 * @exception E_INVALID_ARG The specified @c key is invalid.
81 * @exception E_OUT_OF_MEMORY The memory is insufficient.
83 virtual result SetPrivateKey(const Tizen::Security::IKey& key);
86 * Sets an asymmetric public key for verification.
90 * @return An error code
91 * @param[in] key An instance of IKey
92 * @exception E_SUCCESS The method is successful.
93 * @exception E_INVALID_ARG The specified @c key is invalid.
94 * @exception E_OUT_OF_MEMORY The memory is insufficient.
96 virtual result SetPublicKey(const Tizen::Security::IKey& key);
103 * @return A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
104 * else @c null if an error occurs
105 * @param[in] input An instance of Tizen::Base::ByteBuffer
106 * @exception E_SUCCESS The method is successful.
107 * @exception E_INVALID_ARG The input Tizen::Base::ByteBuffer is empty or contains invalid data.
108 * @exception E_OUT_OF_MEMORY The memory is insufficient.
109 * @exception E_KEY_NOT_FOUND The specified key is not found.
110 * @exception E_SYSTEM A system error has occurred. @n
111 * The method has failed to operate with the OpenSSL library, or
112 * the Tizen::Base::ByteBuffer operation has failed.
113 * @remarks The specific error code can be accessed using the GetLastResult() method.
115 virtual Tizen::Base::ByteBuffer* SignN(const Tizen::Base::ByteBuffer& input);
118 * Verifies the data. @n
119 * The verification is done by comparing the @c signedData to the signature created by the @c data.
123 * @return @c true if the signed data is correct, @n
125 * @param[in] data An instance of Tizen::Base::ByteBuffer that contains the original data
126 * @param[in] signedData A instance of Tizen::Base::ByteBuffer that contains the signed data
127 * @exception E_SUCCESS The method is successful.
128 * @exception E_INVALID_ARG The input Tizen::Base::ByteBuffer is empty or contains invalid data.
129 * @exception E_OUT_OF_MEMORY The memory is insufficient.
130 * @exception E_KEY_NOT_FOUND The specified key is not found.
131 * @exception E_SYSTEM A system error has occurred. @n
132 * The method has failed to operate with the OpenSSL library, or
133 * the Tizen::Base::ByteBuffer operation has failed.
134 * @remarks The specific error code can be accessed using the GetLastResult() method.
136 virtual bool Verify(const Tizen::Base::ByteBuffer& data, const Tizen::Base::ByteBuffer& signedData);
141 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
145 RsaSignature(const RsaSignature& rhs);
148 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
152 RsaSignature& operator =(const RsaSignature& rhs);
155 Tizen::Base::ByteBuffer __privateKey;
156 Tizen::Base::ByteBuffer __publicKey;
158 class _RsaSignatureImpl* __pRsaSignatureImpl;
159 friend class _RsaSignatureImpl;
163 } } } //Tizen::Security::Crypto
165 #endif //_FSEC_CRYPTO_RSA_SIGNATURE_H_