blob: 6bb283a007ab9e7117b93db0a11b857b69eec775 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Yingdi Yu28fd32f2014-01-28 19:03:03 -08002/**
Yingdi Yu99b2a002015-08-12 12:47:44 -07003 * Copyright (c) 2013-2016 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Yingdi Yu28fd32f2014-01-28 19:03:03 -080020 */
21
Yingdi Yuf56c68f2014-04-24 21:50:13 -070022#include "security/sec-tpm-osx.hpp"
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070023#include "security/v1/cryptopp.hpp"
Yingdi Yu28fd32f2014-01-28 19:03:03 -080024
Yingdi Yuf56c68f2014-04-24 21:50:13 -070025#include "util/time.hpp"
26
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070027#include <boost/lexical_cast.hpp>
Yingdi Yu9d9d5992014-06-25 12:25:16 -070028#include <Availability.h>
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070029
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070030#include "boost-test.hpp"
31
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -080032namespace ndn {
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070033namespace security {
Spyridon Mastorakis429634f2015-02-19 17:35:33 -080034namespace tests {
Yingdi Yu28fd32f2014-01-28 19:03:03 -080035
Yingdi Yu41546342014-11-30 23:37:53 -080036class OsxKeyChainTestFixture
37{
38public:
39 OsxKeyChainTestFixture()
40 {
41 std::string oldHOME;
42 if (std::getenv("OLD_HOME"))
43 oldHOME = std::getenv("OLD_HOME");
44
45 if (std::getenv("HOME"))
46 m_HOME = std::getenv("HOME");
47
48 if (!oldHOME.empty())
49 setenv("HOME", oldHOME.c_str(), 1);
50 else
51 unsetenv("HOME");
52 }
53
54 ~OsxKeyChainTestFixture()
55 {
56 if (!m_HOME.empty())
57 setenv("HOME", m_HOME.c_str(), 1);
58 else
59 unsetenv("HOME");
60 }
61
62protected:
63 std::string m_HOME;
64};
65
Spyridon Mastorakis429634f2015-02-19 17:35:33 -080066BOOST_FIXTURE_TEST_SUITE(SecuritySecTpmOsx, OsxKeyChainTestFixture)
Yingdi Yu28fd32f2014-01-28 19:03:03 -080067
Alexander Afanasyevf82d13a2014-04-30 14:30:19 -070068BOOST_AUTO_TEST_CASE(Delete)
Yingdi Yu28fd32f2014-01-28 19:03:03 -080069{
70 SecTpmOsx tpm;
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070071
Yingdi Yu5e96e002014-04-23 18:32:15 -070072 Name keyName("/TestSecTpmOsx/Delete/ksk-" +
Yingdi Yu7036ce22014-06-19 18:53:37 -070073 boost::lexical_cast<std::string>(
Yingdi Yu5e96e002014-04-23 18:32:15 -070074 time::toUnixTimestamp(time::system_clock::now()).count()));
Yingdi Yu7036ce22014-06-19 18:53:37 -070075 RsaKeyParams params(2048);
76 BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, params));
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070077
Yingdi Yu99b2a002015-08-12 12:47:44 -070078 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), true);
79 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), true);
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070080
Yingdi Yu28fd32f2014-01-28 19:03:03 -080081 tpm.deleteKeyPairInTpm(keyName);
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070082
Yingdi Yu99b2a002015-08-12 12:47:44 -070083 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), false);
84 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), false);
Yingdi Yu28fd32f2014-01-28 19:03:03 -080085}
86
Alexander Afanasyevf82d13a2014-04-30 14:30:19 -070087BOOST_AUTO_TEST_CASE(SignVerify)
Yingdi Yu28fd32f2014-01-28 19:03:03 -080088{
89 SecTpmOsx tpm;
90
Yingdi Yu5e96e002014-04-23 18:32:15 -070091 Name keyName("/TestSecTpmOsx/SignVerify/ksk-" +
Yingdi Yu7036ce22014-06-19 18:53:37 -070092 boost::lexical_cast<std::string>(
Yingdi Yu5e96e002014-04-23 18:32:15 -070093 time::toUnixTimestamp(time::system_clock::now()).count()));
Yingdi Yu7036ce22014-06-19 18:53:37 -070094 RsaKeyParams params(2048);
95 BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, params));
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070096
Yingdi Yube4150e2014-02-18 13:02:46 -080097 Data data("/TestSecTpmOsx/SignVaerify/Data/1");
Yingdi Yu28fd32f2014-01-28 19:03:03 -080098 const uint8_t content[] = {0x01, 0x02, 0x03, 0x04};
99
Yingdi Yu2e57a582014-02-20 23:34:43 -0800100 Block sigBlock;
Yingdi Yu5e96e002014-04-23 18:32:15 -0700101 BOOST_CHECK_NO_THROW(sigBlock = tpm.signInTpm(content, sizeof(content),
Yingdi Yu99b2a002015-08-12 12:47:44 -0700102 keyName, DigestAlgorithm::SHA256));
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800103
Alexander Afanasyev2fa59392016-07-29 17:24:23 -0700104 shared_ptr<v1::PublicKey> publicKey;
Yingdi Yu7036ce22014-06-19 18:53:37 -0700105 BOOST_CHECK_NO_THROW(publicKey = tpm.getPublicKeyFromTpm(keyName));
Yingdi Yu2e57a582014-02-20 23:34:43 -0800106 try
107 {
108 using namespace CryptoPP;
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800109
Yingdi Yu7036ce22014-06-19 18:53:37 -0700110 RSA::PublicKey rsaPublicKey;
Yingdi Yu2e57a582014-02-20 23:34:43 -0800111 ByteQueue queue;
Yingdi Yu7036ce22014-06-19 18:53:37 -0700112 queue.Put(reinterpret_cast<const byte*>(publicKey->get().buf()), publicKey->get().size());
113 rsaPublicKey.Load(queue);
Yingdi Yu2e57a582014-02-20 23:34:43 -0800114
Yingdi Yu7036ce22014-06-19 18:53:37 -0700115 RSASS<PKCS1v15, SHA256>::Verifier verifier(rsaPublicKey);
116 bool isVerified = verifier.VerifyMessage(content, sizeof(content),
117 sigBlock.value(), sigBlock.value_size());
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -0700118
Yingdi Yu7036ce22014-06-19 18:53:37 -0700119 BOOST_CHECK_EQUAL(isVerified, true);
Yingdi Yu2e57a582014-02-20 23:34:43 -0800120 }
Yingdi Yu5e96e002014-04-23 18:32:15 -0700121 catch (CryptoPP::Exception& e)
Yingdi Yu2e57a582014-02-20 23:34:43 -0800122 {
123 BOOST_CHECK(false);
124 }
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800125
126 tpm.deleteKeyPairInTpm(keyName);
127}
128
Alexander Afanasyevf82d13a2014-04-30 14:30:19 -0700129BOOST_AUTO_TEST_CASE(RandomGenerator)
Yingdi Yu4b752752014-02-18 12:24:03 -0800130{
131 SecTpmOsx tpm;
132
133 size_t scale = 1000;
134 size_t size = 256 * scale;
135 uint8_t* block = new uint8_t[size];
136 tpm.generateRandomBlock(block, size);
137
Yingdi Yu7036ce22014-06-19 18:53:37 -0700138 std::map<uint8_t, int> counter;
139 for (size_t i = 0; i < size; i++)
140 {
141 counter[block[i]] += 1;
142 }
Yingdi Yu4b752752014-02-18 12:24:03 -0800143
144 float dev = 0.0;
Yingdi Yu7036ce22014-06-19 18:53:37 -0700145 for (size_t i = 0; i != 255; i++)
146 {
147 dev += ((counter[i] - scale) * (counter[i] - scale)) * 1.0 / (scale * scale);
148 }
Yingdi Yu4b752752014-02-18 12:24:03 -0800149
150 BOOST_CHECK_CLOSE(dev / 256, 0.001, 100);
151
152}
Yingdi Yu8dceb1d2014-02-18 12:45:10 -0800153
Alexander Afanasyevf82d13a2014-04-30 14:30:19 -0700154BOOST_AUTO_TEST_CASE(ExportImportKey)
Yingdi Yu8dceb1d2014-02-18 12:45:10 -0800155{
156 using namespace CryptoPP;
157
158 SecTpmOsx tpm;
159
Yingdi Yu5e96e002014-04-23 18:32:15 -0700160 Name keyName("/TestSecTpmOsx/ExportImportKey/ksk-" +
Yingdi Yu7036ce22014-06-19 18:53:37 -0700161 boost::lexical_cast<std::string>(
Yingdi Yu5e96e002014-04-23 18:32:15 -0700162 time::toUnixTimestamp(time::system_clock::now()).count()));
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -0700163
Yingdi Yu7036ce22014-06-19 18:53:37 -0700164 RsaKeyParams params(2048);
165 BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, params));
Yingdi Yu8dceb1d2014-02-18 12:45:10 -0800166
Yingdi Yu99b2a002015-08-12 12:47:44 -0700167 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), true);
168 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), true);
Yingdi Yu8dceb1d2014-02-18 12:45:10 -0800169
Yingdi Yu2e57a582014-02-20 23:34:43 -0800170 ConstBufferPtr exported;
Yingdi Yu5e96e002014-04-23 18:32:15 -0700171 BOOST_CHECK_NO_THROW(exported = tpm.exportPrivateKeyPkcs5FromTpm(keyName, "1234"));
Alexander Afanasyev2fa59392016-07-29 17:24:23 -0700172 shared_ptr<v1::PublicKey> publicKey;
Yingdi Yu7036ce22014-06-19 18:53:37 -0700173 BOOST_REQUIRE_NO_THROW(publicKey = tpm.getPublicKeyFromTpm(keyName));
Yingdi Yu8dceb1d2014-02-18 12:45:10 -0800174
175 tpm.deleteKeyPairInTpm(keyName);
176
Yingdi Yu99b2a002015-08-12 12:47:44 -0700177 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), false);
178 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), false);
Yingdi Yu8dceb1d2014-02-18 12:45:10 -0800179
Yingdi Yu5e96e002014-04-23 18:32:15 -0700180 BOOST_REQUIRE(tpm.importPrivateKeyPkcs5IntoTpm(keyName,
181 exported->buf(), exported->size(),
182 "1234"));
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -0700183
Yingdi Yu99b2a002015-08-12 12:47:44 -0700184 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), true);
185 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), true);
Yingdi Yu8dceb1d2014-02-18 12:45:10 -0800186
187 const uint8_t content[] = {0x01, 0x02, 0x03, 0x04};
Yingdi Yu2e57a582014-02-20 23:34:43 -0800188 Block sigBlock;
Yingdi Yu5e96e002014-04-23 18:32:15 -0700189 BOOST_CHECK_NO_THROW(sigBlock = tpm.signInTpm(content, sizeof(content),
Yingdi Yu99b2a002015-08-12 12:47:44 -0700190 keyName, DigestAlgorithm::SHA256));
Yingdi Yu8dceb1d2014-02-18 12:45:10 -0800191
Yingdi Yu2e57a582014-02-20 23:34:43 -0800192 try
193 {
194 using namespace CryptoPP;
Yingdi Yu8dceb1d2014-02-18 12:45:10 -0800195
Yingdi Yu7036ce22014-06-19 18:53:37 -0700196 RSA::PublicKey rsaPublicKey;
Yingdi Yu2e57a582014-02-20 23:34:43 -0800197 ByteQueue queue;
Yingdi Yu7036ce22014-06-19 18:53:37 -0700198 queue.Put(reinterpret_cast<const byte*>(publicKey->get().buf()), publicKey->get().size());
199 rsaPublicKey.Load(queue);
Yingdi Yu2e57a582014-02-20 23:34:43 -0800200
Yingdi Yu7036ce22014-06-19 18:53:37 -0700201 RSASS<PKCS1v15, SHA256>::Verifier verifier(rsaPublicKey);
202 bool isVerified = verifier.VerifyMessage(content, sizeof(content),
203 sigBlock.value(), sigBlock.value_size());
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -0700204
Yingdi Yu7036ce22014-06-19 18:53:37 -0700205 BOOST_CHECK_EQUAL(isVerified, true);
Yingdi Yu2e57a582014-02-20 23:34:43 -0800206 }
Yingdi Yu5e96e002014-04-23 18:32:15 -0700207 catch (CryptoPP::Exception& e)
Yingdi Yu2e57a582014-02-20 23:34:43 -0800208 {
209 BOOST_CHECK(false);
210 }
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -0700211
Yingdi Yu8dceb1d2014-02-18 12:45:10 -0800212 tpm.deleteKeyPairInTpm(keyName);
Yingdi Yu9d9d5992014-06-25 12:25:16 -0700213 // This is some problem related to Mac OS Key chain.
214 // On OSX 10.8, we cannot delete imported keys, but there is no such problem on OSX 10.9.
215#ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
216#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_9
Yingdi Yu99b2a002015-08-12 12:47:44 -0700217 BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE) == false);
218 BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC) == false);
Yingdi Yu9d9d5992014-06-25 12:25:16 -0700219#endif
220#endif
Yingdi Yu8dceb1d2014-02-18 12:45:10 -0800221}
222
Alexander Afanasyevf82d13a2014-04-30 14:30:19 -0700223BOOST_AUTO_TEST_CASE(NonExistingKey)
224{
225 using namespace CryptoPP;
226
227 SecTpmOsx tpm;
228
229 Name keyName("/TestSecTpmOsx/NonExistingKey");
230
231 BOOST_REQUIRE_THROW(tpm.getPublicKeyFromTpm(keyName), SecTpmOsx::Error);
232
233 const uint8_t content[] = {0x01, 0x02, 0x03, 0x04};
Yingdi Yu99b2a002015-08-12 12:47:44 -0700234 BOOST_REQUIRE_THROW(tpm.signInTpm(content, sizeof(content), keyName, DigestAlgorithm::SHA256),
Alexander Afanasyevf82d13a2014-04-30 14:30:19 -0700235 SecTpmOsx::Error);
236
Yingdi Yu99b2a002015-08-12 12:47:44 -0700237 BOOST_REQUIRE_THROW(tpm.signInTpm(0, 1, keyName, DigestAlgorithm::SHA256),
Alexander Afanasyevf82d13a2014-04-30 14:30:19 -0700238 SecTpmOsx::Error);
239}
240
Yingdi Yuc8f883c2014-06-20 23:25:22 -0700241BOOST_AUTO_TEST_CASE(EcdsaSigning)
242{
243 SecTpmOsx tpm;
244
245 Name keyName("/TestSecTpmOsx/EcdsaSigning/ksk-" +
246 boost::lexical_cast<std::string>(time::toUnixTimestamp(time::system_clock::now())));
247 EcdsaKeyParams params;
248 BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, params));
249
250 Data data("/TestSecTpmOsx/EcdsaSigning/Data/1");
251 const uint8_t content[] = {0x01, 0x02, 0x03, 0x04};
252
253 Block sigBlock;
254 BOOST_CHECK_NO_THROW(sigBlock = tpm.signInTpm(content, sizeof(content),
Yingdi Yu99b2a002015-08-12 12:47:44 -0700255 keyName, DigestAlgorithm::SHA256));
Yingdi Yuc8f883c2014-06-20 23:25:22 -0700256
Alexander Afanasyev2fa59392016-07-29 17:24:23 -0700257 shared_ptr<v1::PublicKey> pubkeyPtr;
Yingdi Yuc8f883c2014-06-20 23:25:22 -0700258 BOOST_CHECK_NO_THROW(pubkeyPtr = tpm.getPublicKeyFromTpm(keyName));
259
260 try
261 {
262 using namespace CryptoPP;
263
264 ECDSA<ECP, SHA256>::PublicKey publicKey;
265 ByteQueue queue;
266 queue.Put(reinterpret_cast<const byte*>(pubkeyPtr->get().buf()), pubkeyPtr->get().size());
267 publicKey.Load(queue);
268
269 uint8_t buffer[64];
270 size_t usedSize = DSAConvertSignatureFormat(buffer, 64, DSA_P1363,
271 sigBlock.value(), sigBlock.value_size(), DSA_DER);
272
273 ECDSA<ECP, SHA256>::Verifier verifier(publicKey);
274 bool result = verifier.VerifyMessage(content, sizeof(content),
275 buffer, usedSize);
276
277 BOOST_CHECK_EQUAL(result, true);
278 }
279 catch (CryptoPP::Exception& e)
280 {
281 BOOST_CHECK(false);
282 }
283
284 tpm.deleteKeyPairInTpm(keyName);
285}
Alexander Afanasyevf82d13a2014-04-30 14:30:19 -0700286
Yingdi Yu9d9d5992014-06-25 12:25:16 -0700287
288BOOST_AUTO_TEST_CASE(ExportImportEcdsaKey)
289{
290 using namespace CryptoPP;
291
292 SecTpmOsx tpm;
293
294 Name keyName("/TestSecTpmOsx/ExportImportEcdsaKey/ksk-" +
295 boost::lexical_cast<std::string>(
296 time::toUnixTimestamp(time::system_clock::now()).count()));
297
298 EcdsaKeyParams params;
299 BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, params));
300
Yingdi Yu99b2a002015-08-12 12:47:44 -0700301 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), true);
302 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), true);
Yingdi Yu9d9d5992014-06-25 12:25:16 -0700303
304 ConstBufferPtr exported;
305 BOOST_CHECK_NO_THROW(exported = tpm.exportPrivateKeyPkcs5FromTpm(keyName, "1234"));
306
Alexander Afanasyev2fa59392016-07-29 17:24:23 -0700307 shared_ptr<v1::PublicKey> publicKey;
Yingdi Yu9d9d5992014-06-25 12:25:16 -0700308 BOOST_REQUIRE_NO_THROW(publicKey = tpm.getPublicKeyFromTpm(keyName));
309
310 tpm.deleteKeyPairInTpm(keyName);
311
Yingdi Yu99b2a002015-08-12 12:47:44 -0700312 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), false);
313 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), false);
Yingdi Yu9d9d5992014-06-25 12:25:16 -0700314
315 BOOST_REQUIRE(tpm.importPrivateKeyPkcs5IntoTpm(keyName,
316 exported->buf(), exported->size(),
317 "1234"));
318
Yingdi Yu99b2a002015-08-12 12:47:44 -0700319 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), true);
320 BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), true);
Yingdi Yu9d9d5992014-06-25 12:25:16 -0700321
322 const uint8_t content[] = {0x01, 0x02, 0x03, 0x04};
323 Block sigBlock;
324 BOOST_CHECK_NO_THROW(sigBlock = tpm.signInTpm(content, sizeof(content),
Yingdi Yu99b2a002015-08-12 12:47:44 -0700325 keyName, DigestAlgorithm::SHA256));
Yingdi Yu9d9d5992014-06-25 12:25:16 -0700326
327 try
328 {
329 using namespace CryptoPP;
330
331 ECDSA<ECP, SHA256>::PublicKey ecdsaPublicKey;
332 ByteQueue queue;
333 queue.Put(reinterpret_cast<const byte*>(publicKey->get().buf()), publicKey->get().size());
334 ecdsaPublicKey.Load(queue);
335
336 uint8_t buffer[64];
337 size_t usedSize = DSAConvertSignatureFormat(buffer, 64, DSA_P1363,
338 sigBlock.value(), sigBlock.value_size(),
339 DSA_DER);
340
341 ECDSA<ECP, SHA256>::Verifier verifier(ecdsaPublicKey);
342 bool isVerified = verifier.VerifyMessage(content, sizeof(content),
343 buffer, usedSize);
344
345 BOOST_CHECK_EQUAL(isVerified, true);
346 }
347 catch (CryptoPP::Exception& e)
348 {
349 BOOST_CHECK(false);
350 }
351
352 tpm.deleteKeyPairInTpm(keyName);
353 // This is some problem related to Mac OS Key chain.
354 // On OSX 10.8, we cannot delete imported keys, but there is no such problem on OSX 10.9.
355#ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
356#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_9
Yingdi Yu99b2a002015-08-12 12:47:44 -0700357 BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE) == false);
358 BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC) == false);
Yingdi Yu9d9d5992014-06-25 12:25:16 -0700359#endif
360#endif
361}
362
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800363BOOST_AUTO_TEST_SUITE_END()
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -0800364
Spyridon Mastorakis429634f2015-02-19 17:35:33 -0800365} // namespace tests
Alexander Afanasyev2fa59392016-07-29 17:24:23 -0700366} // namespace security
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -0800367} // namespace ndn