security: change enum to enum class in security-common.hpp
Change-Id: I5565c845cd57f3457c8120b11399a105fa83418d
Refs: #3083
diff --git a/tests/unit-tests/security/dummy-keychain.cpp b/tests/unit-tests/security/dummy-keychain.cpp
index c7e7a10..27eccb2 100644
--- a/tests/unit-tests/security/dummy-keychain.cpp
+++ b/tests/unit-tests/security/dummy-keychain.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -127,7 +127,7 @@
KeyType
DummyPublicInfo::getPublicKeyType(const Name& keyName)
{
- return KEY_TYPE_RSA;
+ return KeyType::RSA;
}
bool
diff --git a/tests/unit-tests/security/key-chain.t.cpp b/tests/unit-tests/security/key-chain.t.cpp
index eda972b..5d8195a 100644
--- a/tests/unit-tests/security/key-chain.t.cpp
+++ b/tests/unit-tests/security/key-chain.t.cpp
@@ -160,8 +160,8 @@
BOOST_CHECK_EQUAL(m_keyChain.doesIdentityExist(identity), false);
BOOST_CHECK_EQUAL(m_keyChain.doesPublicKeyExist(keyName), false);
- BOOST_CHECK_EQUAL(m_keyChain.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), false);
- BOOST_CHECK_EQUAL(m_keyChain.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), false);
+ BOOST_CHECK_EQUAL(m_keyChain.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), false);
+ BOOST_CHECK_EQUAL(m_keyChain.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), false);
BOOST_CHECK_EQUAL(m_keyChain.doesCertificateExist(certName), false);
SecuredBag imported;
@@ -170,8 +170,8 @@
BOOST_CHECK(m_keyChain.doesIdentityExist(identity));
BOOST_CHECK(m_keyChain.doesPublicKeyExist(keyName));
- BOOST_CHECK(m_keyChain.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE));
- BOOST_CHECK(m_keyChain.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC));
+ BOOST_CHECK(m_keyChain.doesKeyExistInTpm(keyName, KeyClass::PRIVATE));
+ BOOST_CHECK(m_keyChain.doesKeyExistInTpm(keyName, KeyClass::PUBLIC));
BOOST_CHECK(m_keyChain.doesCertificateExist(certName));
}
@@ -406,14 +406,14 @@
BOOST_CHECK_NO_THROW(m_keyChain.sign(data, signingByIdentity(nonExistingIdentity)));
BOOST_CHECK_EQUAL(data.getSignature().getType(),
KeyChain::getSignatureType(KeyChain::DEFAULT_KEY_PARAMS.getKeyType(),
- DIGEST_ALGORITHM_SHA256));
+ DigestAlgorithm::SHA256));
BOOST_CHECK(nonExistingIdentity.isPrefixOf(data.getSignature().getKeyLocator().getName()));
Name ecdsaIdentity = Name("/ndn/test/ecdsa").appendVersion();
Name ecdsaKeyName = m_keyChain.generateEcdsaKeyPairAsDefault(ecdsaIdentity, false, 256);
BOOST_CHECK_NO_THROW(m_keyChain.sign(data, signingByIdentity(ecdsaIdentity)));
BOOST_CHECK_EQUAL(data.getSignature().getType(),
- KeyChain::getSignatureType(EcdsaKeyParams().getKeyType(), DIGEST_ALGORITHM_SHA256));
+ KeyChain::getSignatureType(EcdsaKeyParams().getKeyType(), DigestAlgorithm::SHA256));
BOOST_CHECK(ecdsaIdentity.isPrefixOf(data.getSignature().getKeyLocator().getName()));
}
diff --git a/tests/unit-tests/security/key-params.t.cpp b/tests/unit-tests/security/key-params.t.cpp
index 3cfc61c..66e30fe 100644
--- a/tests/unit-tests/security/key-params.t.cpp
+++ b/tests/unit-tests/security/key-params.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -32,49 +32,49 @@
BOOST_AUTO_TEST_CASE(RsaParameter)
{
RsaKeyParams params;
- BOOST_CHECK_EQUAL(params.getKeyType(), KEY_TYPE_RSA);
+ BOOST_CHECK_EQUAL(params.getKeyType(), KeyType::RSA);
BOOST_CHECK_EQUAL(params.getKeySize(), 2048);
RsaKeyParams params2(1024);
- BOOST_CHECK_EQUAL(params2.getKeyType(), KEY_TYPE_RSA);
+ BOOST_CHECK_EQUAL(params2.getKeyType(), KeyType::RSA);
BOOST_CHECK_EQUAL(params2.getKeySize(), 1024);
RsaKeyParams params3(3);
- BOOST_CHECK_EQUAL(params3.getKeyType(), KEY_TYPE_RSA);
+ BOOST_CHECK_EQUAL(params3.getKeyType(), KeyType::RSA);
BOOST_CHECK_EQUAL(params3.getKeySize(), 2048);
}
BOOST_AUTO_TEST_CASE(EcdsaParameter)
{
EcdsaKeyParams params;
- BOOST_CHECK_EQUAL(params.getKeyType(), KEY_TYPE_ECDSA);
+ BOOST_CHECK_EQUAL(params.getKeyType(), KeyType::EC);
BOOST_CHECK_EQUAL(params.getKeySize(), 256);
EcdsaKeyParams params2(384);
- BOOST_CHECK_EQUAL(params2.getKeyType(), KEY_TYPE_ECDSA);
+ BOOST_CHECK_EQUAL(params2.getKeyType(), KeyType::EC);
BOOST_CHECK_EQUAL(params2.getKeySize(), 384);
EcdsaKeyParams params3(3);
- BOOST_CHECK_EQUAL(params3.getKeyType(), KEY_TYPE_ECDSA);
+ BOOST_CHECK_EQUAL(params3.getKeyType(), KeyType::EC);
BOOST_CHECK_EQUAL(params3.getKeySize(), 256);
}
BOOST_AUTO_TEST_CASE(AesParameter)
{
AesKeyParams params;
- BOOST_CHECK_EQUAL(params.getKeyType(), KEY_TYPE_AES);
+ BOOST_CHECK_EQUAL(params.getKeyType(), KeyType::AES);
BOOST_CHECK_EQUAL(params.getKeySize(), 64);
AesKeyParams params2(128);
- BOOST_CHECK_EQUAL(params2.getKeyType(), KEY_TYPE_AES);
+ BOOST_CHECK_EQUAL(params2.getKeyType(), KeyType::AES);
BOOST_CHECK_EQUAL(params2.getKeySize(), 128);
AesKeyParams params3(256);
- BOOST_CHECK_EQUAL(params3.getKeyType(), KEY_TYPE_AES);
+ BOOST_CHECK_EQUAL(params3.getKeyType(), KeyType::AES);
BOOST_CHECK_EQUAL(params3.getKeySize(), 256);
AesKeyParams params4(4);
- BOOST_CHECK_EQUAL(params4.getKeyType(), KEY_TYPE_AES);
+ BOOST_CHECK_EQUAL(params4.getKeyType(), KeyType::AES);
BOOST_CHECK_EQUAL(params4.getKeySize(), 64);
}
diff --git a/tests/unit-tests/security/public-key.t.cpp b/tests/unit-tests/security/public-key.t.cpp
index 96fda58..ae85d4c 100644
--- a/tests/unit-tests/security/public-key.t.cpp
+++ b/tests/unit-tests/security/public-key.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -69,7 +69,7 @@
BOOST_REQUIRE_NO_THROW(publicKey = shared_ptr<PublicKey>(new PublicKey(os.buf()->buf(),
os.buf()->size())));
- BOOST_CHECK_EQUAL(publicKey->getKeyType(), KEY_TYPE_RSA);
+ BOOST_CHECK_EQUAL(publicKey->getKeyType(), KeyType::RSA);
Block digestBlock(RSA_DER_KEY_DIGEST, sizeof(RSA_DER_KEY_DIGEST));
const Block& digest = publicKey->computeDigest();
@@ -91,7 +91,7 @@
BOOST_REQUIRE_NO_THROW(publicKey = shared_ptr<PublicKey>(new PublicKey(os.buf()->buf(),
os.buf()->size())));
- BOOST_CHECK_EQUAL(publicKey->getKeyType(), KEY_TYPE_ECDSA);
+ BOOST_CHECK_EQUAL(publicKey->getKeyType(), KeyType::EC);
Block digestBlock(ECDSA_DER_KEY_DIGEST, sizeof(ECDSA_DER_KEY_DIGEST));
const Block& digest = publicKey->computeDigest();
diff --git a/tests/unit-tests/security/sec-public-info-sqlite3.t.cpp b/tests/unit-tests/security/sec-public-info-sqlite3.t.cpp
index 2828b0a..b57747c 100644
--- a/tests/unit-tests/security/sec-public-info-sqlite3.t.cpp
+++ b/tests/unit-tests/security/sec-public-info-sqlite3.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -111,7 +111,7 @@
SecPublicInfoSqlite3 pib;
pib.addKey(rsaKeyName, *rsaKey);
- BOOST_CHECK_EQUAL(KEY_TYPE_RSA, pib.getPublicKeyType(rsaKeyName));
+ BOOST_CHECK_EQUAL(KeyType::RSA, pib.getPublicKeyType(rsaKeyName));
pib.deleteIdentityInfo(Name("/TestSecPublicInfoSqlite3/KeyType/RSA"));
}
@@ -131,7 +131,7 @@
SecPublicInfoSqlite3 pib;
pib.addKey(ecdsaKeyName, *ecdsaKey);
- BOOST_CHECK_EQUAL(KEY_TYPE_ECDSA, pib.getPublicKeyType(ecdsaKeyName));
+ BOOST_CHECK_EQUAL(KeyType::EC, pib.getPublicKeyType(ecdsaKeyName));
pib.deleteIdentityInfo(Name("/TestSecPublicInfoSqlite3/KeyType/ECDSA"));
}
@@ -140,7 +140,7 @@
Name nullKeyName("/TestSecPublicInfoSqlite3/KeyType/Null");
SecPublicInfoSqlite3 pib;
- BOOST_CHECK_EQUAL(KEY_TYPE_NULL, pib.getPublicKeyType(nullKeyName));
+ BOOST_CHECK_EQUAL(KeyType::NONE, pib.getPublicKeyType(nullKeyName));
}
diff --git a/tests/unit-tests/security/sec-tpm-file.t.cpp b/tests/unit-tests/security/sec-tpm-file.t.cpp
index 07c867c..ca73c70 100644
--- a/tests/unit-tests/security/sec-tpm-file.t.cpp
+++ b/tests/unit-tests/security/sec-tpm-file.t.cpp
@@ -43,13 +43,13 @@
RsaKeyParams params(2048);
BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, params));
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), true);
tpm.deleteKeyPairInTpm(keyName);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), false);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), false);
}
BOOST_AUTO_TEST_CASE(SignVerify)
@@ -66,7 +66,7 @@
Block sigBlock;
BOOST_CHECK_NO_THROW(sigBlock = tpm.signInTpm(content, sizeof(content),
- keyName, DIGEST_ALGORITHM_SHA256));
+ keyName, DigestAlgorithm::SHA256));
shared_ptr<PublicKey> publicKey;
BOOST_CHECK_NO_THROW(publicKey = tpm.getPublicKeyFromTpm(keyName));
@@ -157,8 +157,8 @@
Name keyName("/TestSecTpmFile/ImportKey/ksk-" +
boost::lexical_cast<std::string>(time::toUnixTimestamp(time::system_clock::now())));
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), false);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), false);
BOOST_REQUIRE_NO_THROW(
tpm.importPrivateKeyPkcs5IntoTpm(keyName,
@@ -166,8 +166,8 @@
decoded.size(),
"1234"));
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), true);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), true);
shared_ptr<PublicKey> publicKey;
BOOST_CHECK_NO_THROW(publicKey = tpm.getPublicKeyFromTpm(keyName));
@@ -175,7 +175,7 @@
const uint8_t content[] = {0x01, 0x02, 0x03, 0x04};
Block sigBlock;
BOOST_CHECK_NO_THROW(sigBlock = tpm.signInTpm(content, sizeof(content),
- keyName, DIGEST_ALGORITHM_SHA256));
+ keyName, DigestAlgorithm::SHA256));
try
{
@@ -202,19 +202,19 @@
tpm.deleteKeyPairInTpm(keyName);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), false);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), false);
BOOST_REQUIRE(tpm.importPrivateKeyPkcs5IntoTpm(keyName, exported->buf(), exported->size(),
"5678"));
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), true);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), true);
const uint8_t content2[] = {0x05, 0x06, 0x07, 0x08};
Block sigBlock2;
BOOST_CHECK_NO_THROW(sigBlock2 = tpm.signInTpm(content2, sizeof(content2),
- keyName, DIGEST_ALGORITHM_SHA256));
+ keyName, DigestAlgorithm::SHA256));
try
{
@@ -238,8 +238,8 @@
tpm.deleteKeyPairInTpm(keyName);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), false);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), false);
}
BOOST_AUTO_TEST_CASE(EcdsaSigning)
@@ -256,7 +256,7 @@
Block sigBlock;
BOOST_CHECK_NO_THROW(sigBlock = tpm.signInTpm(content, sizeof(content),
- keyName, DIGEST_ALGORITHM_SHA256));
+ keyName, DigestAlgorithm::SHA256));
shared_ptr<PublicKey> pubkeyPtr;
BOOST_CHECK_NO_THROW(pubkeyPtr = tpm.getPublicKeyFromTpm(keyName));
@@ -308,8 +308,8 @@
Name keyName("/TestSecTpmFile/ImportExportEcdsaKey/ksk-" +
boost::lexical_cast<std::string>(time::toUnixTimestamp(time::system_clock::now())));
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), false);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), false);
BOOST_REQUIRE_NO_THROW(
tpm.importPrivateKeyPkcs5IntoTpm(keyName,
@@ -317,8 +317,8 @@
decoded.size(),
"5678"));
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), true);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), true);
shared_ptr<PublicKey> publicKey;
BOOST_CHECK_NO_THROW(publicKey = tpm.getPublicKeyFromTpm(keyName));
@@ -326,7 +326,7 @@
const uint8_t content[] = {0x01, 0x02, 0x03, 0x04};
Block sigBlock;
BOOST_CHECK_NO_THROW(sigBlock = tpm.signInTpm(content, sizeof(content),
- keyName, DIGEST_ALGORITHM_SHA256));
+ keyName, DigestAlgorithm::SHA256));
try
{
@@ -357,19 +357,19 @@
tpm.deleteKeyPairInTpm(keyName);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), false);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), false);
BOOST_REQUIRE(tpm.importPrivateKeyPkcs5IntoTpm(keyName, exported->buf(), exported->size(),
"1234"));
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), true);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), true);
const uint8_t content2[] = {0x05, 0x06, 0x07, 0x08};
Block sigBlock2;
BOOST_CHECK_NO_THROW(sigBlock2 = tpm.signInTpm(content2, sizeof(content2),
- keyName, DIGEST_ALGORITHM_SHA256));
+ keyName, DigestAlgorithm::SHA256));
try
{
@@ -399,8 +399,8 @@
tpm.deleteKeyPairInTpm(keyName);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), false);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), false);
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/unit-tests/security/sec-tpm-osx.t.cpp b/tests/unit-tests/security/sec-tpm-osx.t.cpp
index 1e590af..ee9f96b 100644
--- a/tests/unit-tests/security/sec-tpm-osx.t.cpp
+++ b/tests/unit-tests/security/sec-tpm-osx.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -74,13 +74,13 @@
RsaKeyParams params(2048);
BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, params));
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), true);
tpm.deleteKeyPairInTpm(keyName);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), false);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), false);
}
BOOST_AUTO_TEST_CASE(SignVerify)
@@ -98,7 +98,7 @@
Block sigBlock;
BOOST_CHECK_NO_THROW(sigBlock = tpm.signInTpm(content, sizeof(content),
- keyName, DIGEST_ALGORITHM_SHA256));
+ keyName, DigestAlgorithm::SHA256));
shared_ptr<PublicKey> publicKey;
BOOST_CHECK_NO_THROW(publicKey = tpm.getPublicKeyFromTpm(keyName));
@@ -163,8 +163,8 @@
RsaKeyParams params(2048);
BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, params));
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), true);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), true);
ConstBufferPtr exported;
BOOST_CHECK_NO_THROW(exported = tpm.exportPrivateKeyPkcs5FromTpm(keyName, "1234"));
@@ -173,20 +173,20 @@
tpm.deleteKeyPairInTpm(keyName);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), false);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), false);
BOOST_REQUIRE(tpm.importPrivateKeyPkcs5IntoTpm(keyName,
exported->buf(), exported->size(),
"1234"));
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), true);
const uint8_t content[] = {0x01, 0x02, 0x03, 0x04};
Block sigBlock;
BOOST_CHECK_NO_THROW(sigBlock = tpm.signInTpm(content, sizeof(content),
- keyName, DIGEST_ALGORITHM_SHA256));
+ keyName, DigestAlgorithm::SHA256));
try
{
@@ -213,8 +213,8 @@
// On OSX 10.8, we cannot delete imported keys, but there is no such problem on OSX 10.9.
#ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_9
- BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == false);
- BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == false);
+ BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE) == false);
+ BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC) == false);
#endif
#endif
}
@@ -230,10 +230,10 @@
BOOST_REQUIRE_THROW(tpm.getPublicKeyFromTpm(keyName), SecTpmOsx::Error);
const uint8_t content[] = {0x01, 0x02, 0x03, 0x04};
- BOOST_REQUIRE_THROW(tpm.signInTpm(content, sizeof(content), keyName, DIGEST_ALGORITHM_SHA256),
+ BOOST_REQUIRE_THROW(tpm.signInTpm(content, sizeof(content), keyName, DigestAlgorithm::SHA256),
SecTpmOsx::Error);
- BOOST_REQUIRE_THROW(tpm.signInTpm(0, 1, keyName, DIGEST_ALGORITHM_SHA256),
+ BOOST_REQUIRE_THROW(tpm.signInTpm(0, 1, keyName, DigestAlgorithm::SHA256),
SecTpmOsx::Error);
}
@@ -251,7 +251,7 @@
Block sigBlock;
BOOST_CHECK_NO_THROW(sigBlock = tpm.signInTpm(content, sizeof(content),
- keyName, DIGEST_ALGORITHM_SHA256));
+ keyName, DigestAlgorithm::SHA256));
shared_ptr<PublicKey> pubkeyPtr;
BOOST_CHECK_NO_THROW(pubkeyPtr = tpm.getPublicKeyFromTpm(keyName));
@@ -297,8 +297,8 @@
EcdsaKeyParams params;
BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, params));
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), true);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), true);
ConstBufferPtr exported;
BOOST_CHECK_NO_THROW(exported = tpm.exportPrivateKeyPkcs5FromTpm(keyName, "1234"));
@@ -308,20 +308,20 @@
tpm.deleteKeyPairInTpm(keyName);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), false);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), false);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), false);
BOOST_REQUIRE(tpm.importPrivateKeyPkcs5IntoTpm(keyName,
exported->buf(), exported->size(),
"1234"));
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
- BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC), true);
+ BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE), true);
const uint8_t content[] = {0x01, 0x02, 0x03, 0x04};
Block sigBlock;
BOOST_CHECK_NO_THROW(sigBlock = tpm.signInTpm(content, sizeof(content),
- keyName, DIGEST_ALGORITHM_SHA256));
+ keyName, DigestAlgorithm::SHA256));
try
{
@@ -353,8 +353,8 @@
// On OSX 10.8, we cannot delete imported keys, but there is no such problem on OSX 10.9.
#ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_9
- BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == false);
- BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == false);
+ BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KeyClass::PRIVATE) == false);
+ BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KeyClass::PUBLIC) == false);
#endif
#endif
}
diff --git a/tests/unit-tests/security/signing-info.t.cpp b/tests/unit-tests/security/signing-info.t.cpp
index e75efd1..994cb2a 100644
--- a/tests/unit-tests/security/signing-info.t.cpp
+++ b/tests/unit-tests/security/signing-info.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -43,7 +43,7 @@
BOOST_CHECK_EQUAL(info.getSignerType(), SigningInfo::SIGNER_TYPE_NULL);
BOOST_CHECK_EQUAL(info.getSignerName(), SigningInfo::EMPTY_NAME);
- BOOST_CHECK_EQUAL(info.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
+ BOOST_CHECK_EQUAL(info.getDigestAlgorithm(), DigestAlgorithm::SHA256);
const SignatureInfo& sigInfo = info.getSignatureInfo();
BOOST_CHECK_EQUAL(sigInfo.getSignatureType(), -1);
@@ -52,42 +52,42 @@
info.setSigningIdentity(id);
BOOST_CHECK_EQUAL(info.getSignerType(), SigningInfo::SIGNER_TYPE_ID);
BOOST_CHECK_EQUAL(info.getSignerName(), id);
- BOOST_CHECK_EQUAL(info.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
+ BOOST_CHECK_EQUAL(info.getDigestAlgorithm(), DigestAlgorithm::SHA256);
SigningInfo infoId(SigningInfo::SIGNER_TYPE_ID, id);
BOOST_CHECK_EQUAL(infoId.getSignerType(), SigningInfo::SIGNER_TYPE_ID);
BOOST_CHECK_EQUAL(infoId.getSignerName(), id);
- BOOST_CHECK_EQUAL(infoId.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
+ BOOST_CHECK_EQUAL(infoId.getDigestAlgorithm(), DigestAlgorithm::SHA256);
info.setSigningKeyName(key);
BOOST_CHECK_EQUAL(info.getSignerType(), SigningInfo::SIGNER_TYPE_KEY);
BOOST_CHECK_EQUAL(info.getSignerName(), key);
- BOOST_CHECK_EQUAL(info.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
+ BOOST_CHECK_EQUAL(info.getDigestAlgorithm(), DigestAlgorithm::SHA256);
SigningInfo infoKey(SigningInfo::SIGNER_TYPE_KEY, key);
BOOST_CHECK_EQUAL(infoKey.getSignerType(), SigningInfo::SIGNER_TYPE_KEY);
BOOST_CHECK_EQUAL(infoKey.getSignerName(), key);
- BOOST_CHECK_EQUAL(infoKey.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
+ BOOST_CHECK_EQUAL(infoKey.getDigestAlgorithm(), DigestAlgorithm::SHA256);
info.setSigningCertName(cert);
BOOST_CHECK_EQUAL(info.getSignerType(), SigningInfo::SIGNER_TYPE_CERT);
BOOST_CHECK_EQUAL(info.getSignerName(), cert);
- BOOST_CHECK_EQUAL(info.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
+ BOOST_CHECK_EQUAL(info.getDigestAlgorithm(), DigestAlgorithm::SHA256);
SigningInfo infoCert(SigningInfo::SIGNER_TYPE_CERT, cert);
BOOST_CHECK_EQUAL(infoCert.getSignerType(), SigningInfo::SIGNER_TYPE_CERT);
BOOST_CHECK_EQUAL(infoCert.getSignerName(), cert);
- BOOST_CHECK_EQUAL(infoCert.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
+ BOOST_CHECK_EQUAL(infoCert.getDigestAlgorithm(), DigestAlgorithm::SHA256);
info.setSha256Signing();
BOOST_CHECK_EQUAL(info.getSignerType(), SigningInfo::SIGNER_TYPE_SHA256);
BOOST_CHECK_EQUAL(info.getSignerName(), SigningInfo::EMPTY_NAME);
- BOOST_CHECK_EQUAL(info.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
+ BOOST_CHECK_EQUAL(info.getDigestAlgorithm(), DigestAlgorithm::SHA256);
SigningInfo infoSha(SigningInfo::SIGNER_TYPE_SHA256);
BOOST_CHECK_EQUAL(infoSha.getSignerType(), SigningInfo::SIGNER_TYPE_SHA256);
BOOST_CHECK_EQUAL(infoSha.getSignerName(), SigningInfo::EMPTY_NAME);
- BOOST_CHECK_EQUAL(infoSha.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
+ BOOST_CHECK_EQUAL(infoSha.getDigestAlgorithm(), DigestAlgorithm::SHA256);
}
BOOST_AUTO_TEST_CASE(CustomSignatureInfo)
@@ -110,27 +110,27 @@
SigningInfo infoDefault("");
BOOST_CHECK_EQUAL(infoDefault.getSignerType(), SigningInfo::SIGNER_TYPE_NULL);
BOOST_CHECK_EQUAL(infoDefault.getSignerName(), SigningInfo::EMPTY_NAME);
- BOOST_CHECK_EQUAL(infoDefault.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
+ BOOST_CHECK_EQUAL(infoDefault.getDigestAlgorithm(), DigestAlgorithm::SHA256);
SigningInfo infoId("id:/my-identity");
BOOST_CHECK_EQUAL(infoId.getSignerType(), SigningInfo::SIGNER_TYPE_ID);
BOOST_CHECK_EQUAL(infoId.getSignerName(), "/my-identity");
- BOOST_CHECK_EQUAL(infoId.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
+ BOOST_CHECK_EQUAL(infoId.getDigestAlgorithm(), DigestAlgorithm::SHA256);
SigningInfo infoKey("key:/my-key");
BOOST_CHECK_EQUAL(infoKey.getSignerType(), SigningInfo::SIGNER_TYPE_KEY);
BOOST_CHECK_EQUAL(infoKey.getSignerName(), "/my-key");
- BOOST_CHECK_EQUAL(infoKey.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
+ BOOST_CHECK_EQUAL(infoKey.getDigestAlgorithm(), DigestAlgorithm::SHA256);
SigningInfo infoCert("cert:/my-cert");
BOOST_CHECK_EQUAL(infoCert.getSignerType(), SigningInfo::SIGNER_TYPE_CERT);
BOOST_CHECK_EQUAL(infoCert.getSignerName(), "/my-cert");
- BOOST_CHECK_EQUAL(infoCert.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
+ BOOST_CHECK_EQUAL(infoCert.getDigestAlgorithm(), DigestAlgorithm::SHA256);
SigningInfo infoSha("id:/localhost/identity/digest-sha256");
BOOST_CHECK_EQUAL(infoSha.getSignerType(), SigningInfo::SIGNER_TYPE_SHA256);
BOOST_CHECK_EQUAL(infoSha.getSignerName(), SigningInfo::EMPTY_NAME);
- BOOST_CHECK_EQUAL(infoSha.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
+ BOOST_CHECK_EQUAL(infoSha.getDigestAlgorithm(), DigestAlgorithm::SHA256);
}
BOOST_AUTO_TEST_CASE(ToString)
diff --git a/tests/unit-tests/security/transform/digest-filter.t.cpp b/tests/unit-tests/security/transform/digest-filter.t.cpp
index f00599c..c6e296f 100644
--- a/tests/unit-tests/security/transform/digest-filter.t.cpp
+++ b/tests/unit-tests/security/transform/digest-filter.t.cpp
@@ -65,7 +65,7 @@
};
OBufferStream os;
- bufferSource(in, sizeof(in)) >> digestFilter(DIGEST_ALGORITHM_SHA256) >> streamSink(os);
+ bufferSource(in, sizeof(in)) >> digestFilter(DigestAlgorithm::SHA256) >> streamSink(os);
ConstBufferPtr buf = os.buf();
BOOST_CHECK_EQUAL_COLLECTIONS(out, out + sizeof(out), buf->begin(), buf->end());
@@ -101,7 +101,7 @@
StepSource source;
OBufferStream os;
- source >> digestFilter(DIGEST_ALGORITHM_SHA256) >> streamSink(os);
+ source >> digestFilter(DigestAlgorithm::SHA256) >> streamSink(os);
source.write(in, 32);
source.write(in + 32, 1);
source.write(in + 33, 2);
@@ -125,7 +125,7 @@
OBufferStream os;
StepSource source;
- source >> digestFilter(DIGEST_ALGORITHM_SHA256) >> streamSink(os);
+ source >> digestFilter(DigestAlgorithm::SHA256) >> streamSink(os);
source.end();
ConstBufferPtr buf = os.buf();
@@ -135,7 +135,7 @@
BOOST_AUTO_TEST_CASE(Error)
{
OBufferStream os;
- BOOST_REQUIRE_THROW(stepSource() >> digestFilter(DIGEST_ALGORITHM_NONE) >> streamSink(os),
+ BOOST_REQUIRE_THROW(stepSource() >> digestFilter(DigestAlgorithm::NONE) >> streamSink(os),
transform::Error);
}
diff --git a/tests/unit-tests/security/transform/hmac-filter.t.cpp b/tests/unit-tests/security/transform/hmac-filter.t.cpp
index 4ff6a15..ccb5feb 100644
--- a/tests/unit-tests/security/transform/hmac-filter.t.cpp
+++ b/tests/unit-tests/security/transform/hmac-filter.t.cpp
@@ -56,7 +56,7 @@
};
OBufferStream os;
- bufferSource(data, sizeof(data)) >> hmacFilter(DIGEST_ALGORITHM_SHA256, key, sizeof(key)) >> streamSink(os);
+ bufferSource(data, sizeof(data)) >> hmacFilter(DigestAlgorithm::SHA256, key, sizeof(key)) >> streamSink(os);
ConstBufferPtr buf = os.buf();
BOOST_CHECK_EQUAL_COLLECTIONS(digest, digest + sizeof(digest), buf->begin(), buf->end());
@@ -83,7 +83,7 @@
OBufferStream os;
StepSource source;
- source >> hmacFilter(DIGEST_ALGORITHM_SHA256, key, sizeof(key)) >> streamSink(os);
+ source >> hmacFilter(DigestAlgorithm::SHA256, key, sizeof(key)) >> streamSink(os);
source.write(data, 1);
source.write(data + 1, 2);
source.write(data + 3, 3);
@@ -112,7 +112,7 @@
OBufferStream os;
StepSource source;
- source >> hmacFilter(DIGEST_ALGORITHM_SHA256, key, sizeof(key)) >> streamSink(os);
+ source >> hmacFilter(DigestAlgorithm::SHA256, key, sizeof(key)) >> streamSink(os);
source.end();
ConstBufferPtr buf = os.buf();
@@ -127,7 +127,7 @@
};
OBufferStream os;
- BOOST_REQUIRE_THROW(stepSource() >> hmacFilter(DIGEST_ALGORITHM_NONE, key, sizeof(key)) >> streamSink(os),
+ BOOST_REQUIRE_THROW(stepSource() >> hmacFilter(DigestAlgorithm::NONE, key, sizeof(key)) >> streamSink(os),
transform::Error);
}