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 FSecSecretKey.cpp
19 * @brief This is the implementation file for SecretKey class.
21 #include <unique_ptr.h>
22 #include <FBaseResult.h>
23 #include <FBaseErrors.h>
24 #include <FSecSecretKey.h>
25 #include <FBaseSysLog.h>
27 using namespace Tizen::Base;
30 namespace Tizen { namespace Security
33 SecretKey::SecretKey(void)
34 : __pSecretKeyImpl(null)
38 SecretKey::~SecretKey(void)
43 SecretKey::GetFormat(void) const
45 String encodedFormat = L"NONE";
51 SecretKey::GetEncodedN(void) const
57 std::unique_ptr<ByteBuffer> pKeyBuffer(new (std::nothrow) ByteBuffer());
58 SysTryReturn(NID_SEC, pKeyBuffer != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory");
60 r = pKeyBuffer->Construct(__keyBytes);
61 SysTryReturn(NID_SEC, !IsFailed(r), null, r, "[%s] Input key buffer is not valid.", GetErrorMessage(r));
63 return pKeyBuffer.release();
67 SecretKey::SetKey(const ByteBuffer& keyBuffer)
69 //Store the secret key
70 return __keyBytes.Construct(keyBuffer);