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 FSecPublicKey.cpp
20 * @brief This is the implementation file for PublicKey class.
22 * This header file contains the implementation of PublicKey class.
24 #include <unique_ptr.h>
25 #include <FBaseResult.h>
26 #include <FSecPublicKey.h>
27 #include <FBaseSysLog.h>
29 using namespace Tizen::Base;
32 namespace Tizen { namespace Security
35 PublicKey::PublicKey(void)
36 : __pPublicKeyImpl(null)
39 __encodedFormat = L"ASN.1";
42 PublicKey::~PublicKey(void)
47 PublicKey::GetFormat(void) const
49 return __encodedFormat;
53 PublicKey::GetEncodedN(void) const
59 std::unique_ptr<ByteBuffer> pKeyBuffer(new (std::nothrow) ByteBuffer());
60 SysTryReturn(NID_SEC, pKeyBuffer != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
62 r = pKeyBuffer->Construct(__keyBytes);
63 SysTryReturn(NID_SEC, !IsFailed(r), null, r, "[%s] Input key buffer is not valid.", GetErrorMessage(r));
65 return pKeyBuffer.release();
69 PublicKey::SetKey(const ByteBuffer& keyBuffer)
71 return __keyBytes.Construct(keyBuffer);