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.
18 * @file FSecPublicKey.cpp
19 * @brief This is the implementation file for PublicKey class.
21 * This header file contains the implementation of PublicKey class.
23 #include <unique_ptr.h>
24 #include <FBaseResult.h>
25 #include <FSecPublicKey.h>
26 #include <FBaseSysLog.h>
28 using namespace Tizen::Base;
31 namespace Tizen { namespace Security
34 PublicKey::PublicKey(void)
35 : __pPublicKeyImpl(null)
38 __encodedFormat = L"ASN.1";
41 PublicKey::~PublicKey(void)
46 PublicKey::GetFormat(void) const
48 return __encodedFormat;
52 PublicKey::GetEncodedN(void) const
58 std::unique_ptr<ByteBuffer> pKeyBuffer(new (std::nothrow) ByteBuffer());
59 SysTryReturn(NID_SEC, pKeyBuffer != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
61 r = pKeyBuffer->Construct(__keyBytes);
62 SysTryReturn(NID_SEC, !IsFailed(r), null, r, "[%s] Input key buffer is not valid.", GetErrorMessage(r));
64 return pKeyBuffer.release();
68 PublicKey::SetKey(const ByteBuffer& keyBuffer)
70 return __keyBytes.Construct(keyBuffer);