/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2023 - 2024 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
}
+NEGATIVE_TEST_CASE(getStoreTest_n)
+{
+ Decider d;
+ CryptoBackend b;
+ GStore* s;
+ // this always has to pass
+ b = CryptoBackend::OpenSSL;
+ s = d.getStore(b);
+ BOOST_REQUIRE(s != NULL);
+ // this always has to pass
+ b = CryptoBackend::None;
+ s = d.getStore(b);
+ BOOST_REQUIRE(s == NULL);
+ b = CryptoBackend::TrustZone;
+ s = d.getStore(b);
+#ifdef TZ_BACKEND_ENABLED
+ // this passes only if TZ is enabled
+ BOOST_REQUIRE(s != NULL);
+#else
+ BOOST_REQUIRE(s == NULL);
+#endif
+ Policy priv, pub;
+ BOOST_REQUIRE_NO_THROW(d.getStore(DataType::KEY_DSA_PUBLIC, priv, pub, false, false));
+}
+
+POSITIVE_TEST_CASE(getStoreRefTest_p)
+{
+ Decider d;
+ Token t;
+ t.backendId = CryptoBackend::OpenSSL;
+ BOOST_REQUIRE_NO_THROW(d.getStore(t));
+#ifdef TZ_BACKEND_ENABLED
+ t.backendId = CryptoBackend::TrustZone;
+ BOOST_REQUIRE_NO_THROW(d.getStore(t));
+#endif
+}
+
+NEGATIVE_TEST_CASE(getStoreRefTest_n)
+{
+ Decider d;
+ Token t;
+ t.backendId = CryptoBackend::None;
+ BOOST_REQUIRE_THROW(d.getStore(t), Exc::Crypto::InternalError);
+#ifndef TZ_BACKEND_ENABLED
+ t.backendId = CryptoBackend::TrustZone;
+ BOOST_REQUIRE_THROW(d.getStore(t), Exc::Crypto::InternalError);
+#endif
+}
+
BOOST_AUTO_TEST_SUITE_END()
/*
- * Copyright (c) 2015 - 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2024 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
CryptoAlgorithmSerializable::UnsupportedParam);
}
+POSITIVE_TEST_CASE(Serialization_Policy)
+{
+ Policy input;
+ input.extractable = false;
+ input.backend = PolicyBackend::FORCE_SOFTWARE;
+ input.password = "abc";
+
+ PolicySerializable in(input);
+ PolicySerializable output;
+
+ MessageBuffer buf;
+ buf.Push(SerializeMessage(in));
+ buf.Deserialize(output);
+
+ BOOST_REQUIRE(output.extractable == input.extractable);
+ BOOST_REQUIRE(output.backend == input.backend);
+ BOOST_REQUIRE(output.password == input.password);
+}
+
+POSITIVE_TEST_CASE(Serialization_AliasInfoVector)
+{
+ AliasInfoVector v;
+ v.push_back(AliasInfo("alias 1", 1, BackendId::SW));
+ v.push_back(AliasInfo("alias 2", 2, BackendId::TZ));
+
+ AliasInfoSerializableVector sv(v);
+ AliasInfoVector o;
+ AliasInfoSerializableVector output(o);
+
+ MessageBuffer buf;
+ buf.Push(SerializeMessage(sv));
+ buf.Deserialize(output);
+
+ BOOST_REQUIRE(o.size() == v.size());
+ BOOST_REQUIRE(o[0].alias == v[0].alias);
+ BOOST_REQUIRE(o[0].type == v[0].type);
+ BOOST_REQUIRE(o[0].backend == v[0].backend);
+ BOOST_REQUIRE(o[1].alias == v[1].alias);
+ BOOST_REQUIRE(o[1].type == v[1].type);
+ BOOST_REQUIRE(o[1].backend == v[1].backend);
+}
+
BOOST_AUTO_TEST_SUITE_END()