1 #define BOOST_TEST_MODULE KEY_MANAGER_TEST
2 #include <boost/test/unit_test.hpp>
3 #include <key-provider.h>
4 #include <test_common.h>
6 #define PASSWORD "12345TIZEN12345AAAAAAAAA"
7 #define INCORRECT_PASSWORD "AAAAAAAAAAAAAAAAAAAAA"
8 #define NEW_PASSWORD "NEW12345TIZEN12345NEW"
10 #define USERNAME_SHORT "AB"
11 #define USERNAME_LONG "SOFTWARE_CENTER_SYSTEM_SW_LAB_SECURITY_PART"
12 #define SMACK_LABEL_1 "SAMPLE_SMACK_LABEL_1"
13 #define SMACK_LABEL_2 "SAMPLE_SMACK_LABEL_2"
15 CKM::KeyProvider keyProvider;
16 CKM::RawBuffer rb_test;
17 CKM::RawBuffer rb_DEK1;
18 CKM::RawBuffer rb_pureDEK1;
20 BOOST_GLOBAL_FIXTURE(TestConfig)
22 // Test suite for key-provider module.
23 BOOST_AUTO_TEST_SUITE(S1_KEY_PROVIDER)
25 BOOST_AUTO_TEST_CASE(T00100_initialize){
26 boost::unit_test::results_reporter::set_level(boost::unit_test::SHORT_REPORT);
27 BOOST_CHECK_NO_THROW(CKM::KeyProvider::initializeLibrary());
30 BOOST_AUTO_TEST_CASE(T00200_generateDomainKEK){
32 BOOST_CHECK(!(rb_test = CKM::KeyProvider::generateDomainKEK(std::string(USERNAME_LONG),
33 std::string(PASSWORD))).empty());
36 BOOST_AUTO_TEST_CASE(T00300_construct){
37 BOOST_CHECK_NO_THROW(keyProvider = CKM::KeyProvider(rb_test, std::string(PASSWORD)));
40 BOOST_AUTO_TEST_CASE(T00301_construct_incorrect_password){
41 BOOST_CHECK_THROW(keyProvider = CKM::KeyProvider(rb_test, std::string(INCORRECT_PASSWORD)),
42 CKM::KeyProvider::Exception::UnwrapFailed);
45 BOOST_AUTO_TEST_CASE(T00400_isInitialized){
46 BOOST_CHECK(keyProvider.isInitialized());
49 BOOST_AUTO_TEST_CASE(T00500_getPureDomainKEK){
50 BOOST_CHECK_NO_THROW(rb_test = keyProvider.getPureDomainKEK());
53 BOOST_AUTO_TEST_CASE(T00600_getWrappedDomainKEK){
54 BOOST_CHECK_NO_THROW(rb_test = keyProvider.getWrappedDomainKEK(PASSWORD));
57 BOOST_AUTO_TEST_CASE(T00700_generateDEK){
59 BOOST_CHECK_NO_THROW(rb_DEK1 = keyProvider.generateDEK(std::string(SMACK_LABEL_1)));
62 BOOST_AUTO_TEST_CASE(T00800_getPureDEK){
64 BOOST_CHECK_NO_THROW(rb_pureDEK1 = keyProvider.getPureDEK(rb_DEK1));
67 BOOST_AUTO_TEST_CASE(T00900_reencrypt){
68 BOOST_CHECK_NO_THROW(CKM::KeyProvider::reencrypt(rb_test, std::string(PASSWORD),
69 std::string(NEW_PASSWORD)));
72 BOOST_AUTO_TEST_CASE(T00901_reencrypt_incorrect_password){
73 BOOST_CHECK_THROW((rb_test = CKM::KeyProvider::reencrypt(rb_test, std::string(INCORRECT_PASSWORD),
74 std::string(NEW_PASSWORD))), CKM::KeyProvider::Exception::UnwrapFailed);
77 BOOST_AUTO_TEST_CASE(T01000_getPureDEK_after_reencrypt){
78 BOOST_CHECK_NO_THROW(keyProvider.getPureDEK(rb_DEK1));
81 BOOST_AUTO_TEST_CASE(T10000_closeLibrary){
82 BOOST_CHECK_NO_THROW(CKM::KeyProvider::closeLibrary());
85 BOOST_AUTO_TEST_SUITE_END()
88 BOOST_AUTO_TEST_SUITE(S2_CRYPTO_MODULE)
90 BOOST_AUTO_TEST_CASE(T00100_initialize){
94 BOOST_AUTO_TEST_SUITE_END()