encoding: remove duplicate buf() and get() methods from Buffer class
Change-Id: If885d4199d6c9df9b9b46664c3641c9a14a77eab
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);