Project

General

Profile

Actions

Task #3290

closed

Design and Implement validator::KeyManager

Added by Yingdi Yu about 9 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Security
Target version:
-
Start date:
Due date:
% Done:

100%

Estimated time:

Description

One module of the new Validator framework is KeyManager which manages trust anchors, verified keys, unverified keys, and key retrieval.
This issue designs KeyManager abstraction.

class KeyManager 
{
public:
  // create a KeyManager with @p face.
  KeyManager(Face* face);

  shared_ptr<const Data>
  retrieveTrustedCert(const Interest& interest); 
  {
    auto anchor = m_anchors.find(interest);
    if (anchor != nullptr) {
      return anchor;
    }

    auto key = m_verfiedKeyCache.find(interest);
    return key;
  }

  // Retrieve unverified certificate
  void
  retrieveCertificate(shared_ptr<KeyRequest>& req,
                      const RetrievalSuccessCallback& onRetrieval,
                      const RetrievalFailureCallback& onFailure)
  {
    auto uKey = m_unverfiedKeyCache.find(req->interest);
    if (uKey != nullptr) {
      return onRetrieval(uKey, req);
    }

    if (m_face != nullptr)
      fetchKeyFromNetwork(req, onRetrieval, onFailure);
    else
      onFailure(req->interest, req);
  }

  void 
  fetchKeyFromNetwork(shared_ptr<KeyRequest>& req,
                      const RetrievalSuccessCallback& onRetrieval,
                      const RetrievalFailureCallback& onFailure)
  {
    preProcess(const_cast<KeyRequest&> req);
    m_face->expressInterest(req.interest. onRetrieval, onFailure, onTimeout);
  }

  void
  loadAnchor(...);

  void
  loadVerifiedKey(...);

  void
  loadUnverifiedKey(...);

  // call back when interest times out, will retry @p remainRetries times before falure
  void
  onTimeout(const Interest& interest, int remainRetries,
            shared_ptr<KeyRequest>& req,
            const RetrievalSuccessCallback& onRetrieval,
            const RetrievalFailureCallback& onFailure);

private:
  virtual
  preProcess(KeyRequest& req) = 0;

private:
  Face* m_face;
  TrustAnchorContainer m_anchors;           // trust anchors
  CertificateCache     m_verfiedKeyCache;   // cache of verified keys.
  DataCache            m_unverfiedKeyCache; // cache of unverified keys.
};
Actions

Also available in: Atom PDF