Tizen 2.0 Release
[framework/web/wrt-commons.git] / tests / dpl / 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, "sample_input_string", "c9f26439c9882cccc98467dbdf07b1fc");
35 }
36
37 RUNNER_TEST(CryptoHash_MD4)
38 {
39     TEST_CRYPTO_HASH(DPL::Crypto::Hash::MD4, "sample_input_string", "8cd0720f7ec98c8e5f008afb54054677");
40 }
41
42 RUNNER_TEST(CryptoHash_MD5)
43 {
44     TEST_CRYPTO_HASH(DPL::Crypto::Hash::MD5, "sample_input_string", "eb7ae4f28fecbd1fd777d9b7495fc8ec");
45 }
46
47 RUNNER_TEST(CryptoHash_SHA)
48 {
49     TEST_CRYPTO_HASH(DPL::Crypto::Hash::SHA, "sample_input_string", "0a5725f3586616a4049730f3ba14c8aeda79ab21");
50 }
51
52 RUNNER_TEST(CryptoHash_SHA1)
53 {
54     TEST_CRYPTO_HASH(DPL::Crypto::Hash::SHA1, "sample_input_string", "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
55 }
56
57 RUNNER_TEST(CryptoHash_DSS)
58 {
59     TEST_CRYPTO_HASH(DPL::Crypto::Hash::DSS, "sample_input_string", "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
60 }
61
62 RUNNER_TEST(CryptoHash_DSS1)
63 {
64     TEST_CRYPTO_HASH(DPL::Crypto::Hash::DSS1, "sample_input_string", "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
65 }
66
67 RUNNER_TEST(CryptoHash_ECDSA)
68 {
69     TEST_CRYPTO_HASH(DPL::Crypto::Hash::ECDSA, "sample_input_string", "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
70 }
71
72 RUNNER_TEST(CryptoHash_SHA224)
73 {
74     TEST_CRYPTO_HASH(DPL::Crypto::Hash::SHA224, "sample_input_string", "d4dde2370eb869f6e790133b94d58e45417392b9d899af883a274011");
75 }
76
77 RUNNER_TEST(CryptoHash_SHA256)
78 {
79     TEST_CRYPTO_HASH(DPL::Crypto::Hash::SHA256, "sample_input_string", "a470ec7c783ac51f9eb1772132e6bde1a053bbc81650719dd0ac62ecd93caf12");
80 }
81
82 RUNNER_TEST(CryptoHash_SHA384)
83 {
84     TEST_CRYPTO_HASH(DPL::Crypto::Hash::SHA384, "sample_input_string", "63d8bfa95c95c6906d1816965431c065278a655c60f786c9b246c1f73ba7ac557007f5064ba54ebd3a1988e6f37baa97");
85 }
86
87 RUNNER_TEST(CryptoHash_SHA512)
88 {
89     TEST_CRYPTO_HASH(DPL::Crypto::Hash::SHA512, "sample_input_string", "799317a140741937d9e5d8dbf9d3045d2c220de5ac33b3d5897acf873291ed14379eb15ef406d2284313d40edb0e01affac8efeb01cb47c2042e3e62a4a83d7d");
90 }