tests: eliminate cryptopp use from Test{Signer,Verifier}Filter

Change-Id: Id6781ce2636c9803b601e26b8847b76a029e3b99
Refs: #3946
diff --git a/tests/unit-tests/security/transform/block-cipher.t.cpp b/tests/unit-tests/security/transform/block-cipher.t.cpp
index 82f5d39..ccc5d2b 100644
--- a/tests/unit-tests/security/transform/block-cipher.t.cpp
+++ b/tests/unit-tests/security/transform/block-cipher.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -20,10 +20,10 @@
  */
 
 #include "security/transform/block-cipher.hpp"
+
+#include "encoding/buffer-stream.hpp"
 #include "security/transform/buffer-source.hpp"
 #include "security/transform/stream-sink.hpp"
-#include "encoding/buffer-stream.hpp"
-#include <iostream>
 
 #include "boost-test.hpp"
 
@@ -38,35 +38,25 @@
 
 BOOST_AUTO_TEST_CASE(AesCbc)
 {
-  uint8_t key[] = {
+  const uint8_t key[] = {
     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
     0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
   };
-
-  uint8_t plainText[] = {
-    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
-    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
-    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
-    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
-  };
-
-  uint8_t iv[] = {
+  const uint8_t iv[] = {
     0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
   };
-
-  /*
-   * Cipher text can be generated using:
-   *
-   * {
-   *   using namespace CryptoPP;
-   *   CBC_Mode<AES>::Encryption aes(key, sizeof(key), iv);
-   *   StringSource(plainText, sizeof(plainText), true,
-   *                new StreamTransformationFilter(aes,
-   *                                               new HexEncoder(new FileSink(std::cerr), false)));
-   * }
-   */
-  uint8_t cipherText[] = {
+  const uint8_t plainText[] = {
+    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+  };
+  //
+  // You can use the following shell one-liner to calculate the ciphertext:
+  //   echo ${plaintext} | xxd -p -r | openssl enc -aes-128-cbc -K ${key} -iv ${iv} | xxd -i
+  //
+  const uint8_t cipherText[] = {
     0x07, 0x4d, 0x32, 0x68, 0xc3, 0x40, 0x64, 0x43,
     0x1e, 0x66, 0x4c, 0x25, 0x66, 0x42, 0x0f, 0x59,
     0x0a, 0x51, 0x19, 0x07, 0x67, 0x5c, 0x0e, 0xfa,
@@ -78,22 +68,20 @@
   // encrypt
   OBufferStream os;
   bufferSource(plainText, sizeof(plainText)) >>
-    blockCipher(BlockCipherAlgorithm::AES_CBC,
-                CipherOperator::ENCRYPT,
+    blockCipher(BlockCipherAlgorithm::AES_CBC, CipherOperator::ENCRYPT,
                 key, sizeof(key), iv, sizeof(iv)) >> streamSink(os);
 
-  ConstBufferPtr buf = os.buf();
+  auto buf = os.buf();
   BOOST_CHECK_EQUAL_COLLECTIONS(cipherText, cipherText + sizeof(cipherText),
                                 buf->begin(), buf->end());
 
   // decrypt
   OBufferStream os2;
   bufferSource(cipherText, sizeof(cipherText)) >>
-    blockCipher(BlockCipherAlgorithm::AES_CBC,
-                CipherOperator::DECRYPT,
+    blockCipher(BlockCipherAlgorithm::AES_CBC, CipherOperator::DECRYPT,
                 key, sizeof(key), iv, sizeof(iv)) >> streamSink(os2);
 
-  ConstBufferPtr buf2 = os2.buf();
+  auto buf2 = os2.buf();
   BOOST_CHECK_EQUAL_COLLECTIONS(plainText, plainText + sizeof(plainText),
                                 buf2->begin(), buf2->end());
 }
diff --git a/tests/unit-tests/security/transform/signer-filter.t.cpp b/tests/unit-tests/security/transform/signer-filter.t.cpp
index 7714827..f041e12 100644
--- a/tests/unit-tests/security/transform/signer-filter.t.cpp
+++ b/tests/unit-tests/security/transform/signer-filter.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).
@@ -20,11 +20,12 @@
  */
 
 #include "security/transform/signer-filter.hpp"
-#include "security/transform.hpp"
-#include "encoding/buffer-stream.hpp"
 
-// TODO: remove CryptoPP dependency
-#include "security/v1/cryptopp.hpp"
+#include "encoding/buffer-stream.hpp"
+#include "security/transform/base64-decode.hpp"
+#include "security/transform/buffer-source.hpp"
+#include "security/transform/stream-sink.hpp"
+#include "security/verification-helpers.hpp"
 
 #include "boost-test.hpp"
 
@@ -39,7 +40,7 @@
 
 BOOST_AUTO_TEST_CASE(Rsa)
 {
-  std::string publicKeyPkcs8 =
+  const std::string publicKeyPkcs8 =
     "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw0WM1/WhAxyLtEqsiAJg\n"
     "WDZWuzkYpeYVdeeZcqRZzzfRgBQTsNozS5t4HnwTZhwwXbH7k3QN0kRTV826Xobw\n"
     "s3iigohnM9yTK+KKiayPhIAm/+5HGT6SgFJhYhqo1/upWdueojil6RP4/AgavHho\n"
@@ -47,8 +48,7 @@
     "ZwIL5PuE9BiO6I39cL9z7EK1SfZhOWvDe/qH7YhD/BHwcWit8FjRww1glwRVTJsA\n"
     "9rH58ynaAix0tcR/nBMRLUX+e3rURHg6UbSjJbdb9qmKM1fTGHKUzL/5pMG6uBU0\n"
     "ywIDAQAB\n";
-
-  std::string privateKeyPkcs1 =
+  const std::string privateKeyPkcs1 =
     "MIIEpAIBAAKCAQEAw0WM1/WhAxyLtEqsiAJgWDZWuzkYpeYVdeeZcqRZzzfRgBQT\n"
     "sNozS5t4HnwTZhwwXbH7k3QN0kRTV826Xobws3iigohnM9yTK+KKiayPhIAm/+5H\n"
     "GT6SgFJhYhqo1/upWdueojil6RP4/AgavHhopxlAVbk6G9VdVnlQcQ5Zv0OcGi73\n"
@@ -74,40 +74,25 @@
     "cuHICmsCgYAtFJ1idqMoHxES3mlRpf2JxyQudP3SCm2WpGmqVzhRYInqeatY5sUd\n"
     "lPLHm/p77RT7EyxQHTlwn8FJPuM/4ZH1rQd/vB+Y8qAtYJCexDMsbvLW+Js+VOvk\n"
     "jweEC0nrcL31j9mF0vz5E6tfRu4hhJ6L4yfWs0gSejskeVB/w8QY4g==\n";
-
-  uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
+  const uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
 
   OBufferStream os1;
   bufferSource(publicKeyPkcs8) >> base64Decode() >> streamSink(os1);
-  ConstBufferPtr publicKeyBuffer = os1.buf();
+  auto pubKey = os1.buf();
 
   PrivateKey sKey;
-  sKey.loadPkcs1Base64(reinterpret_cast<const uint8_t*>(privateKeyPkcs1.c_str()),
-                       privateKeyPkcs1.size());
+  sKey.loadPkcs1Base64(reinterpret_cast<const uint8_t*>(privateKeyPkcs1.data()), privateKeyPkcs1.size());
 
-  OBufferStream os3;
-  bufferSource(data, sizeof(data)) >> signerFilter(DigestAlgorithm::SHA256, sKey) >> streamSink(os3);
-  ConstBufferPtr sig = os3.buf();
+  OBufferStream os2;
+  bufferSource(data, sizeof(data)) >> signerFilter(DigestAlgorithm::SHA256, sKey) >> streamSink(os2);
+  auto sig = os2.buf();
 
-  // TODO: remove CryptoPP dependency
-  {
-    using namespace CryptoPP;
-
-    CryptoPP::RSA::PublicKey publicKey;
-
-    ByteQueue keyQueue1;
-    keyQueue1.LazyPut(publicKeyBuffer->buf(), publicKeyBuffer->size());
-    publicKey.Load(keyQueue1);
-
-    // For signature, openssl only support pkcs1v15 padding.
-    RSASS<PKCS1v15, CryptoPP::SHA256>::Verifier verifier(publicKey);
-    BOOST_CHECK(verifier.VerifyMessage(data, sizeof(data), sig->buf(), sig->size()));
-  }
+  BOOST_CHECK(verifySignature(data, sizeof(data), sig->buf(), sig->size(), pubKey->buf(), pubKey->size()));
 }
 
 BOOST_AUTO_TEST_CASE(Ecdsa)
 {
-  std::string privateKeyPkcs1 =
+  const std::string privateKeyPkcs1 =
     "MIIBaAIBAQQgRxwcbzK9RV6AHYFsDcykI86o3M/a1KlJn0z8PcLMBZOggfowgfcC\n"
     "AQEwLAYHKoZIzj0BAQIhAP////8AAAABAAAAAAAAAAAAAAAA////////////////\n"
     "MFsEIP////8AAAABAAAAAAAAAAAAAAAA///////////////8BCBaxjXYqjqT57Pr\n"
@@ -116,8 +101,7 @@
     "K84zV2sxXs7LtkBoN79R9QIhAP////8AAAAA//////////+85vqtpxeehPO5ysL8\n"
     "YyVRAgEBoUQDQgAEaG4WJuDAt0QkEM4t29KDUdzkQlMPGrqWzkWhgt9OGnwc6O7A\n"
     "ZLPSrDyhwyrKS7XLRXml5DisQ93RvByll32y8A==\n";
-
-  std::string publicKeyPkcs8 =
+  const std::string publicKeyPkcs8 =
     "MIIBSzCCAQMGByqGSM49AgEwgfcCAQEwLAYHKoZIzj0BAQIhAP////8AAAABAAAA\n"
     "AAAAAAAAAAAA////////////////MFsEIP////8AAAABAAAAAAAAAAAAAAAA////\n"
     "///////////8BCBaxjXYqjqT57PrvVV2mIa8ZR0GsMxTsPY7zjw+J9JgSwMVAMSd\n"
@@ -125,38 +109,20 @@
     "RdiYwpZP40Li/hp/m47n60p8D54WK84zV2sxXs7LtkBoN79R9QIhAP////8AAAAA\n"
     "//////////+85vqtpxeehPO5ysL8YyVRAgEBA0IABGhuFibgwLdEJBDOLdvSg1Hc\n"
     "5EJTDxq6ls5FoYLfThp8HOjuwGSz0qw8ocMqyku1y0V5peQ4rEPd0bwcpZd9svA=\n";
-
-  uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
+  const uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
 
   OBufferStream os1;
   bufferSource(publicKeyPkcs8) >> base64Decode() >> streamSink(os1);
-  ConstBufferPtr publicKeyBuffer = os1.buf();
+  auto pubKey = os1.buf();
 
   PrivateKey sKey;
-  sKey.loadPkcs1Base64(reinterpret_cast<const uint8_t*>(privateKeyPkcs1.c_str()),
-                       privateKeyPkcs1.size());
+  sKey.loadPkcs1Base64(reinterpret_cast<const uint8_t*>(privateKeyPkcs1.data()), privateKeyPkcs1.size());
 
-  OBufferStream os3;
-  bufferSource(data, sizeof(data)) >> signerFilter(DigestAlgorithm::SHA256, sKey) >> streamSink(os3);
-  ConstBufferPtr sig = os3.buf();
+  OBufferStream os2;
+  bufferSource(data, sizeof(data)) >> signerFilter(DigestAlgorithm::SHA256, sKey) >> streamSink(os2);
+  auto sig = os2.buf();
 
-  // TODO: remove CryptoPP dependency
-  {
-    using namespace CryptoPP;
-
-    ECDSA<ECP, CryptoPP::SHA256>::PublicKey publicKey;
-    ByteQueue keyQueue1;
-    keyQueue1.LazyPut(publicKeyBuffer->buf(), publicKeyBuffer->size());
-    publicKey.Load(keyQueue1);
-
-    // For signature, openssl only support pkcs1v15 padding.
-    ECDSA<ECP, CryptoPP::SHA256>::Verifier verifier(publicKey);
-
-    uint8_t buffer[64];
-    size_t usedSize = DSAConvertSignatureFormat(buffer, sizeof(buffer), DSA_P1363,
-                                                sig->buf(), sig->size(), DSA_DER);
-    BOOST_CHECK(verifier.VerifyMessage(data, sizeof(data), buffer, usedSize));
-  }
+  BOOST_CHECK(verifySignature(data, sizeof(data), sig->buf(), sig->size(), pubKey->buf(), pubKey->size()));
 }
 
 BOOST_AUTO_TEST_SUITE_END() // TestSignerFilter
diff --git a/tests/unit-tests/security/transform/verifier-filter.t.cpp b/tests/unit-tests/security/transform/verifier-filter.t.cpp
index 1813ba0..98a7c32 100644
--- a/tests/unit-tests/security/transform/verifier-filter.t.cpp
+++ b/tests/unit-tests/security/transform/verifier-filter.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).
@@ -20,11 +20,13 @@
  */
 
 #include "security/transform/verifier-filter.hpp"
-#include "security/transform.hpp"
-#include "encoding/buffer-stream.hpp"
 
-// TODO: remove CryptoPP dependency
-#include "security/v1/cryptopp.hpp"
+#include "encoding/buffer-stream.hpp"
+#include "security/transform/base64-decode.hpp"
+#include "security/transform/bool-sink.hpp"
+#include "security/transform/buffer-source.hpp"
+#include "security/transform/signer-filter.hpp"
+#include "security/transform/stream-sink.hpp"
 
 #include "boost-test.hpp"
 
@@ -39,7 +41,7 @@
 
 BOOST_AUTO_TEST_CASE(Rsa)
 {
-  std::string publicKeyPkcs8 =
+  const std::string publicKeyPkcs8 =
     "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw0WM1/WhAxyLtEqsiAJg\n"
     "WDZWuzkYpeYVdeeZcqRZzzfRgBQTsNozS5t4HnwTZhwwXbH7k3QN0kRTV826Xobw\n"
     "s3iigohnM9yTK+KKiayPhIAm/+5HGT6SgFJhYhqo1/upWdueojil6RP4/AgavHho\n"
@@ -47,8 +49,7 @@
     "ZwIL5PuE9BiO6I39cL9z7EK1SfZhOWvDe/qH7YhD/BHwcWit8FjRww1glwRVTJsA\n"
     "9rH58ynaAix0tcR/nBMRLUX+e3rURHg6UbSjJbdb9qmKM1fTGHKUzL/5pMG6uBU0\n"
     "ywIDAQAB\n";
-
-  std::string privateKeyPkcs8 =
+  const std::string privateKeyPkcs1 =
     "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDDRYzX9aEDHIu0\n"
     "SqyIAmBYNla7ORil5hV155lypFnPN9GAFBOw2jNLm3gefBNmHDBdsfuTdA3SRFNX\n"
     "zbpehvCzeKKCiGcz3JMr4oqJrI+EgCb/7kcZPpKAUmFiGqjX+6lZ256iOKXpE/j8\n"
@@ -75,47 +76,33 @@
     "/YnHJC50/dIKbZakaapXOFFgiep5q1jmxR2U8seb+nvtFPsTLFAdOXCfwUk+4z/h\n"
     "kfWtB3+8H5jyoC1gkJ7EMyxu8tb4mz5U6+SPB4QLSetwvfWP2YXS/PkTq19G7iGE\n"
     "novjJ9azSBJ6OyR5UH/DxBji\n";
-
-  uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
+  const uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
 
   OBufferStream os1;
   bufferSource(publicKeyPkcs8) >> base64Decode() >> streamSink(os1);
-  ConstBufferPtr publicKeyBuffer = os1.buf();
-
-  OBufferStream os2;
-  bufferSource(privateKeyPkcs8) >> base64Decode() >> streamSink(os2);
-  ConstBufferPtr privateKeyBuffer = os2.buf();
-
-  // TODO: remove CryptoPP dependency
-  ConstBufferPtr sig;
-  {
-    CryptoPP::RSA::PrivateKey privateKey;
-    CryptoPP::ByteQueue keyQueue;
-    keyQueue.LazyPut(privateKeyBuffer->buf(), privateKeyBuffer->size());
-    privateKey.Load(keyQueue);
-
-    CryptoPP::RSASS<CryptoPP::PKCS1v15, CryptoPP::SHA256>::Signer signer(privateKey);
-
-    CryptoPP::AutoSeededRandomPool rng;
-    OBufferStream os;
-    CryptoPP::StringSource(data, sizeof(data), true,
-                           new CryptoPP::SignerFilter(rng, signer, new CryptoPP::FileSink(os)));
-
-    sig = os.buf();
-  }
+  auto publicKeyBuffer = os1.buf();
 
   PublicKey pKey;
-  bool result = false;
   pKey.loadPkcs8(publicKeyBuffer->buf(), publicKeyBuffer->size());
+
+  PrivateKey sKey;
+  sKey.loadPkcs1Base64(reinterpret_cast<const uint8_t*>(privateKeyPkcs1.data()), privateKeyPkcs1.size());
+
+  OBufferStream os2;
+  bufferSource(data, sizeof(data)) >> signerFilter(DigestAlgorithm::SHA256, sKey) >> streamSink(os2);
+  auto sig = os2.buf();
+
+  bool result = false;
   bufferSource(data, sizeof(data)) >>
-    verifierFilter(DigestAlgorithm::SHA256, pKey, sig->buf(), sig->size()) >> boolSink(result);
+    verifierFilter(DigestAlgorithm::SHA256, pKey, sig->buf(), sig->size()) >>
+    boolSink(result);
 
   BOOST_CHECK_EQUAL(result, true);
 }
 
 BOOST_AUTO_TEST_CASE(Ecdsa)
 {
-  std::string privateKeyPkcs8 =
+  const std::string privateKeyPkcs1 =
     "MIIBeQIBADCCAQMGByqGSM49AgEwgfcCAQEwLAYHKoZIzj0BAQIhAP////8AAAAB\n"
     "AAAAAAAAAAAAAAAA////////////////MFsEIP////8AAAABAAAAAAAAAAAAAAAA\n"
     "///////////////8BCBaxjXYqjqT57PrvVV2mIa8ZR0GsMxTsPY7zjw+J9JgSwMV\n"
@@ -124,8 +111,7 @@
     "AAAA//////////+85vqtpxeehPO5ysL8YyVRAgEBBG0wawIBAQQgRxwcbzK9RV6A\n"
     "HYFsDcykI86o3M/a1KlJn0z8PcLMBZOhRANCAARobhYm4MC3RCQQzi3b0oNR3ORC\n"
     "Uw8aupbORaGC304afBzo7sBks9KsPKHDKspLtctFeaXkOKxD3dG8HKWXfbLw\n";
-
-  std::string publicKeyPkcs8 =
+  const std::string publicKeyPkcs8 =
     "MIIBSzCCAQMGByqGSM49AgEwgfcCAQEwLAYHKoZIzj0BAQIhAP////8AAAABAAAA\n"
     "AAAAAAAAAAAA////////////////MFsEIP////8AAAABAAAAAAAAAAAAAAAA////\n"
     "///////////8BCBaxjXYqjqT57PrvVV2mIa8ZR0GsMxTsPY7zjw+J9JgSwMVAMSd\n"
@@ -133,43 +119,26 @@
     "RdiYwpZP40Li/hp/m47n60p8D54WK84zV2sxXs7LtkBoN79R9QIhAP////8AAAAA\n"
     "//////////+85vqtpxeehPO5ysL8YyVRAgEBA0IABGhuFibgwLdEJBDOLdvSg1Hc\n"
     "5EJTDxq6ls5FoYLfThp8HOjuwGSz0qw8ocMqyku1y0V5peQ4rEPd0bwcpZd9svA=\n";
-
-  uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
+  const uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
 
   OBufferStream os1;
   bufferSource(publicKeyPkcs8) >> base64Decode() >> streamSink(os1);
-  ConstBufferPtr publicKeyBuffer = os1.buf();
-
-  OBufferStream os2;
-  bufferSource(privateKeyPkcs8) >> base64Decode() >> streamSink(os2);
-  ConstBufferPtr privateKeyBuffer = os2.buf();
-
-  // TODO: remove CryptoPP dependency
-  ConstBufferPtr sig;
-  {
-    CryptoPP::ECDSA<CryptoPP::ECP, CryptoPP::SHA256>::PrivateKey privateKey;
-    CryptoPP::ByteQueue keyQueue;
-    keyQueue.LazyPut(privateKeyBuffer->buf(), privateKeyBuffer->size());
-    privateKey.Load(keyQueue);
-    CryptoPP::ECDSA<CryptoPP::ECP, CryptoPP::SHA256>::Signer signer(privateKey);
-
-    CryptoPP::AutoSeededRandomPool rng;
-    OBufferStream os;
-    CryptoPP::StringSource(data, sizeof(data), true,
-                           new CryptoPP::SignerFilter(rng, signer, new CryptoPP::FileSink(os)));
-
-    uint8_t buf[200];
-    size_t bufSize = DSAConvertSignatureFormat(buf, sizeof(buf), CryptoPP::DSA_DER,
-                                               os.buf()->buf(), os.buf()->size(),
-                                               CryptoPP::DSA_P1363);
-    sig = make_shared<Buffer>(buf, bufSize);
-  }
+  auto publicKeyBuffer = os1.buf();
 
   PublicKey pKey;
-  bool result = false;
   pKey.loadPkcs8(publicKeyBuffer->buf(), publicKeyBuffer->size());
+
+  PrivateKey sKey;
+  sKey.loadPkcs1Base64(reinterpret_cast<const uint8_t*>(privateKeyPkcs1.data()), privateKeyPkcs1.size());
+
+  OBufferStream os2;
+  bufferSource(data, sizeof(data)) >> signerFilter(DigestAlgorithm::SHA256, sKey) >> streamSink(os2);
+  auto sig = os2.buf();
+
+  bool result = false;
   bufferSource(data, sizeof(data)) >>
-    verifierFilter(DigestAlgorithm::SHA256, pKey, sig->buf(), sig->size()) >> boolSink(result);
+    verifierFilter(DigestAlgorithm::SHA256, pKey, sig->buf(), sig->size()) >>
+    boolSink(result);
 
   BOOST_CHECK_EQUAL(result, true);
 }