Fix svace defects
[platform/core/security/drm-service-core-tizen.git] / test / drm_testcore.cpp
1 /*
2  *  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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
15  *
16  * @file        drm_testcore.cpp
17  * @author      Kyungwook Tak(k.tak@samsung.com)
18  * @version     1.0
19  * @brief       Test drm library internal core codes
20  */
21 #include "TADC_Util.h"
22
23 #include <iostream>
24 #include <cstring>
25
26 bool tc_base64(void)
27 {
28         unsigned char in[16] = {
29                 0x12, 0x93, 0xe8, 0xf1, 0x28, 0xb3, 0xff, 0x85,
30                 0x83, 0xab, 0x8c, 0x1f, 0x7f, 0x9e, 0x15, 0x22
31         };
32
33         char *encoded = Base64Encode(in, sizeof(in));
34         std::cout << "encoded: " << encoded << std::endl;
35
36         int len = 0;
37         unsigned char *decoded = Base64Decode(encoded, &len);
38
39         if (len <= 0
40                         || static_cast<size_t>(len) != sizeof(in)
41                         || memcmp(in, decoded, sizeof(in)) != 0) {
42                 std::cerr << "input and decoded base64 is different!!" << std::endl;
43                 return false;
44         }
45
46         return true;
47 }
48
49 void test_drm_core(void)
50 {
51         tc_base64();
52 }