This file is indexed.

/usr/share/doc/libucommon-dev/a00203_source.html is in libucommon-doc 3.2.0-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>UCommon: ucommon/secure.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<h1>ucommon/secure.h</h1><a href="a00203.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 2010 David Sugar, Tycho Softworks.</span>
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">// This file is part of GNU uCommon C++.</span>
<a name="l00004"></a>00004 <span class="comment">//</span>
<a name="l00005"></a>00005 <span class="comment">// GNU uCommon C++ is free software: you can redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment">// it under the terms of the GNU Lesser General Public License as published </span>
<a name="l00007"></a>00007 <span class="comment">// by the Free Software Foundation, either version 3 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment">// (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">// GNU uCommon C++ is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00013"></a>00013 <span class="comment">// GNU Lesser General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">// You should have received a copy of the GNU Lesser General Public License</span>
<a name="l00016"></a>00016 <span class="comment">// along with GNU uCommon C++.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<a name="l00017"></a>00017 
<a name="l00041"></a>00041 <span class="preprocessor">#ifndef _UCOMMON_SECURE_H_</span>
<a name="l00042"></a>00042 <span class="preprocessor"></span><span class="preprocessor">#define _UCOMMON_SECURE_H_</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span>
<a name="l00044"></a>00044 <span class="preprocessor">#ifndef _UCOMMON_CONFIG_H_</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span><span class="preprocessor">#include &lt;<a class="code" href="a00201.html" title="Various miscelanous platform specific headers and defines.">ucommon/platform.h</a>&gt;</span>
<a name="l00046"></a>00046 <span class="preprocessor">#endif</span>
<a name="l00047"></a>00047 <span class="preprocessor"></span>
<a name="l00048"></a>00048 <span class="preprocessor">#ifndef _UCOMMON_UCOMMON_H_</span>
<a name="l00049"></a>00049 <span class="preprocessor"></span><span class="preprocessor">#include &lt;<a class="code" href="a00210.html" title="Top level include file for the GNU uCommon C++ core library.">ucommon/ucommon.h</a>&gt;</span>
<a name="l00050"></a>00050 <span class="preprocessor">#endif</span>
<a name="l00051"></a>00051 <span class="preprocessor"></span>
<a name="l00052"></a>00052 <span class="preprocessor">#define MAX_CIPHER_KEYSIZE  512</span>
<a name="l00053"></a>00053 <span class="preprocessor"></span><span class="preprocessor">#define MAX_DIGEST_HASHSIZE 512</span>
<a name="l00054"></a>00054 <span class="preprocessor"></span>
<a name="l00055"></a>00055 NAMESPACE_UCOMMON
<a name="l00056"></a>00056 
<a name="l00062"></a><a class="code" href="a00131.html">00062</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00131.html" title="Common secure socket support.">secure</a>
<a name="l00063"></a>00063 {
<a name="l00064"></a>00064 <span class="keyword">public</span>:
<a name="l00068"></a><a class="code" href="a00131.html#a7d522ec3912078b59d49b8e004779961">00068</a>     <span class="keyword">typedef</span> <span class="keyword">enum</span> {OK=0, INVALID, MISSING_CERTIFICATE, MISSING_PRIVATEKEY, INVALID_CERTIFICATE, INVALID_AUTHORITY, INVALID_PEERNAME, INVALID_CIPHER} error_t;
<a name="l00069"></a>00069 
<a name="l00070"></a>00070 <span class="keyword">protected</span>:
<a name="l00074"></a><a class="code" href="a00131.html#a08e113f3e92a506269d5f86b1ed6e074">00074</a>     <a class="code" href="a00131.html#a7d522ec3912078b59d49b8e004779961" title="Different error states of the security context.">error_t</a> error;
<a name="l00075"></a>00075 
<a name="l00076"></a>00076     <span class="keyword">inline</span> <a class="code" href="a00131.html" title="Common secure socket support.">secure</a>() {error = OK;};
<a name="l00077"></a>00077 
<a name="l00078"></a>00078 <span class="keyword">public</span>:
<a name="l00083"></a>00083     <span class="keyword">virtual</span> ~<a class="code" href="a00131.html" title="Common secure socket support.">secure</a>();
<a name="l00084"></a>00084 
<a name="l00088"></a><a class="code" href="a00131.html#ad9a6bf354c256efa7cb0996efedf311a">00088</a>     <span class="keyword">typedef</span> <a class="code" href="a00131.html" title="Common secure socket support.">secure</a> *<a class="code" href="a00131.html" title="Common secure socket support.">context_t</a>;
<a name="l00089"></a>00089 
<a name="l00093"></a><a class="code" href="a00131.html#ab6a9c66d872da1aa8abb5b954c18b67e">00093</a>     <span class="keyword">typedef</span> <span class="keywordtype">void</span> *session_t;
<a name="l00094"></a>00094 
<a name="l00098"></a><a class="code" href="a00131.html#a29b65f0d4fc0e34f1da452729f3da47c">00098</a>     <span class="keyword">typedef</span> <span class="keywordtype">void</span> *bufio_t;
<a name="l00099"></a>00099 
<a name="l00107"></a>00107     <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="a00201.html#a5fc126f9a4406cb2d0d054488cf00809" title="Template function to initialize memory by invoking default constructor.">init</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *program = NULL);
<a name="l00108"></a>00108 
<a name="l00118"></a>00118     <span class="keyword">static</span> <a class="code" href="a00131.html#a7d522ec3912078b59d49b8e004779961" title="Different error states of the security context.">error_t</a> verify(session_t session, <span class="keyword">const</span> <span class="keywordtype">char</span> *peername = NULL);
<a name="l00119"></a>00119 
<a name="l00129"></a>00129     <span class="keyword">static</span> <a class="code" href="a00131.html" title="Common secure socket support.">context_t</a> server(<span class="keyword">const</span> <span class="keywordtype">char</span> *authority = NULL);
<a name="l00130"></a>00130 
<a name="l00137"></a>00137     <span class="keyword">static</span> <a class="code" href="a00131.html" title="Common secure socket support.">context_t</a> client(<span class="keyword">const</span> <span class="keywordtype">char</span> *authority = NULL);
<a name="l00138"></a>00138 
<a name="l00145"></a>00145     <span class="keyword">static</span> <a class="code" href="a00131.html" title="Common secure socket support.">context_t</a> user(<span class="keyword">const</span> <span class="keywordtype">char</span> *authority);
<a name="l00146"></a>00146 
<a name="l00152"></a>00152     <span class="keyword">static</span> <span class="keywordtype">void</span> cipher(<a class="code" href="a00131.html" title="Common secure socket support.">context_t</a> context, <span class="keyword">const</span> <span class="keywordtype">char</span> *ciphers);
<a name="l00153"></a>00153 
<a name="l00158"></a><a class="code" href="a00131.html#ac84baffe227bffd59836a7ce639aecd1">00158</a>     <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="a00214.html#aa074f1a5a7f2741a51a01bc1607fb4a6" title="Convenience function to validate object assuming it is castable to bool.">is</a>(<span class="keywordtype">void</span>)
<a name="l00159"></a>00159         {<span class="keywordflow">return</span> error == OK;};
<a name="l00160"></a>00160 
<a name="l00165"></a><a class="code" href="a00131.html#af2825793079391fd0a4b9a0894a6e739">00165</a>     <span class="keyword">inline</span> <a class="code" href="a00131.html#a7d522ec3912078b59d49b8e004779961" title="Different error states of the security context.">error_t</a> err(<span class="keywordtype">void</span>)
<a name="l00166"></a>00166         {<span class="keywordflow">return</span> error;};
<a name="l00167"></a>00167 };
<a name="l00168"></a>00168 
<a name="l00176"></a><a class="code" href="a00154.html">00176</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00154.html" title="Secure socket class.">SSocket</a> : <span class="keyword">public</span> <a class="code" href="a00162.html" title="A generic tcp socket class that offers i/o buffering.">TCPSocket</a>
<a name="l00177"></a>00177 {
<a name="l00178"></a>00178 <span class="keyword">protected</span>:
<a name="l00179"></a>00179     secure::session_t ssl;
<a name="l00180"></a>00180     secure::bufio_t bio;
<a name="l00181"></a>00181     <span class="keywordtype">bool</span> verify;
<a name="l00182"></a>00182 
<a name="l00183"></a>00183 <span class="keyword">public</span>:
<a name="l00184"></a>00184     <a class="code" href="a00154.html" title="Secure socket class.">SSocket</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *service, <a class="code" href="a00131.html" title="Common secure socket support.">secure::context_t</a> context);
<a name="l00185"></a>00185     <a class="code" href="a00154.html" title="Secure socket class.">SSocket</a>(<a class="code" href="a00161.html" title="A generic tcp server class for TCPSocket.">TCPServer</a> *server, <a class="code" href="a00131.html" title="Common secure socket support.">secure::context_t</a> context, <span class="keywordtype">size_t</span> size = 536);
<a name="l00186"></a>00186     ~<a class="code" href="a00154.html" title="Secure socket class.">SSocket</a>();
<a name="l00187"></a>00187 
<a name="l00194"></a>00194     <span class="keywordtype">void</span> <a class="code" href="a00162.html#ac5fc5b64728ac1668701d6d693f1129d" title="Connect a tcp socket to a client from a listener.">open</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *host, <span class="keywordtype">size_t</span> size = 536);
<a name="l00195"></a>00195 
<a name="l00196"></a>00196     <span class="keywordtype">void</span> <a class="code" href="a00162.html#ac5fc5b64728ac1668701d6d693f1129d" title="Connect a tcp socket to a client from a listener.">open</a>(<a class="code" href="a00161.html" title="A generic tcp server class for TCPSocket.">TCPServer</a> *server, <span class="keywordtype">size_t</span> size = 536);
<a name="l00197"></a>00197 
<a name="l00198"></a>00198     <span class="keywordtype">void</span> <a class="code" href="a00162.html#ab55bbb63bde5bee2d52504f32c623d84" title="Close active connection.">close</a>(<span class="keywordtype">void</span>);
<a name="l00199"></a>00199 
<a name="l00200"></a>00200     <span class="keywordtype">bool</span> <a class="code" href="a00057.html#a6c0d513e2c85ee1aa52f7db1c5355685" title="Flush buffered memory to physical I/O.">flush</a>(<span class="keywordtype">void</span>);
<a name="l00201"></a>00201 
<a name="l00202"></a>00202     <span class="keywordtype">void</span> <a class="code" href="a00057.html#ac61f4cc324a744be8bc78f012a8c2565" title="Release (free) buffer memory.">release</a>(<span class="keywordtype">void</span>);
<a name="l00203"></a>00203 
<a name="l00204"></a>00204     <span class="keywordtype">size_t</span> <a class="code" href="a00162.html#aa4d11855ebc0e3539812b6d3eb16eb81" title="Method to push buffer into physical i/o (write).">_push</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="a00152.html" title="A generic socket address class.">address</a>, <span class="keywordtype">size_t</span> size);
<a name="l00205"></a>00205 
<a name="l00206"></a>00206     <span class="keywordtype">size_t</span> <a class="code" href="a00162.html#a1ce3ecc90dae3c278143ecf3f54e9b9a" title="Method to pull buffer from physical i/o (read).">_pull</a>(<span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00207"></a>00207 
<a name="l00208"></a>00208     <span class="keywordtype">bool</span> <a class="code" href="a00162.html#a4e153320094ecc110a763209187da70f" title="Check for pending tcp or ssl data.">pending</a>(<span class="keywordtype">void</span>);
<a name="l00209"></a>00209 
<a name="l00210"></a>00210     <span class="keywordtype">bool</span> issecure(<span class="keywordtype">void</span>)
<a name="l00211"></a>00211         {<span class="keywordflow">return</span> bio != NULL;};
<a name="l00212"></a>00212 };
<a name="l00213"></a>00213 
<a name="l00223"></a><a class="code" href="a00038.html">00223</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00038.html" title="A generic data ciphering class.">Cipher</a>
<a name="l00224"></a>00224 {
<a name="l00225"></a>00225 <span class="keyword">public</span>:
<a name="l00226"></a>00226     <span class="keyword">typedef</span> <span class="keyword">enum</span> {ENCRYPT = 1, DECRYPT = 0} mode_t;
<a name="l00227"></a>00227 
<a name="l00235"></a><a class="code" href="a00039.html">00235</a>     <span class="keyword">class </span>__EXPORT <a class="code" href="a00039.html" title="Cipher key formed by hash algorithm.">Key</a>
<a name="l00236"></a>00236     {
<a name="l00237"></a>00237     <span class="keyword">private</span>:
<a name="l00238"></a>00238         <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="a00038.html" title="A generic data ciphering class.">Cipher</a>;
<a name="l00239"></a>00239     
<a name="l00240"></a>00240         <span class="keyword">union </span>{
<a name="l00241"></a>00241             <span class="keyword">const</span> <span class="keywordtype">void</span> *algotype;
<a name="l00242"></a>00242             <span class="keywordtype">int</span> algoid;
<a name="l00243"></a>00243         };
<a name="l00244"></a>00244 
<a name="l00245"></a>00245         <span class="keyword">union </span>{
<a name="l00246"></a>00246             <span class="keyword">const</span> <span class="keywordtype">void</span> *hashtype;
<a name="l00247"></a>00247             <span class="keywordtype">int</span> hashid;
<a name="l00248"></a>00248         };
<a name="l00249"></a>00249 
<a name="l00250"></a>00250         <span class="keywordtype">int</span> modeid;
<a name="l00251"></a>00251         
<a name="l00252"></a>00252         <span class="comment">// assume 512 bit cipher keys possible...</span>
<a name="l00253"></a>00253         <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> keybuf[MAX_CIPHER_KEYSIZE / 8], ivbuf[MAX_CIPHER_KEYSIZE / 8];
<a name="l00254"></a>00254 
<a name="l00255"></a>00255         <span class="comment">// generated keysize</span>
<a name="l00256"></a>00256         <span class="keywordtype">size_t</span> keysize, blksize;
<a name="l00257"></a>00257 
<a name="l00258"></a>00258     <span class="keyword">public</span>:
<a name="l00259"></a>00259         <a class="code" href="a00039.html" title="Cipher key formed by hash algorithm.">Key</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *cipher, <span class="keyword">const</span> <span class="keywordtype">char</span> *digest, <span class="keyword">const</span> <span class="keywordtype">char</span> *text, <span class="keywordtype">size_t</span> size = 0, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *salt = NULL, <span class="keywordtype">unsigned</span> rounds = 1);
<a name="l00260"></a>00260         <a class="code" href="a00039.html" title="Cipher key formed by hash algorithm.">Key</a>();
<a name="l00261"></a>00261         ~<a class="code" href="a00039.html" title="Cipher key formed by hash algorithm.">Key</a>();
<a name="l00262"></a>00262 
<a name="l00263"></a>00263         <span class="keywordtype">void</span> clear(<span class="keywordtype">void</span>);
<a name="l00264"></a>00264 
<a name="l00265"></a>00265         <span class="keyword">inline</span> <span class="keywordtype">size_t</span> size(<span class="keywordtype">void</span>)
<a name="l00266"></a>00266             {<span class="keywordflow">return</span> keysize;};
<a name="l00267"></a>00267 
<a name="l00268"></a>00268         <span class="keyword">inline</span> <span class="keywordtype">size_t</span> iosize(<span class="keywordtype">void</span>)
<a name="l00269"></a>00269             {<span class="keywordflow">return</span> blksize;};
<a name="l00270"></a>00270     };
<a name="l00271"></a>00271 
<a name="l00272"></a>00272     <span class="keyword">typedef</span> <a class="code" href="a00039.html" title="Cipher key formed by hash algorithm.">Key</a> *<a class="code" href="a00039.html" title="Cipher key formed by hash algorithm.">key_t</a>;
<a name="l00273"></a>00273 
<a name="l00274"></a>00274 <span class="keyword">private</span>:
<a name="l00275"></a>00275     <a class="code" href="a00039.html" title="Cipher key formed by hash algorithm.">Key</a> keys;
<a name="l00276"></a>00276     <span class="keywordtype">size_t</span> bufsize, bufpos;
<a name="l00277"></a>00277     mode_t bufmode;
<a name="l00278"></a>00278     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *bufaddr;
<a name="l00279"></a>00279     <span class="keywordtype">void</span> *context;
<a name="l00280"></a>00280     
<a name="l00281"></a>00281 <span class="keyword">protected</span>:
<a name="l00282"></a>00282     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00214.html#ad3c146b0a18955ca36ae65ef8edacaa0" title="Push a linked object onto a stack of linked objects.">push</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00283"></a>00283 
<a name="l00284"></a>00284     <span class="keywordtype">void</span> <a class="code" href="a00214.html#ab7bef2898e731474a9c3dfa805a6f56d" title="Convenience function to unlock shared object through it&amp;#39;s protocol.">release</a>(<span class="keywordtype">void</span>);
<a name="l00285"></a>00285 
<a name="l00286"></a>00286 <span class="keyword">public</span>:
<a name="l00287"></a>00287     <a class="code" href="a00038.html" title="A generic data ciphering class.">Cipher</a>();
<a name="l00288"></a>00288 
<a name="l00289"></a>00289     <a class="code" href="a00038.html" title="A generic data ciphering class.">Cipher</a>(<a class="code" href="a00039.html" title="Cipher key formed by hash algorithm.">key_t</a> key, mode_t mode, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *address = NULL, <span class="keywordtype">size_t</span> size = 0);
<a name="l00290"></a>00290 
<a name="l00291"></a>00291     ~<a class="code" href="a00038.html" title="A generic data ciphering class.">Cipher</a>();
<a name="l00292"></a>00292 
<a name="l00293"></a>00293     <span class="keywordtype">void</span> <span class="keyword">set</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size = 0);
<a name="l00294"></a>00294 
<a name="l00295"></a>00295     <span class="keywordtype">void</span> <span class="keyword">set</span>(<a class="code" href="a00039.html" title="Cipher key formed by hash algorithm.">key_t</a> key, mode_t mode, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size = 0);
<a name="l00296"></a>00296 
<a name="l00301"></a>00301     <span class="keywordtype">size_t</span> flush(<span class="keywordtype">void</span>);
<a name="l00302"></a>00302 
<a name="l00311"></a>00311     <span class="keywordtype">size_t</span> put(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *data, <span class="keywordtype">size_t</span> size);
<a name="l00312"></a>00312 
<a name="l00319"></a>00319     <span class="keywordtype">size_t</span> puts(<span class="keyword">const</span> <span class="keywordtype">char</span> *<span class="keywordtype">string</span>);
<a name="l00320"></a>00320 
<a name="l00332"></a>00332     <span class="keywordtype">size_t</span> pad(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00333"></a>00333 
<a name="l00342"></a>00342     <span class="keywordtype">size_t</span> process(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size, <span class="keywordtype">bool</span> flag = <span class="keyword">false</span>);
<a name="l00343"></a>00343         
<a name="l00344"></a>00344     <span class="keyword">inline</span> <span class="keywordtype">size_t</span> size(<span class="keywordtype">void</span>)
<a name="l00345"></a>00345         {<span class="keywordflow">return</span> bufsize;};
<a name="l00346"></a>00346 
<a name="l00347"></a>00347     <span class="keyword">inline</span> <span class="keywordtype">size_t</span> pos(<span class="keywordtype">void</span>)
<a name="l00348"></a>00348         {<span class="keywordflow">return</span> bufpos;};
<a name="l00349"></a>00349 
<a name="l00350"></a>00350     <span class="keyword">inline</span> <span class="keywordtype">size_t</span> align(<span class="keywordtype">void</span>)
<a name="l00351"></a>00351         {<span class="keywordflow">return</span> keys.iosize();};
<a name="l00352"></a>00352 
<a name="l00358"></a>00358     <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="a00214.html#aa074f1a5a7f2741a51a01bc1607fb4a6" title="Convenience function to validate object assuming it is castable to bool.">is</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *name);
<a name="l00359"></a>00359 };
<a name="l00360"></a>00360 
<a name="l00367"></a><a class="code" href="a00050.html">00367</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00050.html" title="A crytographic digest class.">Digest</a>
<a name="l00368"></a>00368 {
<a name="l00369"></a>00369 <span class="keyword">private</span>:
<a name="l00370"></a>00370     <span class="keywordtype">void</span> *context;
<a name="l00371"></a>00371 
<a name="l00372"></a>00372     <span class="keyword">union </span>{
<a name="l00373"></a>00373         <span class="keyword">const</span> <span class="keywordtype">void</span> *hashtype;
<a name="l00374"></a>00374         <span class="keywordtype">int</span> hashid;
<a name="l00375"></a>00375     };
<a name="l00376"></a>00376 
<a name="l00377"></a>00377     <span class="keywordtype">unsigned</span> bufsize;
<a name="l00378"></a>00378     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> buffer[MAX_DIGEST_HASHSIZE / 8];
<a name="l00379"></a>00379     <span class="keywordtype">char</span> text[MAX_DIGEST_HASHSIZE / 8 + 1];
<a name="l00380"></a>00380     
<a name="l00381"></a>00381 <span class="keyword">protected</span>:
<a name="l00382"></a>00382     <span class="keywordtype">void</span> <a class="code" href="a00214.html#ab7bef2898e731474a9c3dfa805a6f56d" title="Convenience function to unlock shared object through it&amp;#39;s protocol.">release</a>(<span class="keywordtype">void</span>);
<a name="l00383"></a>00383 
<a name="l00384"></a>00384 <span class="keyword">public</span>:
<a name="l00385"></a>00385     <a class="code" href="a00050.html" title="A crytographic digest class.">Digest</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *type);
<a name="l00386"></a>00386 
<a name="l00387"></a>00387     <a class="code" href="a00050.html" title="A crytographic digest class.">Digest</a>();
<a name="l00388"></a>00388 
<a name="l00389"></a>00389     ~<a class="code" href="a00050.html" title="A crytographic digest class.">Digest</a>();
<a name="l00390"></a>00390 
<a name="l00391"></a>00391     <span class="keyword">inline</span> <span class="keywordtype">bool</span> puts(<span class="keyword">const</span> <span class="keywordtype">char</span> *str)
<a name="l00392"></a>00392         {<span class="keywordflow">return</span> put(str, strlen(str));};
<a name="l00393"></a>00393 
<a name="l00394"></a>00394     <span class="keywordtype">bool</span> put(<span class="keyword">const</span> <span class="keywordtype">void</span> *memory, <span class="keywordtype">size_t</span> size);
<a name="l00395"></a>00395     
<a name="l00396"></a>00396     <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> size()<span class="keyword"> const</span>
<a name="l00397"></a>00397 <span class="keyword">        </span>{<span class="keywordflow">return</span> bufsize;};
<a name="l00398"></a>00398     
<a name="l00399"></a>00399     <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *<span class="keyword">get</span>(void);
<a name="l00400"></a>00400 
<a name="l00401"></a>00401     <span class="keyword">const</span> <span class="keywordtype">char</span> *c_str(<span class="keywordtype">void</span>);
<a name="l00402"></a>00402 
<a name="l00403"></a>00403     <span class="keywordtype">void</span> <span class="keyword">set</span>(<span class="keyword">const</span> <span class="keywordtype">char</span> *id);
<a name="l00404"></a>00404 
<a name="l00405"></a>00405     <span class="keyword">inline</span> <span class="keywordtype">void</span> operator=(<span class="keyword">const</span> <span class="keywordtype">char</span> *<span class="keywordtype">id</span>)
<a name="l00406"></a>00406         {<span class="keyword">set</span>(id);};
<a name="l00407"></a>00407 
<a name="l00408"></a>00408     <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator *=(<span class="keyword">const</span> <span class="keywordtype">char</span> *text)
<a name="l00409"></a>00409         {<span class="keywordflow">return</span> puts(text);};
<a name="l00410"></a>00410 
<a name="l00411"></a>00411     <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator +=(<span class="keyword">const</span> <span class="keywordtype">char</span> *text)
<a name="l00412"></a>00412         {<span class="keywordflow">return</span> puts(text);};
<a name="l00413"></a>00413 
<a name="l00414"></a>00414     <span class="keyword">inline</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *operator*()
<a name="l00415"></a>00415         {<span class="keywordflow">return</span> c_str();};
<a name="l00416"></a>00416 
<a name="l00417"></a>00417     <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator!()<span class="keyword"> const</span>
<a name="l00418"></a>00418 <span class="keyword">        </span>{<span class="keywordflow">return</span> !bufsize &amp;&amp; context == NULL;};
<a name="l00419"></a>00419 
<a name="l00420"></a>00420     <span class="keyword">inline</span> operator bool()<span class="keyword"> const</span>
<a name="l00421"></a>00421 <span class="keyword">        </span>{<span class="keywordflow">return</span> bufsize &gt; 0 || context != NULL;};
<a name="l00422"></a>00422 
<a name="l00428"></a>00428     <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="a00214.html#aa074f1a5a7f2741a51a01bc1607fb4a6" title="Convenience function to validate object assuming it is castable to bool.">is</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *name);
<a name="l00429"></a>00429 };
<a name="l00430"></a>00430 
<a name="l00436"></a><a class="code" href="a00111.html">00436</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00111.html" title="Crytographically relevant random numbers.">Random</a>
<a name="l00437"></a>00437 {
<a name="l00438"></a>00438 <span class="keyword">public</span>:
<a name="l00445"></a>00445     <span class="keyword">static</span> <span class="keywordtype">bool</span> seed(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *buffer, <span class="keywordtype">size_t</span> size);
<a name="l00446"></a>00446 
<a name="l00450"></a>00450     <span class="keyword">static</span> <span class="keywordtype">void</span> seed(<span class="keywordtype">void</span>);
<a name="l00451"></a>00451 
<a name="l00460"></a>00460     <span class="keyword">static</span> <span class="keywordtype">size_t</span> key(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *memory, <span class="keywordtype">size_t</span> size);
<a name="l00461"></a>00461 
<a name="l00470"></a>00470     <span class="keyword">static</span> <span class="keywordtype">size_t</span> fill(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *memory, <span class="keywordtype">size_t</span> size);
<a name="l00471"></a>00471 
<a name="l00476"></a>00476     <span class="keyword">static</span> <span class="keywordtype">int</span> <span class="keyword">get</span>(void);
<a name="l00477"></a>00477 
<a name="l00484"></a>00484     <span class="keyword">static</span> <span class="keywordtype">int</span> <span class="keyword">get</span>(<span class="keywordtype">int</span> <a class="code" href="a00214.html#a12c25876ddd218e42a739cea9e7af3d1" title="Template for min value of a type.">min</a>, <span class="keywordtype">int</span> <a class="code" href="a00214.html#a8049d3aa4d2ad2df40e33d0104fe0c05" title="Template for max value of a type.">max</a>);
<a name="l00485"></a>00485 
<a name="l00490"></a>00490     <span class="keyword">static</span> <span class="keywordtype">double</span> real(<span class="keywordtype">void</span>);
<a name="l00491"></a>00491 
<a name="l00498"></a>00498     <span class="keyword">static</span> <span class="keywordtype">double</span> real(<span class="keywordtype">double</span> <a class="code" href="a00214.html#a12c25876ddd218e42a739cea9e7af3d1" title="Template for min value of a type.">min</a>, <span class="keywordtype">double</span> <a class="code" href="a00214.html#a8049d3aa4d2ad2df40e33d0104fe0c05" title="Template for max value of a type.">max</a>);
<a name="l00499"></a>00499 
<a name="l00505"></a>00505     <span class="keyword">static</span> <span class="keywordtype">bool</span> status(<span class="keywordtype">void</span>);
<a name="l00506"></a>00506 };
<a name="l00507"></a>00507 
<a name="l00511"></a><a class="code" href="a00214.html#a6de9f6b4e456fe1f75d0856188f0216a">00511</a> <span class="keyword">typedef</span> <a class="code" href="a00154.html" title="Secure socket class.">SSocket</a> <a class="code" href="a00154.html" title="Secure socket class.">ssl_t</a>;
<a name="l00512"></a>00512 
<a name="l00516"></a><a class="code" href="a00214.html#a8efa6b9bea40271ab01dc1219403e705">00516</a> <span class="keyword">typedef</span> <a class="code" href="a00050.html" title="A crytographic digest class.">Digest</a> <a class="code" href="a00050.html" title="A crytographic digest class.">digest_t</a>;
<a name="l00517"></a>00517 
<a name="l00521"></a><a class="code" href="a00214.html#af39b9b316751a7a69f7a3706673b8bac">00521</a> <span class="keyword">typedef</span> <a class="code" href="a00038.html" title="A generic data ciphering class.">Cipher</a> <a class="code" href="a00038.html" title="A generic data ciphering class.">cipher_t</a>;
<a name="l00522"></a>00522 
<a name="l00526"></a><a class="code" href="a00214.html#a815700a8a903493ac3a31a3fc811fe79">00526</a> <span class="keyword">typedef</span> <a class="code" href="a00039.html" title="Cipher key formed by hash algorithm.">Cipher::Key</a> <a class="code" href="a00039.html" title="Cipher key formed by hash algorithm.">skey_t</a>;
<a name="l00527"></a>00527 
<a name="l00528"></a>00528 <span class="keyword">inline</span> <span class="keywordtype">void</span> zerofill(<span class="keywordtype">void</span> *<a class="code" href="a00214.html#a808c8560ceaca5f9237fb473c0f748f2" title="A convenience function to convert a socket address list into a socket address.">addr</a>, <span class="keywordtype">size_t</span> size)
<a name="l00529"></a>00529 {
<a name="l00530"></a>00530     ::memset(addr, 0, size);
<a name="l00531"></a>00531 }
<a name="l00532"></a>00532 
<a name="l00533"></a>00533 END_NAMESPACE
<a name="l00534"></a>00534 
<a name="l00535"></a>00535 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Tue Jul 6 08:22:01 2010 for UCommon by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>