security: Preliminary work with security module changes
Change-Id: I36d86ac22fdc8aa71eed229236673993753489a2
diff --git a/include/ndn-cpp/security/identity/identity-manager.hpp b/include/ndn-cpp/security/identity/identity-manager.hpp
index d5f49f4..4273f6b 100644
--- a/include/ndn-cpp/security/identity/identity-manager.hpp
+++ b/include/ndn-cpp/security/identity/identity-manager.hpp
@@ -9,18 +9,22 @@
#ifndef NDN_IDENTITY_MANAGER_HPP
#define NDN_IDENTITY_MANAGER_HPP
-#include "../certificate/identity-certificate.hpp"
#include "identity-storage.hpp"
-#include "../certificate/public-key.hpp"
#include "private-key-storage.hpp"
+#include "../../data.hpp"
+
namespace ndn {
+class IdentityCertificate;
+
/**
* An IdentityManager is the interface of operations related to identity, keys, and certificates.
*/
class IdentityManager {
public:
+ struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
+
IdentityManager(const ptr_lib::shared_ptr<IdentityStorage>& identityStorage, const ptr_lib::shared_ptr<PrivateKeyStorage>& privateKeyStorage)
: identityStorage_(identityStorage), privateKeyStorage_(privateKeyStorage)
{
@@ -91,11 +95,11 @@
* @param keyName The name of the key.
* @return The public key.
*/
- ptr_lib::shared_ptr<PublicKey>
- getPublicKey(const Name& keyName)
- {
- return PublicKey::fromDer(identityStorage_->getKey(keyName));
- }
+ // ptr_lib::shared_ptr<PublicKey>
+ // getPublicKey(const Name& keyName)
+ // {
+ // return PublicKey::fromDer(identityStorage_->getKey(keyName));
+ // }
/**
* Create an identity certificate for a public key managed by this IdentityManager.
@@ -160,22 +164,22 @@
* @param certificateName The name of the requested certificate.
* @return the requested certificate which is valid.
*/
- ptr_lib::shared_ptr<IdentityCertificate>
- getCertificate(const Name& certificateName)
- {
- return ptr_lib::make_shared<IdentityCertificate>(*identityStorage_->getCertificate(certificateName, false));
- }
+ // ptr_lib::shared_ptr<IdentityCertificate>
+ // getCertificate(const Name& certificateName)
+ // {
+ // return ptr_lib::make_shared<IdentityCertificate>(*identityStorage_->getCertificate(certificateName, false));
+ // }
/**
* Get a certificate even if the certificate is not valid anymore.
* @param certificateName The name of the requested certificate.
* @return the requested certificate.
*/
- ptr_lib::shared_ptr<IdentityCertificate>
- getAnyCertificate(const Name& certificateName)
- {
- return ptr_lib::make_shared<IdentityCertificate>(*identityStorage_->getCertificate(certificateName, true));
- }
+ // ptr_lib::shared_ptr<IdentityCertificate>
+ // getAnyCertificate(const Name& certificateName)
+ // {
+ // return ptr_lib::make_shared<IdentityCertificate>(*identityStorage_->getCertificate(certificateName, true));
+ // }
/**
* Get the default certificate name for the specified identity, which will be used when signing is performed based on identity.
@@ -206,22 +210,10 @@
* @param certificateName The signing certificate name.
* @return The generated signature.
*/
- ptr_lib::shared_ptr<Signature>
+ Signature
signByCertificate(const uint8_t* buffer, size_t bufferLength, const Name& certificateName);
/**
- * Sign the byte array data based on the certificate name.
- * @param buffer The byte array to be signed.
- * @param certificateName The signing certificate name.
- * @return The generated signature.
- */
- ptr_lib::shared_ptr<Signature>
- signByCertificate(const std::vector<uint8_t>& buffer, const Name& certificateName)
- {
- return signByCertificate(&buffer[0], buffer.size(), certificateName);
- }
-
- /**
* Sign data packet based on the certificate name.
* Note: the caller must make sure the timestamp in data is correct, for example with
* data.getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0).
@@ -230,7 +222,7 @@
* @param wireFormat The WireFormat for calling encodeData, or WireFormat::getDefaultWireFormat() if omitted.
*/
void
- signByCertificate(Data& data, const Name& certificateName, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat());
+ signByCertificate(Data& data, const Name& certificateName);
/**
* Generate a self-signed certificate for a public key.