diff options
author | Krzysztof Jackiewicz <k.jackiewicz@samsung.com> | 2018-10-30 14:26:12 +0100 |
---|---|---|
committer | Krzysztof Jackiewicz <k.jackiewicz@samsung.com> | 2019-02-13 13:37:06 +0100 |
commit | b15ba6d7ccaeef1b17e2234afba13b7864cfcd2a (patch) | |
tree | 1f7db361bb07059c7cbab90ea57d7507d7f99929 /tests | |
parent | 4437a93b733df83365798950ada5f7d598877407 (diff) | |
download | key-manager-b15ba6d7ccaeef1b17e2234afba13b7864cfcd2a.tar.gz key-manager-b15ba6d7ccaeef1b17e2234afba13b7864cfcd2a.tar.bz2 key-manager-b15ba6d7ccaeef1b17e2234afba13b7864cfcd2a.zip |
Validate encrypted DKEK
- Make sure that the length of the encrypted DKEK received in
WrapperKeyAndInfoContainer() does not exceed the size of the key
buffer.
- Check client id NULL termination.
- Get rid of unnecessary dynamic allocations.
- Update tests.
Change-Id: I9f5b494a8ea3d0d8f438a50bb49b55d57d1a3e67
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_key-provider.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/test_key-provider.cpp b/tests/test_key-provider.cpp index abca9890..4991c4db 100644 --- a/tests/test_key-provider.cpp +++ b/tests/test_key-provider.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2016 - 2019 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kyungwook Tak <k.tak@samsung.com> * @@ -186,6 +186,23 @@ BOOST_AUTO_TEST_CASE(wrapped_container) wrappedContainer.getWrappedKeyAndInfo().keyInfo.client, wrappedContainer2.getWrappedKeyAndInfo().keyInfo.client, sizeof(wrappedContainer.getWrappedKeyAndInfo().keyInfo.client)) == 0); + + CKM::WrappedKeyAndInfo wrapped3; + wrapped3.keyInfo.keyLength = MAX_WRAPPED_KEY_SIZE; + BOOST_REQUIRE_NO_THROW(CKM::WrappedKeyAndInfoContainer wrappedContainer3( + reinterpret_cast<unsigned char*>(&wrapped3))); + + wrapped3.keyInfo.keyLength++; + BOOST_REQUIRE_THROW(CKM::WrappedKeyAndInfoContainer wrappedContainer3( + reinterpret_cast<unsigned char*>(&wrapped3)), + CKM::Exc::InternalError); + + // missing NULL termination in wrapped4.keyInfo.client + CKM::WrappedKeyAndInfo wrapped4; + memset(&wrapped4, 0x01, sizeof(CKM::WrappedKeyAndInfo)); + BOOST_REQUIRE_THROW(CKM::WrappedKeyAndInfoContainer wrappedContainer3( + reinterpret_cast<unsigned char*>(&wrapped4)), + CKM::Exc::InternalError); } BOOST_AUTO_TEST_CASE(container) |