blob: 9dd32a96673ea5b80a23b7043672e8d8010d62e1 [file] [log] [blame]
Jeff Thompson7b79eb62013-09-12 18:48:29 -07001/**
2 * @author: Yingdi Yu <yingdi@cs.ucla.edu>
3 * @author: Jeff Thompson
4 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef NDN_PRIVATE_KEY_STORAGE_HPP
8#define NDN_PRIVATE_KEY_STORAGE_HPP
9
10#include <string>
11#include "../../util/blob.hpp"
12#include "../security-common.hpp"
13
14namespace ndn {
15
16class PrivateKeyStorage {
17 /**
18 * The virtual destructor
19 */
20 virtual
21 ~PrivateKeyStorage();
22
23#if 0
24 /**
25 * @brief generate a pair of asymmetric keys
26 * @param keyName the name of the key pair
27 * @param keyType the type of the key pair, e.g. RSA
28 * @param keySize the size of the key pair
29 */
30 virtual void
31 generateKeyPair(const string & keyName, KeyType keyType = KEY_TYPE_RSA, int keySize = 2048) = 0;
32
33 /**
34 * @brief get the public key
35 * @param keyName the name of public key
36 * @return the public key
37 */
38 virtual Ptr<Publickey>
39 getPublickey(const string & keyName) = 0;
40#endif
41
42 /**
Jeff Thompson4c11b9f2013-09-13 11:05:28 -070043 * Fetch the private key for keyName and sign the data, returning a signature Blob.
44 * @param data Pointer to the input byte array.
45 * @param dataLength The length of data.
Jeff Thompson7b79eb62013-09-12 18:48:29 -070046 * @param keyName The name of the signing key.
47 * @param digestAlgorithm the digest algorithm.
48 * @return The signature, or 0 if signing fails.
49 */
50 virtual Blob
Jeff Thompson4c11b9f2013-09-13 11:05:28 -070051 sign(const unsigned char *data, unsigned int dataLength, const std::string& keyName, DigestAlgorithm digestAlgorithm = DIGEST_ALGORITHM_SHA256);
Jeff Thompson7b79eb62013-09-12 18:48:29 -070052
53#if 0
54 /**
55 * @brief decrypt data
56 * @param keyName the name of the decrypting key
57 * @param blob the blob to be decrypted
58 * @param sym if true symmetric encryption is used, otherwise asymmetric decryption is used.
59 * @return decrypted data
60 */
61 virtual Ptr<Blob>
62 decrypt(const string & keyName, const Blob & data, bool sym = false) = 0;
63
64 /**
65 * @brief encrypt data
66 * @param keyName the name of the encrypting key
67 * @param blob the blob to be encrypted
68 * @param sym if true symmetric encryption is used, otherwise asymmetric decryption is used.
69 * @return encrypted data
70 */
71 virtual Ptr<Blob>
72 encrypt(const string & keyName, const Blob & pData, bool sym = false) = 0;
73
74 /**
75 * @brief generate a symmetric key
76 * @param keyName the name of the key
77 * @param keyType the type of the key, e.g. AES
78 * @param keySize the size of the key
79 */
80 virtual void
81 generateKey(const string & keyName, KeyType keyType = KEY_TYPE_AES, int keySize = 256) = 0;
82
83 /**
84 * @brief check if a particular key exist
85 * @param keyName the name of the key
86 * @param keyClass the class of the key, e.g. public, private, or symmetric
87 * @return true if the key exists, otherwise false
88 */
89 virtual bool
90 doesKeyExist(const string & keyName, KeyClass keyClass) = 0;
91#endif
92};
93
94}
95
96#endif