2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Kyungwook Tak <k.tak@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
19 * @author Kyungwook Tak (k.tak@samsung.com)
25 #include <boost/test/unit_test.hpp>
27 #include <SecCryptoSvc.h>
29 BOOST_AUTO_TEST_SUITE(CRYPTO_SERVICE_TEST)
31 BOOST_AUTO_TEST_CASE(PLATFORM_UNIQUE_KEY)
33 constexpr unsigned int KeyLen = 16;
34 unsigned char cek[KeyLen] = {0};
35 char *encoded_cek = nullptr;
37 BOOST_REQUIRE_MESSAGE(SecFrameGeneratePlatformUniqueKey(KeyLen, cek),
38 "Failed to SecFrameGeneratePlatformUniqueKey.");
40 encoded_cek = Base64Encoding(
41 reinterpret_cast<char *>(cek),
42 static_cast<int>(KeyLen));
43 BOOST_REQUIRE_MESSAGE(encoded_cek != nullptr, "Failed to base64 encoding.");
45 std::cout << "base64 encoded platform unique key(with len 16): "
46 << encoded_cek << std::endl;
49 BOOST_AUTO_TEST_CASE(GETDUID_16)
51 char *duid = GetDuid(16);
52 BOOST_REQUIRE_MESSAGE(duid != nullptr, "returned duid shouldn't be null");
53 std::cout << "duid: " << duid << std::endl;
56 BOOST_AUTO_TEST_CASE(GETDUID_20)
58 char *duid = GetDuid(20);
59 BOOST_REQUIRE_MESSAGE(duid != nullptr, "returned duid shouldn't be null");
60 std::cout << "duid: " << duid << std::endl;
64 BOOST_AUTO_TEST_SUITE_END()