blob: bb79753575439a838fd236ad78836af40b690738 [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 /**
43 * Sign data blob.
44 * @param blob The blob to be signed.
45 * @param keyName The name of the signing key.
46 * @param digestAlgorithm the digest algorithm.
47 * @return The signature, or 0 if signing fails.
48 */
49 virtual Blob
50 sign(const Blob& blob, const std::string& keyName, DigestAlgorithm digestAlgorithm = DIGEST_ALGORITHM_SHA256);
51
52#if 0
53 /**
54 * @brief decrypt data
55 * @param keyName the name of the decrypting key
56 * @param blob the blob to be decrypted
57 * @param sym if true symmetric encryption is used, otherwise asymmetric decryption is used.
58 * @return decrypted data
59 */
60 virtual Ptr<Blob>
61 decrypt(const string & keyName, const Blob & data, bool sym = false) = 0;
62
63 /**
64 * @brief encrypt data
65 * @param keyName the name of the encrypting key
66 * @param blob the blob to be encrypted
67 * @param sym if true symmetric encryption is used, otherwise asymmetric decryption is used.
68 * @return encrypted data
69 */
70 virtual Ptr<Blob>
71 encrypt(const string & keyName, const Blob & pData, bool sym = false) = 0;
72
73 /**
74 * @brief generate a symmetric key
75 * @param keyName the name of the key
76 * @param keyType the type of the key, e.g. AES
77 * @param keySize the size of the key
78 */
79 virtual void
80 generateKey(const string & keyName, KeyType keyType = KEY_TYPE_AES, int keySize = 256) = 0;
81
82 /**
83 * @brief check if a particular key exist
84 * @param keyName the name of the key
85 * @param keyClass the class of the key, e.g. public, private, or symmetric
86 * @return true if the key exists, otherwise false
87 */
88 virtual bool
89 doesKeyExist(const string & keyName, KeyClass keyClass) = 0;
90#endif
91};
92
93}
94
95#endif