2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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.
17 * @file test_crypto_hash.cpp
18 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
20 * @brief This file is the implementation file of test crypto hash
22 #include <dpl/test_runner.h>
23 #include <dpl/crypto_hash.h>
24 RUNNER_TEST_GROUP_INIT(DPL)
26 #define TEST_CRYPTO_HASH(Class, Input, Output) \
28 crypto.Append(Input); \
30 RUNNER_ASSERT(crypto.ToString() == Output);
32 RUNNER_TEST(CryptoHash_MD2)
34 TEST_CRYPTO_HASH(DPL::Crypto::Hash::MD2,
35 "sample_input_string",
36 "c9f26439c9882cccc98467dbdf07b1fc");
39 RUNNER_TEST(CryptoHash_MD4)
41 TEST_CRYPTO_HASH(DPL::Crypto::Hash::MD4,
42 "sample_input_string",
43 "8cd0720f7ec98c8e5f008afb54054677");
46 RUNNER_TEST(CryptoHash_MD5)
48 TEST_CRYPTO_HASH(DPL::Crypto::Hash::MD5,
49 "sample_input_string",
50 "eb7ae4f28fecbd1fd777d9b7495fc8ec");
53 RUNNER_TEST(CryptoHash_SHA)
55 TEST_CRYPTO_HASH(DPL::Crypto::Hash::SHA,
56 "sample_input_string",
57 "0a5725f3586616a4049730f3ba14c8aeda79ab21");
60 RUNNER_TEST(CryptoHash_SHA1)
62 TEST_CRYPTO_HASH(DPL::Crypto::Hash::SHA1,
63 "sample_input_string",
64 "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
67 RUNNER_TEST(CryptoHash_DSS)
69 TEST_CRYPTO_HASH(DPL::Crypto::Hash::DSS,
70 "sample_input_string",
71 "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
74 RUNNER_TEST(CryptoHash_DSS1)
76 TEST_CRYPTO_HASH(DPL::Crypto::Hash::DSS1,
77 "sample_input_string",
78 "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
81 RUNNER_TEST(CryptoHash_ECDSA)
83 TEST_CRYPTO_HASH(DPL::Crypto::Hash::ECDSA,
84 "sample_input_string",
85 "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
88 RUNNER_TEST(CryptoHash_SHA224)
90 TEST_CRYPTO_HASH(DPL::Crypto::Hash::SHA224,
91 "sample_input_string",
92 "d4dde2370eb869f6e790133b94d58e45417392b9d899af883a274011");
95 RUNNER_TEST(CryptoHash_SHA256)
98 DPL::Crypto::Hash::SHA256,
99 "sample_input_string",
100 "a470ec7c783ac51f9eb1772132e6bde1a053bbc81650719dd0ac62ecd93caf12");
103 RUNNER_TEST(CryptoHash_SHA384)
106 DPL::Crypto::Hash::SHA384,
107 "sample_input_string",
108 "63d8bfa95c95c6906d1816965431c065278a655c60f786c9b246c1f73ba7ac557007f5064ba54ebd3a1988e6f37baa97");
111 RUNNER_TEST(CryptoHash_SHA512)
114 DPL::Crypto::Hash::SHA512,
115 "sample_input_string",
116 "799317a140741937d9e5d8dbf9d3045d2c220de5ac33b3d5897acf873291ed14379eb15ef406d2284313d40edb0e01affac8efeb01cb47c2042e3e62a4a83d7d");