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