-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsessionenum.h
More file actions
105 lines (97 loc) · 3.32 KB
/
Copy pathsessionenum.h
File metadata and controls
105 lines (97 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef SESSIONENUM_H
#define SESSIONENUM_H
extern "C" {
#include <ccn/ccn.h>
#include <ccn/bloom.h>
#include <ccn/charbuf.h>
#include <ccn/keystore.h>
#include <ccn/signing.h>
#include <ccn/uri.h>
#include <ccn/schedule.h>
}
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/x509.h>
#include <openssl/aes.h>
#include <openssl/hmac.h>
#include <openssl/pem.h>
#include <errno.h>
#include "announcement.h"
class SessionEnum {
private:
string prefix;
list<Announcement *> myConferences;
list<Announcement *> myPrivateConferences;
list<FetchedAnnouncement *> pubConferences;
list<FetchedAnnouncement *> priConferences;
bool bRunning;
struct ccn *ccn;
struct ccn_closure *to_announce;
struct ccn_closure *to_announce_private;
struct ccn_closure *fetch_announce;
struct ccn_closure *fetch_private;
struct ccn_closure *handle_dismiss;
struct ccn_keystore *keystore;
struct ccn_keystore *actd_keystore;
struct ccn_charbuf *signed_info;
//QTimer *enumTimer;
//QTimer *aliveTimer;
string uuid;
bool listPrivate;
list<struct ccn_pkey *>publicKeys;
public:
SessionEnum(string prefix);
SessionEnum();
~SessionEnum();
void startThread();
void stopThread();
void setPrefix(string prefix) { this->prefix = prefix; }
void removeFromMyConferences(Announcement *a);
void addToMyConferences(Announcement *a);
void addToConferences(Announcement *a, bool pub);
list<Announcement *> listAllPubConference();
list<Announcement *> listAllPriConference();
void handleDismissEvent(struct ccn_upcall_info *info);
void handleEnumInterest(struct ccn_upcall_info *info);
void handleEnumContent(struct ccn_upcall_info *info);
void handleEnumPrivateInterest(struct ccn_upcall_info *info);
void handleEnumPrivateContent(struct ccn_upcall_info *info);
bool isConferenceRefresh(unsigned char *hash, bool pub);
void sendDismissSignal(Announcement *a);
void setListPrivate(bool b);
private:
void enumerate();
void enumeratePriConf();
void enumeratePubConf();
void checkAlive();
void ccnConnect();
void initKeystoreAndSignedInfo();
void loadPublicAndPrivateKeys();
static int pubKeyEncrypt(EVP_PKEY *public_key,
const unsigned char *data,
size_t data_length,
unsigned char **encrypted_output,
size_t *encrypted_output_length);
static int priKeyDecrypt(EVP_PKEY *private_key,
const unsigned char *ciphertext,
size_t ciphertext_length,
unsigned char **decrypted_output,
size_t *decrypted_output_length);
static int symDecrypt(const unsigned char *key,
const unsigned char *iv,
const unsigned char *ciphertext,
size_t ciphertext_length,
unsigned char **plaintext,
size_t *plaintext_length,
size_t plaintext_padding);
static int symEncrypt(const unsigned char *key,
const unsigned char *iv,
const unsigned char *plaintext,
size_t plaintext_length,
unsigned char **ciphertext,
size_t *ciphertext_length,
size_t padding);
static void* run(void * se);
};
//static void* run(void * se);
#endif // SESSIONENUM_H