merge with master
[platform/framework/web/wrt-commons.git] / tests / unused / test_crypto_hash.cpp
1 /*
2  * Copyright (c) 2011 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 /*
17  * @file        test_crypto_hash.cpp
18  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
19  * @version     1.0
20  * @brief       This file is the implementation file of test crypto hash
21  */
22 #include <dpl/test_runner.h>
23 #include <dpl/crypto_hash.h>
24 RUNNER_TEST_GROUP_INIT(DPL)
25
26 #define TEST_CRYPTO_HASH(Class, Input, Output)   \
27     Class crypto;                                \
28     crypto.Append(Input);                        \
29     crypto.Finish();                             \
30     RUNNER_ASSERT(crypto.ToString() == Output);
31
32 RUNNER_TEST(CryptoHash_MD2)
33 {
34     TEST_CRYPTO_HASH(DPL::Crypto::Hash::MD2,
35                      "sample_input_string",
36                      "c9f26439c9882cccc98467dbdf07b1fc");
37 }
38
39 RUNNER_TEST(CryptoHash_MD4)
40 {
41     TEST_CRYPTO_HASH(DPL::Crypto::Hash::MD4,
42                      "sample_input_string",
43                      "8cd0720f7ec98c8e5f008afb54054677");
44 }
45
46 RUNNER_TEST(CryptoHash_MD5)
47 {
48     TEST_CRYPTO_HASH(DPL::Crypto::Hash::MD5,
49                      "sample_input_string",
50                      "eb7ae4f28fecbd1fd777d9b7495fc8ec");
51 }
52
53 RUNNER_TEST(CryptoHash_SHA)
54 {
55     TEST_CRYPTO_HASH(DPL::Crypto::Hash::SHA,
56                      "sample_input_string",
57                      "0a5725f3586616a4049730f3ba14c8aeda79ab21");
58 }
59
60 RUNNER_TEST(CryptoHash_SHA1)
61 {
62     TEST_CRYPTO_HASH(DPL::Crypto::Hash::SHA1,
63                      "sample_input_string",
64                      "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
65 }
66
67 RUNNER_TEST(CryptoHash_DSS)
68 {
69     TEST_CRYPTO_HASH(DPL::Crypto::Hash::DSS,
70                      "sample_input_string",
71                      "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
72 }
73
74 RUNNER_TEST(CryptoHash_DSS1)
75 {
76     TEST_CRYPTO_HASH(DPL::Crypto::Hash::DSS1,
77                      "sample_input_string",
78                      "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
79 }
80
81 RUNNER_TEST(CryptoHash_ECDSA)
82 {
83     TEST_CRYPTO_HASH(DPL::Crypto::Hash::ECDSA,
84                      "sample_input_string",
85                      "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
86 }
87
88 RUNNER_TEST(CryptoHash_SHA224)
89 {
90     TEST_CRYPTO_HASH(DPL::Crypto::Hash::SHA224,
91                      "sample_input_string",
92                      "d4dde2370eb869f6e790133b94d58e45417392b9d899af883a274011");
93 }
94
95 RUNNER_TEST(CryptoHash_SHA256)
96 {
97     TEST_CRYPTO_HASH(
98         DPL::Crypto::Hash::SHA256,
99         "sample_input_string",
100         "a470ec7c783ac51f9eb1772132e6bde1a053bbc81650719dd0ac62ecd93caf12");
101 }
102
103 RUNNER_TEST(CryptoHash_SHA384)
104 {
105     TEST_CRYPTO_HASH(
106         DPL::Crypto::Hash::SHA384,
107         "sample_input_string",
108         "63d8bfa95c95c6906d1816965431c065278a655c60f786c9b246c1f73ba7ac557007f5064ba54ebd3a1988e6f37baa97");
109 }
110
111 RUNNER_TEST(CryptoHash_SHA512)
112 {
113     TEST_CRYPTO_HASH(
114         DPL::Crypto::Hash::SHA512,
115         "sample_input_string",
116         "799317a140741937d9e5d8dbf9d3045d2c220de5ac33b3d5897acf873291ed14379eb15ef406d2284313d40edb0e01affac8efeb01cb47c2042e3e62a4a83d7d");
117 }