use new ccnx API for publishing data
diff --git a/include/ccnx-wrapper.h b/include/ccnx-wrapper.h
index 42466eb..12a5bc7 100644
--- a/include/ccnx-wrapper.h
+++ b/include/ccnx-wrapper.h
@@ -60,21 +60,6 @@
/// @cond include_hidden
void
- createKeyLocator ();
-
- void
- initKeyStore ();
-
- const ccn_pkey *
- getPrivateKey ();
-
- const unsigned char *
- getPublicKeyDigest ();
-
- ssize_t
- getPublicKeyDigestLength ();
-
- void
ccnLoop ();
/// @endcond
diff --git a/src/ccnx-wrapper.cpp b/src/ccnx-wrapper.cpp
index 5f1ffc9..981fdd4 100644
--- a/src/ccnx-wrapper.cpp
+++ b/src/ccnx-wrapper.cpp
@@ -40,8 +40,6 @@
, m_connected (false)
{
connectCcnd();
- initKeyStore ();
- createKeyLocator ();
m_thread = thread (&CcnxWrapper::ccnLoop, this);
}
@@ -86,47 +84,6 @@
}
void
-CcnxWrapper::createKeyLocator ()
-{
- m_keyLoactor = ccn_charbuf_create();
- ccn_charbuf_append_tt (m_keyLoactor, CCN_DTAG_KeyLocator, CCN_DTAG);
- ccn_charbuf_append_tt (m_keyLoactor, CCN_DTAG_Key, CCN_DTAG);
- int res = ccn_append_pubkey_blob (m_keyLoactor, ccn_keystore_public_key(m_keyStore));
- if (res >= 0)
- {
- ccn_charbuf_append_closer (m_keyLoactor); /* </Key> */
- ccn_charbuf_append_closer (m_keyLoactor); /* </KeyLocator> */
- }
-}
-
-const ccn_pkey*
-CcnxWrapper::getPrivateKey ()
-{
- return ccn_keystore_private_key (m_keyStore);
-}
-
-const unsigned char*
-CcnxWrapper::getPublicKeyDigest ()
-{
- return ccn_keystore_public_key_digest(m_keyStore);
-}
-
-ssize_t
-CcnxWrapper::getPublicKeyDigestLength ()
-{
- return ccn_keystore_public_key_digest_length(m_keyStore);
-}
-
-void
-CcnxWrapper::initKeyStore ()
-{
- m_keyStore = ccn_keystore_create ();
- string keyStoreFile = string(getenv("HOME")) + string("/.ccnx/.ccnx_keystore");
- if (ccn_keystore_init (m_keyStore, (char *)keyStoreFile.c_str(), (char*)"Th1s1sn0t8g00dp8ssw0rd.") < 0)
- BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str(keyStoreFile.c_str()));
-}
-
-void
CcnxWrapper::ccnLoop ()
{
static boost::mt19937 randomGenerator (static_cast<unsigned int> (std::time (0)));
@@ -215,28 +172,19 @@
{
CcnxCharbufPtr ptr = name.toCcnxCharbuf();
ccn_charbuf *pname = ptr->getBuf();
- ccn_charbuf *signed_info = ccn_charbuf_create();
ccn_charbuf *content = ccn_charbuf_create();
- ccn_signed_info_create(signed_info,
- getPublicKeyDigest(),
- getPublicKeyDigestLength(),
- NULL,
- CCN_CONTENT_DATA,
- freshness,
- NULL,
- m_keyLoactor);
- if(ccn_encode_ContentObject(content, pname, signed_info,
- buf, len,
- NULL, getPrivateKey()) < 0)
+ struct ccn_signing_params sp = CCN_SIGNING_PARAMS_INIT;
+ sp.freshness = freshness;
+
+ if (ccn_sign_content(m_handle, content, pname, &sp, buf, len) != 0)
{
- // BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("encode content failed"));
+ BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("sign content failed"));
}
Bytes bytes;
readRaw(bytes, content->buf, content->length);
- ccn_charbuf_destroy (&signed_info);
ccn_charbuf_destroy (&content);
return bytes;