ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/connection.C
(Generate patch)

Comparing gvpe/src/connection.C (file contents):
Revision 1.50 by pcg, Fri Mar 18 01:53:05 2005 UTC vs.
Revision 1.51 by pcg, Wed Mar 23 20:07:56 2005 UTC

95struct rsa_cache : list<rsa_entry> 95struct rsa_cache : list<rsa_entry>
96{ 96{
97 void cleaner_cb (time_watcher &w); time_watcher cleaner; 97 void cleaner_cb (time_watcher &w); time_watcher cleaner;
98 98
99 bool find (const rsaid &id, rsachallenge &chg) 99 bool find (const rsaid &id, rsachallenge &chg)
100 { 100 {
101 for (iterator i = begin (); i != end (); ++i) 101 for (iterator i = begin (); i != end (); ++i)
102 { 102 {
103 if (!memcmp (&id, &i->id, sizeof id) && i->expire > NOW) 103 if (!memcmp (&id, &i->id, sizeof id) && i->expire > NOW)
104 { 104 {
105 memcpy (&chg, &i->chg, sizeof chg); 105 memcpy (&chg, &i->chg, sizeof chg);
106 106
107 erase (i); 107 erase (i);
108 return true; 108 return true;
109 } 109 }
110 } 110 }
111 111
112 if (cleaner.at < NOW) 112 if (cleaner.at < NOW)
113 cleaner.start (NOW + RSA_TTL); 113 cleaner.start (NOW + RSA_TTL);
114 114
115 return false; 115 return false;
116 } 116 }
117 117
118 void gen (rsaid &id, rsachallenge &chg) 118 void gen (rsaid &id, rsachallenge &chg)
119 { 119 {
120 rsa_entry e; 120 rsa_entry e;
121 121
122 RAND_bytes ((unsigned char *)&id, sizeof id); 122 RAND_bytes ((unsigned char *)&id, sizeof id);
123 RAND_bytes ((unsigned char *)&chg, sizeof chg); 123 RAND_bytes ((unsigned char *)&chg, sizeof chg);
124 124
125 e.expire = NOW + RSA_TTL; 125 e.expire = NOW + RSA_TTL;
126 e.id = id; 126 e.id = id;
127 memcpy (&e.chg, &chg, sizeof chg); 127 memcpy (&e.chg, &chg, sizeof chg);
128 128
129 push_back (e); 129 push_back (e);
130 130
131 if (cleaner.at < NOW) 131 if (cleaner.at < NOW)
132 cleaner.start (NOW + RSA_TTL); 132 cleaner.start (NOW + RSA_TTL);
133 } 133 }
134 134
135 rsa_cache () 135 rsa_cache ()
136 : cleaner (this, &rsa_cache::cleaner_cb) 136 : cleaner (this, &rsa_cache::cleaner_cb)
137 { } 137 { }
138 138
139} rsa_cache; 139} rsa_cache;
140 140
141void rsa_cache::cleaner_cb (time_watcher &w) 141void rsa_cache::cleaner_cb (time_watcher &w)
142{ 142{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines