blob: bb79753575439a838fd236ad78836af40b690738 [file] [log] [blame]
/**
* @author: Yingdi Yu <yingdi@cs.ucla.edu>
* @author: Jeff Thompson
* See COPYING for copyright and distribution information.
*/
#ifndef NDN_PRIVATE_KEY_STORAGE_HPP
#define NDN_PRIVATE_KEY_STORAGE_HPP
#include <string>
#include "../../util/blob.hpp"
#include "../security-common.hpp"
namespace ndn {
class PrivateKeyStorage {
/**
* The virtual destructor
*/
virtual
~PrivateKeyStorage();
#if 0
/**
* @brief generate a pair of asymmetric keys
* @param keyName the name of the key pair
* @param keyType the type of the key pair, e.g. RSA
* @param keySize the size of the key pair
*/
virtual void
generateKeyPair(const string & keyName, KeyType keyType = KEY_TYPE_RSA, int keySize = 2048) = 0;
/**
* @brief get the public key
* @param keyName the name of public key
* @return the public key
*/
virtual Ptr<Publickey>
getPublickey(const string & keyName) = 0;
#endif
/**
* Sign data blob.
* @param blob The blob to be signed.
* @param keyName The name of the signing key.
* @param digestAlgorithm the digest algorithm.
* @return The signature, or 0 if signing fails.
*/
virtual Blob
sign(const Blob& blob, const std::string& keyName, DigestAlgorithm digestAlgorithm = DIGEST_ALGORITHM_SHA256);
#if 0
/**
* @brief decrypt data
* @param keyName the name of the decrypting key
* @param blob the blob to be decrypted
* @param sym if true symmetric encryption is used, otherwise asymmetric decryption is used.
* @return decrypted data
*/
virtual Ptr<Blob>
decrypt(const string & keyName, const Blob & data, bool sym = false) = 0;
/**
* @brief encrypt data
* @param keyName the name of the encrypting key
* @param blob the blob to be encrypted
* @param sym if true symmetric encryption is used, otherwise asymmetric decryption is used.
* @return encrypted data
*/
virtual Ptr<Blob>
encrypt(const string & keyName, const Blob & pData, bool sym = false) = 0;
/**
* @brief generate a symmetric key
* @param keyName the name of the key
* @param keyType the type of the key, e.g. AES
* @param keySize the size of the key
*/
virtual void
generateKey(const string & keyName, KeyType keyType = KEY_TYPE_AES, int keySize = 256) = 0;
/**
* @brief check if a particular key exist
* @param keyName the name of the key
* @param keyClass the class of the key, e.g. public, private, or symmetric
* @return true if the key exists, otherwise false
*/
virtual bool
doesKeyExist(const string & keyName, KeyClass keyClass) = 0;
#endif
};
}
#endif