encoding: remove duplicate buf() and get() methods from Buffer class
Change-Id: If885d4199d6c9df9b9b46664c3641c9a14a77eab
diff --git a/tests/unit-tests/security/digest-sha256.t.cpp b/tests/unit-tests/security/digest-sha256.t.cpp
index 7855058..f3d7bb7 100644
--- a/tests/unit-tests/security/digest-sha256.t.cpp
+++ b/tests/unit-tests/security/digest-sha256.t.cpp
@@ -41,7 +41,7 @@
char content[6] = "1234\n";
ConstBufferPtr buf = util::Sha256::computeDigest(reinterpret_cast<uint8_t*>(content), 5);
- BOOST_CHECK_EQUAL(toHex(buf->buf(), buf->size(), false),
+ BOOST_CHECK_EQUAL(toHex(buf->data(), buf->size(), false),
"a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4");
}
diff --git a/tests/unit-tests/security/pib/detail/identity-impl.t.cpp b/tests/unit-tests/security/pib/detail/identity-impl.t.cpp
index 2f35d2f..0eaabdb 100644
--- a/tests/unit-tests/security/pib/detail/identity-impl.t.cpp
+++ b/tests/unit-tests/security/pib/detail/identity-impl.t.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -22,9 +22,9 @@
#include "security/pib/detail/identity-impl.hpp"
#include "security/pib/pib.hpp"
#include "security/pib/pib-memory.hpp"
-#include "../pib-data-fixture.hpp"
#include "boost-test.hpp"
+#include "../pib-data-fixture.hpp"
namespace ndn {
namespace security {
@@ -64,7 +64,7 @@
BOOST_REQUIRE_THROW(identity1.setDefaultKey(id1Key1Name), Pib::Error);
// add key
- identity1.addKey(id1Key1.buf(), id1Key1.size(), id1Key1Name);
+ identity1.addKey(id1Key1.data(), id1Key1.size(), id1Key1Name);
BOOST_CHECK_NO_THROW(identity1.getKey(id1Key1Name));
// new key becomes default key when there is no default key
@@ -79,7 +79,7 @@
BOOST_CHECK_THROW(identity1.getDefaultKey(), Pib::Error);
// set default key directly
- BOOST_REQUIRE_NO_THROW(identity1.setDefaultKey(id1Key1.buf(), id1Key1.size(), id1Key1Name));
+ BOOST_REQUIRE_NO_THROW(identity1.setDefaultKey(id1Key1.data(), id1Key1.size(), id1Key1Name));
BOOST_REQUIRE_NO_THROW(identity1.getDefaultKey());
BOOST_CHECK_NO_THROW(identity1.getKey(id1Key1Name));
@@ -89,7 +89,7 @@
BOOST_CHECK(defaultKey1.getPublicKey() == id1Key1);
// add another key
- identity1.addKey(id1Key2.buf(), id1Key2.size(), id1Key2Name);
+ identity1.addKey(id1Key2.data(), id1Key2.size(), id1Key2Name);
BOOST_CHECK_EQUAL(identity1.getKeys().size(), 2);
// set default key through name
@@ -105,7 +105,7 @@
BOOST_CHECK_EQUAL(identity1.getKeys().size(), 1);
// set default key directly again, change the default setting
- BOOST_REQUIRE_NO_THROW(identity1.setDefaultKey(id1Key1.buf(), id1Key1.size(), id1Key1Name));
+ BOOST_REQUIRE_NO_THROW(identity1.setDefaultKey(id1Key1.data(), id1Key1.size(), id1Key1Name));
const Key& defaultKey3 = identity1.getDefaultKey();
BOOST_CHECK_EQUAL(defaultKey3.getName(), id1Key1Name);
BOOST_CHECK(defaultKey3.getPublicKey() == id1Key1);
@@ -126,10 +126,10 @@
auto pibImpl = make_shared<pib::PibMemory>();
IdentityImpl identity1(id1, pibImpl, true);
- identity1.addKey(id1Key1.buf(), id1Key1.size(), id1Key1Name);
+ identity1.addKey(id1Key1.data(), id1Key1.size(), id1Key1Name);
BOOST_CHECK(identity1.getKey(id1Key1Name).getPublicKey() == id1Key1);
- identity1.addKey(id1Key2.buf(), id1Key2.size(), id1Key1Name); // overwriting key should work
+ identity1.addKey(id1Key2.data(), id1Key2.size(), id1Key1Name); // overwriting key should work
BOOST_CHECK(identity1.getKey(id1Key1Name).getPublicKey() == id1Key2);
}
@@ -140,11 +140,11 @@
BOOST_CHECK_THROW(IdentityImpl(id1, pibImpl, false), Pib::Error);
IdentityImpl identity1(id1, pibImpl, true);
- identity1.addKey(id1Key1.buf(), id1Key1.size(), id1Key1Name);
- BOOST_CHECK_THROW(identity1.addKey(id2Key1.buf(), id2Key1.size(), id2Key1Name), std::invalid_argument);
+ identity1.addKey(id1Key1.data(), id1Key1.size(), id1Key1Name);
+ BOOST_CHECK_THROW(identity1.addKey(id2Key1.data(), id2Key1.size(), id2Key1Name), std::invalid_argument);
BOOST_CHECK_THROW(identity1.removeKey(id2Key1Name), std::invalid_argument);
BOOST_CHECK_THROW(identity1.getKey(id2Key1Name), std::invalid_argument);
- BOOST_CHECK_THROW(identity1.setDefaultKey(id2Key1.buf(), id2Key1.size(), id2Key1Name), std::invalid_argument);
+ BOOST_CHECK_THROW(identity1.setDefaultKey(id2Key1.data(), id2Key1.size(), id2Key1Name), std::invalid_argument);
BOOST_CHECK_THROW(identity1.setDefaultKey(id2Key1Name), std::invalid_argument);
}
diff --git a/tests/unit-tests/security/pib/detail/key-impl.t.cpp b/tests/unit-tests/security/pib/detail/key-impl.t.cpp
index 5257113..ec51751 100644
--- a/tests/unit-tests/security/pib/detail/key-impl.t.cpp
+++ b/tests/unit-tests/security/pib/detail/key-impl.t.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -36,14 +36,14 @@
BOOST_AUTO_TEST_SUITE(Security)
BOOST_AUTO_TEST_SUITE(Pib)
BOOST_AUTO_TEST_SUITE(Detail)
-BOOST_FIXTURE_TEST_SUITE(TestKeyImpl, ndn::security::tests::PibDataFixture)
+BOOST_FIXTURE_TEST_SUITE(TestKeyImpl, security::tests::PibDataFixture)
using security::Pib;
BOOST_AUTO_TEST_CASE(Basic)
{
auto pibImpl = make_shared<pib::PibMemory>();
- KeyImpl key11(id1Key1Name, id1Key1.buf(), id1Key1.size(), pibImpl);
+ KeyImpl key11(id1Key1Name, id1Key1.data(), id1Key1.size(), pibImpl);
BOOST_CHECK_EQUAL(key11.getName(), id1Key1Name);
BOOST_CHECK_EQUAL(key11.getIdentity(), id1);
@@ -60,7 +60,7 @@
BOOST_AUTO_TEST_CASE(CertificateOperation)
{
auto pibImpl = make_shared<pib::PibMemory>();
- KeyImpl key11(id1Key1Name, id1Key1.buf(), id1Key1.size(), pibImpl);
+ KeyImpl key11(id1Key1Name, id1Key1.data(), id1Key1.size(), pibImpl);
BOOST_CHECK_NO_THROW(KeyImpl(id1Key1Name, pibImpl));
// key does not have any certificate
@@ -141,10 +141,10 @@
auto pibImpl = make_shared<pib::PibMemory>();
BOOST_CHECK_THROW(KeyImpl(id1Key1Name, pibImpl), Pib::Error);
- KeyImpl(id1Key1Name, id1Key1.buf(), id1Key1.size(), pibImpl);
+ KeyImpl(id1Key1Name, id1Key1.data(), id1Key1.size(), pibImpl);
KeyImpl key1(id1Key1Name, pibImpl);
- KeyImpl(id1Key1Name, id1Key2.buf(), id1Key2.size(), pibImpl); // overwriting of the key should work
+ KeyImpl(id1Key1Name, id1Key2.data(), id1Key2.size(), pibImpl); // overwriting of the key should work
KeyImpl key2(id1Key1Name, pibImpl);
BOOST_CHECK(key1.getPublicKey() != key2.getPublicKey()); // key1 cached the original public key
@@ -173,12 +173,12 @@
auto pibImpl = make_shared<pib::PibMemory>();
BOOST_CHECK_THROW(KeyImpl(id1Key1Name, pibImpl), Pib::Error);
- KeyImpl key11(id1Key1Name, id1Key1.buf(), id1Key1.size(), pibImpl);
+ KeyImpl key11(id1Key1Name, id1Key1.data(), id1Key1.size(), pibImpl);
BOOST_CHECK_THROW(KeyImpl(Name("/wrong"), pibImpl), std::invalid_argument);
- BOOST_CHECK_THROW(KeyImpl(Name("/wrong"), id1Key1.buf(), id1Key1.size(), pibImpl), std::invalid_argument);
+ BOOST_CHECK_THROW(KeyImpl(Name("/wrong"), id1Key1.data(), id1Key1.size(), pibImpl), std::invalid_argument);
Buffer wrongKey;
- BOOST_CHECK_THROW(KeyImpl(id1Key2Name, wrongKey.buf(), wrongKey.size(), pibImpl), std::invalid_argument);
+ BOOST_CHECK_THROW(KeyImpl(id1Key2Name, wrongKey.data(), wrongKey.size(), pibImpl), std::invalid_argument);
key11.addCertificate(id1Key1Cert1);
BOOST_CHECK_THROW(key11.addCertificate(id1Key2Cert1), std::invalid_argument);
diff --git a/tests/unit-tests/security/pib/identity.t.cpp b/tests/unit-tests/security/pib/identity.t.cpp
index 239da12..6f631e5 100644
--- a/tests/unit-tests/security/pib/identity.t.cpp
+++ b/tests/unit-tests/security/pib/identity.t.cpp
@@ -82,12 +82,12 @@
BOOST_CHECK_NE(identity1, Identity());
BOOST_CHECK_EQUAL(Identity(), Identity());
- identity1.addKey(id1Key1.buf(), id1Key1.size(), id1Key1Name);
+ identity1.addKey(id1Key1.data(), id1Key1.size(), id1Key1Name);
BOOST_CHECK_NO_THROW(identity2.getKey(id1Key1Name));
identity2.removeKey(id1Key1Name);
BOOST_CHECK_THROW(identity1.getKey(id1Key1Name), Pib::Error);
- identity1.setDefaultKey(id1Key1.buf(), id1Key1.size(), id1Key1Name);
+ identity1.setDefaultKey(id1Key1.data(), id1Key1.size(), id1Key1Name);
BOOST_CHECK_NO_THROW(identity2.getDefaultKey());
}
diff --git a/tests/unit-tests/security/pib/key-container.t.cpp b/tests/unit-tests/security/pib/key-container.t.cpp
index 5b7961e..c04a415 100644
--- a/tests/unit-tests/security/pib/key-container.t.cpp
+++ b/tests/unit-tests/security/pib/key-container.t.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -49,7 +49,7 @@
BOOST_CHECK_EQUAL(container.getLoadedKeys().size(), 0);
// add the first key
- Key key11 = container.add(id1Key1.buf(), id1Key1.size(), id1Key1Name);
+ Key key11 = container.add(id1Key1.data(), id1Key1.size(), id1Key1Name);
BOOST_CHECK_EQUAL(key11.getName(), id1Key1Name);
BOOST_CHECK(key11.getPublicKey() == id1Key1);
BOOST_CHECK_EQUAL(container.size(), 1);
@@ -57,7 +57,7 @@
BOOST_CHECK(container.find(id1Key1Name) != container.end());
// add the same key again
- Key key12 = container.add(id1Key1.buf(), id1Key1.size(), id1Key1Name);
+ Key key12 = container.add(id1Key1.data(), id1Key1.size(), id1Key1Name);
BOOST_CHECK_EQUAL(key12.getName(), id1Key1Name);
BOOST_CHECK(key12.getPublicKey() == id1Key1);
BOOST_CHECK_EQUAL(container.size(), 1);
@@ -65,7 +65,7 @@
BOOST_CHECK(container.find(id1Key1Name) != container.end());
// add the second key
- Key key21 = container.add(id1Key2.buf(), id1Key2.size(), id1Key2Name);
+ Key key21 = container.add(id1Key2.data(), id1Key2.size(), id1Key2Name);
BOOST_CHECK_EQUAL(key21.getName(), id1Key2Name);
BOOST_CHECK(key21.getPublicKey() == id1Key2);
BOOST_CHECK_EQUAL(container.size(), 2);
@@ -122,7 +122,7 @@
KeyContainer container(id1, pibImpl);
- BOOST_CHECK_THROW(container.add(id2Key1.buf(), id2Key1.size(), id2Key1Name), std::invalid_argument);
+ BOOST_CHECK_THROW(container.add(id2Key1.data(), id2Key1.size(), id2Key1Name), std::invalid_argument);
BOOST_CHECK_THROW(container.remove(id2Key1Name), std::invalid_argument);
BOOST_CHECK_THROW(container.get(id2Key1Name), std::invalid_argument);
}
@@ -132,8 +132,8 @@
auto pibImpl = make_shared<PibMemory>();
KeyContainer container(id1, pibImpl);
- container.add(id1Key1.buf(), id1Key1.size(), id1Key1Name);
- container.add(id1Key2.buf(), id1Key2.size(), id1Key2Name);
+ container.add(id1Key1.data(), id1Key1.size(), id1Key1Name);
+ container.add(id1Key2.data(), id1Key2.size(), id1Key2Name);
std::set<Name> keyNames;
keyNames.insert(id1Key1Name);
diff --git a/tests/unit-tests/security/pib/key.t.cpp b/tests/unit-tests/security/pib/key.t.cpp
index a3543a3..2a90b9c 100644
--- a/tests/unit-tests/security/pib/key.t.cpp
+++ b/tests/unit-tests/security/pib/key.t.cpp
@@ -54,7 +54,8 @@
else
BOOST_CHECK(true);
- auto keyImpl = make_shared<KeyImpl>(id1Key1Name, id1Key1.buf(), id1Key1.size(), make_shared<pib::PibMemory>());
+ auto keyImpl = make_shared<KeyImpl>(id1Key1Name, id1Key1.data(), id1Key1.size(),
+ make_shared<pib::PibMemory>());
key = Key(keyImpl);
BOOST_CHECK_EQUAL(static_cast<bool>(key), true);
@@ -76,7 +77,8 @@
{
using security::pib::detail::KeyImpl;
- auto keyImpl = make_shared<KeyImpl>(id1Key1Name, id1Key1.buf(), id1Key1.size(), make_shared<pib::PibMemory>());
+ auto keyImpl = make_shared<KeyImpl>(id1Key1Name, id1Key1.data(), id1Key1.size(),
+ make_shared<pib::PibMemory>());
Key key1(keyImpl);
Key key2(keyImpl);
BOOST_CHECK_EQUAL(key1, key2);
diff --git a/tests/unit-tests/security/pib/pib-impl.t.cpp b/tests/unit-tests/security/pib/pib-impl.t.cpp
index 2677e9d..265c111 100644
--- a/tests/unit-tests/security/pib/pib-impl.t.cpp
+++ b/tests/unit-tests/security/pib/pib-impl.t.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -165,7 +165,7 @@
BOOST_CHECK_EQUAL(this->pib.hasIdentity(this->id1), false);
// add id1Key1, should be default, id1 should be added implicitly
- this->pib.addKey(this->id1, this->id1Key1Name, this->id1Key1.buf(), this->id1Key1.size());
+ this->pib.addKey(this->id1, this->id1Key1Name, this->id1Key1.data(), this->id1Key1.size());
BOOST_CHECK_EQUAL(this->pib.hasKey(this->id1Key1Name), true);
BOOST_CHECK_EQUAL(this->pib.hasIdentity(this->id1), true);
const Buffer& keyBits = this->pib.getKeyBits(this->id1Key1Name);
@@ -174,7 +174,7 @@
BOOST_CHECK_EQUAL(this->pib.getDefaultKeyOfIdentity(this->id1), this->id1Key1Name);
// add id1Key2, should not be default
- this->pib.addKey(this->id1, this->id1Key2Name, this->id1Key2.buf(), this->id1Key2.size());
+ this->pib.addKey(this->id1, this->id1Key2Name, this->id1Key2.data(), this->id1Key2.size());
BOOST_CHECK_EQUAL(this->pib.hasKey(this->id1Key2Name), true);
BOOST_CHECK_EQUAL(this->pib.getDefaultKeyOfIdentity(this->id1), this->id1Key1Name);
@@ -193,7 +193,7 @@
BOOST_CHECK_THROW(this->pib.getDefaultKeyOfIdentity(this->id1), Pib::Error);
// add id1Key2 back, should be default
- this->pib.addKey(this->id1, this->id1Key2Name, this->id1Key2.buf(), this->id1Key2.size());
+ this->pib.addKey(this->id1, this->id1Key2Name, this->id1Key2.data(), this->id1Key2.size());
BOOST_CHECK_NO_THROW(this->pib.getKeyBits(this->id1Key2Name));
BOOST_CHECK_EQUAL(this->pib.getDefaultKeyOfIdentity(this->id1), this->id1Key2Name);
@@ -275,11 +275,11 @@
this->pib.removeIdentity(this->id1);
BOOST_CHECK_THROW(this->pib.getDefaultIdentity(), Pib::Error);
- this->pib.addKey(this->id2, this->id2Key1Name, this->id2Key1.buf(), this->id2Key1.size());
+ this->pib.addKey(this->id2, this->id2Key1Name, this->id2Key1.data(), this->id2Key1.size());
BOOST_CHECK_EQUAL(this->pib.getDefaultIdentity(), this->id2);
BOOST_CHECK_EQUAL(this->pib.getDefaultKeyOfIdentity(this->id2), this->id2Key1Name);
- this->pib.addKey(this->id2, this->id2Key2Name, this->id2Key2.buf(), this->id2Key2.size());
+ this->pib.addKey(this->id2, this->id2Key2Name, this->id2Key2.data(), this->id2Key2.size());
BOOST_CHECK_EQUAL(this->pib.getDefaultKeyOfIdentity(this->id2), this->id2Key1Name);
this->pib.removeKey(this->id2Key1Name);
@@ -303,13 +303,13 @@
BOOST_CHECK_EQUAL(this->pib.hasKey(this->id1Key1Name), false);
// add id1Key1
- this->pib.addKey(this->id1, this->id1Key1Name, this->id1Key1.buf(), this->id1Key1.size());
+ this->pib.addKey(this->id1, this->id1Key1Name, this->id1Key1.data(), this->id1Key1.size());
BOOST_CHECK_EQUAL(this->pib.hasKey(this->id1Key1Name), true);
const Buffer& keyBits = this->pib.getKeyBits(this->id1Key1Name);
BOOST_CHECK(keyBits == this->id1Key1);
// check overwrite, add a key with the same name.
- this->pib.addKey(this->id1, this->id1Key1Name, this->id1Key2.buf(), this->id1Key2.size());
+ this->pib.addKey(this->id1, this->id1Key1Name, this->id1Key2.data(), this->id1Key2.size());
const Buffer& keyBits2 = this->pib.getKeyBits(this->id1Key1Name);
BOOST_CHECK(keyBits2 == this->id1Key2);
@@ -318,7 +318,7 @@
BOOST_CHECK_EQUAL(this->pib.hasCertificate(this->id1Key1Cert1.getName()), false);
// add id1Key1Cert1
- this->pib.addKey(this->id1, this->id1Key1Name, this->id1Key1.buf(), this->id1Key1.size());
+ this->pib.addKey(this->id1, this->id1Key1Name, this->id1Key1.data(), this->id1Key1.size());
this->pib.addCertificate(this->id1Key1Cert1);
BOOST_CHECK_EQUAL(this->pib.hasCertificate(this->id1Key1Cert1.getName()), true);
diff --git a/tests/unit-tests/security/pib/pib.t.cpp b/tests/unit-tests/security/pib/pib.t.cpp
index de436b4..5ae91b5 100644
--- a/tests/unit-tests/security/pib/pib.t.cpp
+++ b/tests/unit-tests/security/pib/pib.t.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -53,7 +53,7 @@
BOOST_CHECK(false);
// key
- Key key = id.addKey(id1Key1.buf(), id1Key1.size(), id1Key1Name);
+ Key key = id.addKey(id1Key1.data(), id1Key1.size(), id1Key1Name);
BOOST_CHECK_EQUAL(static_cast<bool>(key), true);
BOOST_CHECK_EQUAL(!key, false);
diff --git a/tests/unit-tests/security/tpm/back-end.t.cpp b/tests/unit-tests/security/tpm/back-end.t.cpp
index 9f7104d..ad8e39c 100644
--- a/tests/unit-tests/security/tpm/back-end.t.cpp
+++ b/tests/unit-tests/security/tpm/back-end.t.cpp
@@ -101,14 +101,14 @@
transform::PublicKey pubKey;
ConstBufferPtr pubKeyBits = key->derivePublicKey();
- pubKey.loadPkcs8(pubKeyBits->buf(), pubKeyBits->size());
+ pubKey.loadPkcs8(pubKeyBits->data(), pubKeyBits->size());
bool result;
{
using namespace transform;
- bufferSource(content, sizeof(content)) >> verifierFilter(DigestAlgorithm::SHA256, pubKey,
- sigBlock.value(), sigBlock.value_size())
- >> boolSink(result);
+ bufferSource(content, sizeof(content)) >>
+ verifierFilter(DigestAlgorithm::SHA256, pubKey, sigBlock.value(), sigBlock.value_size()) >>
+ boolSink(result);
}
BOOST_CHECK_EQUAL(result, true);
@@ -131,11 +131,11 @@
transform::PublicKey pubKey;
ConstBufferPtr pubKeyBits = key->derivePublicKey();
- pubKey.loadPkcs8(pubKeyBits->buf(), pubKeyBits->size());
+ pubKey.loadPkcs8(pubKeyBits->data(), pubKeyBits->size());
ConstBufferPtr cipherText = pubKey.encrypt(content, sizeof(content));
- ConstBufferPtr plainText = key->decrypt(cipherText->buf(), cipherText->size());
+ ConstBufferPtr plainText = key->decrypt(cipherText->data(), cipherText->size());
BOOST_CHECK_EQUAL_COLLECTIONS(content, content + sizeof(content),
plainText->begin(), plainText->end());
@@ -160,7 +160,7 @@
transform::PublicKey pubKey;
ConstBufferPtr pubKeyBits = key->derivePublicKey();
- pubKey.loadPkcs8(pubKeyBits->buf(), pubKeyBits->size());
+ pubKey.loadPkcs8(pubKeyBits->data(), pubKeyBits->size());
bool result;
{
@@ -219,14 +219,14 @@
sKey.savePkcs8(os, password.c_str(), password.size());
ConstBufferPtr privateKeyBuffer = os.buf();
- tpm.importKey(keyName, privateKeyBuffer->buf(), privateKeyBuffer->size(), password.c_str(), password.size());
+ tpm.importKey(keyName, privateKeyBuffer->data(), privateKeyBuffer->size(), password.c_str(), password.size());
BOOST_CHECK_EQUAL(tpm.hasKey(keyName), true);
ConstBufferPtr exportedKey = tpm.exportKey(keyName, password.c_str(), password.size());
BOOST_CHECK_EQUAL(tpm.hasKey(keyName), true);
transform::PrivateKey sKey2;
- sKey2.loadPkcs8(exportedKey->buf(), exportedKey->size(), password.c_str(), password.size());
+ sKey2.loadPkcs8(exportedKey->data(), exportedKey->size(), password.c_str(), password.size());
OBufferStream os2;
sKey.savePkcs1Base64(os2);
ConstBufferPtr pkcs1Buffer = os2.buf();
diff --git a/tests/unit-tests/security/transform/private-key.t.cpp b/tests/unit-tests/security/transform/private-key.t.cpp
index 6a6ba93..76c541f 100644
--- a/tests/unit-tests/security/transform/private-key.t.cpp
+++ b/tests/unit-tests/security/transform/private-key.t.cpp
@@ -143,7 +143,7 @@
checkPkcs8Encoding(ConstBufferPtr encoding, const std::string& password, ConstBufferPtr pkcs1)
{
PrivateKey sKey;
- sKey.loadPkcs8(encoding->buf(), encoding->size(), password.c_str(), password.size());
+ sKey.loadPkcs8(encoding->data(), encoding->size(), password.c_str(), password.size());
OBufferStream os;
sKey.savePkcs1(os);
BOOST_CHECK_EQUAL_COLLECTIONS(pkcs1->begin(), pkcs1->end(),
@@ -167,7 +167,7 @@
OBufferStream os;
bufferSource(sKeyPkcs1Base64, sKeyPkcs1Base64Len) >> base64Decode() >> streamSink(os);
ConstBufferPtr sKeyPkcs1Buf = os.buf();
- const uint8_t* sKeyPkcs1 = sKeyPkcs1Buf->buf();
+ const uint8_t* sKeyPkcs1 = sKeyPkcs1Buf->data();
size_t sKeyPkcs1Len = sKeyPkcs1Buf->size();
// load key in base64-encoded pkcs1 format
@@ -203,7 +203,7 @@
size_t sKeyPkcs8Base64Len = dataSet.privateKeyPkcs8.size();
OBufferStream os4;
bufferSource(sKeyPkcs8Base64, sKeyPkcs8Base64Len) >> base64Decode() >> streamSink(os4);
- const uint8_t* sKeyPkcs8 = os4.buf()->buf();
+ const uint8_t* sKeyPkcs8 = os4.buf()->data();
size_t sKeyPkcs8Len = os4.buf()->size();
std::string password("password");
@@ -309,7 +309,7 @@
OBufferStream os;
bufferSource(cipherTextBase64) >> base64Decode() >> streamSink(os);
- auto decrypted = sKey.decrypt(os.buf()->buf(), os.buf()->size());
+ auto decrypted = sKey.decrypt(os.buf()->data(), os.buf()->size());
BOOST_CHECK_EQUAL_COLLECTIONS(plainText, plainText + sizeof(plainText),
decrypted->begin(), decrypted->end());
}
@@ -331,7 +331,7 @@
const uint8_t plainText[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
auto cipherText = pKey.encrypt(plainText, sizeof(plainText));
- auto decrypted = sKey.decrypt(cipherText->buf(), cipherText->size());
+ auto decrypted = sKey.decrypt(cipherText->data(), cipherText->size());
BOOST_CHECK_EQUAL_COLLECTIONS(plainText, plainText + sizeof(plainText),
decrypted->begin(), decrypted->end());
}
@@ -348,7 +348,7 @@
OBufferStream os;
bufferSource("Y2lhbyFob2xhIWhlbGxvIQ==") >> base64Decode() >> streamSink(os);
- BOOST_CHECK_THROW(sKey.decrypt(os.buf()->buf(), os.buf()->size()), PrivateKey::Error);
+ BOOST_CHECK_THROW(sKey.decrypt(os.buf()->data(), os.buf()->size()), PrivateKey::Error);
}
using KeyParams = boost::mpl::vector<RsaKeyParams, EcKeyParams>;
@@ -358,7 +358,7 @@
unique_ptr<PrivateKey> sKey = generatePrivateKey(T());
PublicKey pKey;
ConstBufferPtr pKeyBits = sKey->derivePublicKey();
- pKey.loadPkcs8(pKeyBits->buf(), pKeyBits->size());
+ pKey.loadPkcs8(pKeyBits->data(), pKeyBits->size());
const uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
OBufferStream os;
@@ -369,7 +369,7 @@
ConstBufferPtr sig = os.buf();
bool result = false;
BOOST_REQUIRE_NO_THROW(bufferSource(data, sizeof(data)) >>
- verifierFilter(DigestAlgorithm::SHA256, pKey, sig->buf(), sig->size()) >>
+ verifierFilter(DigestAlgorithm::SHA256, pKey, sig->data(), sig->size()) >>
boolSink(result));
BOOST_CHECK(result);
diff --git a/tests/unit-tests/security/transform/public-key.t.cpp b/tests/unit-tests/security/transform/public-key.t.cpp
index fee246f..20e071c 100644
--- a/tests/unit-tests/security/transform/public-key.t.cpp
+++ b/tests/unit-tests/security/transform/public-key.t.cpp
@@ -73,7 +73,7 @@
OBufferStream os;
bufferSource(pKeyPkcs8Base64, pKeyPkcs8Base64Len) >> base64Decode() >> streamSink(os);
ConstBufferPtr pKeyPkcs8Buf = os.buf();
- const uint8_t* pKeyPkcs8 = pKeyPkcs8Buf->buf();
+ const uint8_t* pKeyPkcs8 = pKeyPkcs8Buf->data();
size_t pKeyPkcs8Len = pKeyPkcs8Buf->size();
PublicKey pKey1;
@@ -119,7 +119,7 @@
OBufferStream os;
bufferSource("Y2lhbyFob2xhIWhlbGxvIQ==") >> base64Decode() >> streamSink(os);
- BOOST_CHECK_THROW(pKey.encrypt(os.buf()->buf(), os.buf()->size()), PublicKey::Error);
+ BOOST_CHECK_THROW(pKey.encrypt(os.buf()->data(), os.buf()->size()), PublicKey::Error);
}
BOOST_AUTO_TEST_SUITE_END() // TestPublicKey
diff --git a/tests/unit-tests/security/transform/signer-filter.t.cpp b/tests/unit-tests/security/transform/signer-filter.t.cpp
index 450f9ff..5db93a7 100644
--- a/tests/unit-tests/security/transform/signer-filter.t.cpp
+++ b/tests/unit-tests/security/transform/signer-filter.t.cpp
@@ -90,7 +90,7 @@
bufferSource(data, sizeof(data)) >> signerFilter(DigestAlgorithm::SHA256, sKey) >> streamSink(os2);
auto sig = os2.buf();
- BOOST_CHECK(verifySignature(data, sizeof(data), sig->buf(), sig->size(), pubKey->buf(), pubKey->size()));
+ BOOST_CHECK(verifySignature(data, sizeof(data), sig->data(), sig->size(), pubKey->data(), pubKey->size()));
}
BOOST_AUTO_TEST_CASE(Ecdsa)
@@ -127,7 +127,7 @@
bufferSource(data, sizeof(data)) >> signerFilter(DigestAlgorithm::SHA256, sKey) >> streamSink(os2);
auto sig = os2.buf();
- BOOST_CHECK(verifySignature(data, sizeof(data), sig->buf(), sig->size(), pubKey->buf(), pubKey->size()));
+ BOOST_CHECK(verifySignature(data, sizeof(data), sig->data(), sig->size(), pubKey->data(), pubKey->size()));
}
BOOST_AUTO_TEST_CASE(InvalidKey)
diff --git a/tests/unit-tests/security/transform/strip-space.t.cpp b/tests/unit-tests/security/transform/strip-space.t.cpp
index bea3191..431aed2 100644
--- a/tests/unit-tests/security/transform/strip-space.t.cpp
+++ b/tests/unit-tests/security/transform/strip-space.t.cpp
@@ -64,7 +64,7 @@
"velitessecillumdoloreeufugiatnullapariatur.Excepteursintoccaecatcupidatatnonproi"
"dent,suntinculpaquiofficiadeseruntmollitanimidestlaborum.");
ConstBufferPtr buf = os.buf();
- BOOST_CHECK_EQUAL(std::string(reinterpret_cast<const char*>(buf->get()), buf->size()), expected);
+ BOOST_CHECK_EQUAL(std::string(buf->get<char>(), buf->size()), expected);
}
BOOST_AUTO_TEST_SUITE_END() // TestStripSpace
diff --git a/tests/unit-tests/security/transform/verifier-filter.t.cpp b/tests/unit-tests/security/transform/verifier-filter.t.cpp
index 217cf87..ae2f2ee 100644
--- a/tests/unit-tests/security/transform/verifier-filter.t.cpp
+++ b/tests/unit-tests/security/transform/verifier-filter.t.cpp
@@ -85,7 +85,7 @@
auto pubKey = os1.buf();
PublicKey pKey;
- pKey.loadPkcs8(pubKey->buf(), pubKey->size());
+ pKey.loadPkcs8(pubKey->data(), pubKey->size());
PrivateKey sKey;
sKey.loadPkcs1Base64(reinterpret_cast<const uint8_t*>(privateKeyPkcs1.data()), privateKeyPkcs1.size());
@@ -94,11 +94,11 @@
bufferSource(data, sizeof(data)) >> signerFilter(DigestAlgorithm::SHA256, sKey) >> streamSink(os2);
auto sig = os2.buf();
- BOOST_CHECK_THROW(VerifierFilter(DigestAlgorithm::NONE, pKey, sig->buf(), sig->size()), Error);
+ BOOST_CHECK_THROW(VerifierFilter(DigestAlgorithm::NONE, pKey, sig->data(), sig->size()), Error);
bool result = false;
bufferSource(data, sizeof(data)) >>
- verifierFilter(DigestAlgorithm::SHA256, pKey, sig->buf(), sig->size()) >>
+ verifierFilter(DigestAlgorithm::SHA256, pKey, sig->data(), sig->size()) >>
boolSink(result);
BOOST_CHECK_EQUAL(result, true);
@@ -130,7 +130,7 @@
auto pubKey = os1.buf();
PublicKey pKey;
- pKey.loadPkcs8(pubKey->buf(), pubKey->size());
+ pKey.loadPkcs8(pubKey->data(), pubKey->size());
PrivateKey sKey;
sKey.loadPkcs1Base64(reinterpret_cast<const uint8_t*>(privateKeyPkcs1.data()), privateKeyPkcs1.size());
@@ -139,11 +139,11 @@
bufferSource(data, sizeof(data)) >> signerFilter(DigestAlgorithm::SHA256, sKey) >> streamSink(os2);
auto sig = os2.buf();
- BOOST_CHECK_THROW(VerifierFilter(DigestAlgorithm::NONE, pKey, sig->buf(), sig->size()), Error);
+ BOOST_CHECK_THROW(VerifierFilter(DigestAlgorithm::NONE, pKey, sig->data(), sig->size()), Error);
bool result = false;
bufferSource(data, sizeof(data)) >>
- verifierFilter(DigestAlgorithm::SHA256, pKey, sig->buf(), sig->size()) >>
+ verifierFilter(DigestAlgorithm::SHA256, pKey, sig->data(), sig->size()) >>
boolSink(result);
BOOST_CHECK_EQUAL(result, true);
diff --git a/tests/unit-tests/security/v2/validator.t.cpp b/tests/unit-tests/security/v2/validator.t.cpp
index 9945ef9..ac5ca86 100644
--- a/tests/unit-tests/security/v2/validator.t.cpp
+++ b/tests/unit-tests/security/v2/validator.t.cpp
@@ -275,7 +275,7 @@
certificate.setFreshnessPeriod(time::hours(1));
// set content
- certificate.setContent(requestedKey.getPublicKey().buf(), requestedKey.getPublicKey().size());
+ certificate.setContent(requestedKey.getPublicKey().data(), requestedKey.getPublicKey().size());
// set signature-info
SignatureInfo info;
diff --git a/tests/unit-tests/security/verification-helpers.t.cpp b/tests/unit-tests/security/verification-helpers.t.cpp
index d1654d7..41aed81 100644
--- a/tests/unit-tests/security/verification-helpers.t.cpp
+++ b/tests/unit-tests/security/verification-helpers.t.cpp
@@ -430,24 +430,24 @@
v2::Certificate cert(Block(dataset.cert.data(), dataset.cert.size()));
Buffer keyRaw = cert.getPublicKey();
v2::PublicKey key;
- key.loadPkcs8(keyRaw.buf(), keyRaw.size());
+ key.loadPkcs8(keyRaw.data(), keyRaw.size());
Data data(Block(dataset.goodData.data(), dataset.goodData.size()));
Data badSigData(Block(dataset.badSigData.data(), dataset.badSigData.size()));
Interest interest(Block(dataset.goodInterest.data(), dataset.goodInterest.size()));
Interest badSigInterest(Block(dataset.badSigInterest.data(), dataset.badSigInterest.size()));
BOOST_CHECK(verifySignature(data, key));
- BOOST_CHECK(verifySignature(data, keyRaw.buf(), keyRaw.size()));
+ BOOST_CHECK(verifySignature(data, keyRaw.data(), keyRaw.size()));
BOOST_CHECK(verifySignature(data, cert));
BOOST_CHECK(verifySignature(interest, key));
- BOOST_CHECK(verifySignature(interest, keyRaw.buf(), keyRaw.size()));
+ BOOST_CHECK(verifySignature(interest, keyRaw.data(), keyRaw.size()));
BOOST_CHECK(verifySignature(interest, cert));
BOOST_CHECK(!verifySignature(badSigData, key));
- BOOST_CHECK(!verifySignature(badSigData, keyRaw.buf(), keyRaw.size()));
+ BOOST_CHECK(!verifySignature(badSigData, keyRaw.data(), keyRaw.size()));
BOOST_CHECK(!verifySignature(badSigData, cert));
BOOST_CHECK(!verifySignature(badSigInterest, key));
- BOOST_CHECK(!verifySignature(badSigInterest, keyRaw.buf(), keyRaw.size()));
+ BOOST_CHECK(!verifySignature(badSigInterest, keyRaw.data(), keyRaw.size()));
BOOST_CHECK(!verifySignature(badSigInterest, cert));
Data unsignedData("/some/data");