cryptlib  3.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
stream.h
Go to the documentation of this file.
1 /****************************************************************************
2 * *
3 * STREAM Class Constants and Structures *
4 * Copyright Peter Gutmann 1993-2007 *
5 * *
6 ****************************************************************************/
7 
8 #ifndef _STREAM_DEFINED
9 
10 #define _STREAM_DEFINED
11 
12 #if defined( INC_ALL )
13  #include "crypt.h"
14 #else
15  #include "crypt.h"
16 #endif /* Compiler-specific includes */
17 #if defined( __WIN32__ ) || defined( __WINCE__ )
18  /* Includes are always handled via the normal system includes */
19 #elif defined( __UNIX__ ) || defined( __BEOS__ ) || defined( __XMK__ )
20  #include <unistd.h> /* For lseek() codes */
21 #elif defined( __MAC__ )
22  #include <Files.h>
23 #elif defined( __PALMOS__ )
24  #include <VFSMgr.h>
25 #elif defined( __UCOSII__ )
26  #include <fs_api.h> /* For uC/FS 2.x, renamed to fs.h in 3.x */
27 #elif !defined( CONFIG_NO_STDIO )
28  #include <stdio.h>
29 #endif /* System-specific file I/O headers */
30 
31 /****************************************************************************
32 * *
33 * Stream Constants *
34 * *
35 ****************************************************************************/
36 
37 /* Access/option flags for the file stream open call. The exclusive access
38  flag locks the file so that other threads/processes can't open it until
39  the current thread/process closes it. This flag is implicitly set if the
40  file R/W bits are FILE_WRITE, which creates a new file. The difference
41  between the private and sensitive flags is that some data may be private
42  for a given user but not sensitive (e.g.config info) while other data may
43  be private and sensitive (e.g.private keys). The sensitive flag only has
44  an effect on special systems where data can be committed to secure
45  storage, since there's usually a very limited amount of this available we
46  only use it for sensitive data but not generic private data */
47 
48 #define FILE_FLAG_NONE 0x00 /* No file flag */
49 #define FILE_FLAG_READ 0x01 /* Open file for read access */
50 #define FILE_FLAG_WRITE 0x02 /* Open file for write access */
51 #define FILE_FLAG_EXCLUSIVE_ACCESS 0x04 /* Don't allow others access */
52 #define FILE_FLAG_PRIVATE 0x08 /* Set ACL's to allow owner access only */
53 #define FILE_FLAG_SENSITIVE 0x10 /* Use secure storage if available */
54 #define FILE_FLAG_RW_MASK 0x03 /* Mask for R/W bits */
55 #define FILE_FLAG_MAX 0x1F /* Maximum possible flag value */
56 
57 /* Options for the build-path call */
58 
59 typedef enum {
60  BUILDPATH_NONE, /* No option type */
61  BUILDPATH_CREATEPATH, /* Get path to config file, create if nec.*/
62  BUILDPATH_GETPATH, /* Get path to config file */
63  BUILDPATH_RNDSEEDFILE, /* Get path to random seed file */
64  BUILDPATH_LAST /* Last valid option type */
66 
67 /* Stream IOCTL types */
68 
69 typedef enum {
70  STREAM_IOCTL_NONE, /* No IOCTL type */
71  STREAM_IOCTL_IOBUFFER, /* Working buffer for file streams */
72  STREAM_IOCTL_PARTIALREAD, /* Allow read of less than req.amount */
73  STREAM_IOCTL_PARTIALWRITE, /* Allow write of less then req.amount */
74  STREAM_IOCTL_READTIMEOUT, /* Network read timeout */
75  STREAM_IOCTL_WRITETIMEOUT, /* Network write timeout */
76  STREAM_IOCTL_HANDSHAKECOMPLETE, /* Toggle handshake vs.data timeout */
77  STREAM_IOCTL_CONNSTATE, /* Connection state (open/closed) */
78  STREAM_IOCTL_GETCLIENTNAME, /* Get client name */
79  STREAM_IOCTL_GETCLIENTNAMELEN, /* Get client name length */
80  STREAM_IOCTL_GETCLIENTPORT, /* Get client port */
81  STREAM_IOCTL_HTTPREQTYPES, /* Permitted HTTP request types */
82  STREAM_IOCTL_LASTMESSAGE, /* CMP last message in transaction */
83  STREAM_IOCTL_CLOSESENDCHANNEL, /* Close send side of channel */
84  STREAM_IOCTL_ERRORINFO, /* Set stream extended error info */
85  STREAM_IOCTL_LAST /* Last possible IOCTL type */
87 
88 /* Options for STREAM_IOCTL_HTTPREQTYPES */
89 
90 typedef enum {
91  STREAM_HTTPREQTYPE_NONE, /* No HTTP request type */
92  STREAM_HTTPREQTYPE_GET, /* HTTP GET only */
93  STREAM_HTTPREQTYPE_POST, /* HTTP POST only */
94  STREAM_HTTPREQTYPE_ANY, /* HTTP GET or POST */
95  STREAM_HTTPREQTYPE_LAST /* Last possible HTTP request type */
97 
98 /* Stream network protocol types */
99 
100 typedef enum {
101  STREAM_PROTOCOL_NONE, /* No protocol type */
102  STREAM_PROTOCOL_TCPIP, /* TCP/IP */
104  STREAM_PROTOCOL_CMP, /* TCP/IP with CMP packets */
105  STREAM_PROTOCOL_LAST /* Last possible protocol type */
107 
108 /* The size of the I/O buffer used to read/write data from/to streams backed
109  by persistent files. These are allocated on-demand on the stack, so they
110  shouldn't be made too big. In addition since they may correspond
111  directly to underlying storage media blocks (e.g. disk sectors or flash
112  memory segments) they shouldn't be made smaller than the underlying
113  blocksize either. Finally, they should be a power of two (this isn't a
114  strict requirement of the code, but is in a good idea in general because
115  of storage media constraints) */
116 
117 #ifdef CONFIG_CONSERVE_MEMORY
118  #define STREAM_BUFSIZE 512
119 #else
120  #define STREAM_BUFSIZE 4096
121 #endif /* CONFIG_CONSERVE_MEMORY */
122 
123 /****************************************************************************
124 * *
125 * Stream Structures *
126 * *
127 ****************************************************************************/
128 
129 /* The STREAM data type */
130 
131 typedef struct ST {
132  /* General information for the stream */
133  int type; /* The stream type, of type STREAM_TYPE */
134  int flags; /* Stream flags */
135  int status; /* Current stream status (clib error code) */
136 
137  /* Information for memory I/O */
139  BYTE *buffer; /* Buffer to R/W to */
140  int bufSize; /* Total size of buffer */
141  int bufPos; /* Current position in buffer */
142  int bufEnd; /* Last buffer position with valid data */
143 
144  /* Information for file I/O */
145  int bufCount; /* File position quantised by buffer size */
146 #if defined( __WIN32__ ) || defined( __WINCE__ )
147  HANDLE hFile; /* Backing file for the stream */
148  #ifdef __TESTIO__
149  char name[ MAX_PATH_LENGTH + 8 ];/* Data item associated with stream */
150  #endif /* __TESTIO__ */
151 #elif defined( __AMX__ ) || defined( __BEOS__ ) || defined( __ECOS__ ) || \
152  ( defined( __MVS__ ) && !defined( CONFIG_NO_STDIO ) ) || \
153  defined( __RTEMS__ ) || defined( __SYMBIAN32__ ) || \
154  defined( __TANDEM_NSK__ ) || defined( __TANDEM_OSS__ ) || \
155  defined( __UNIX__ ) || defined( __VXWORKS__ ) || defined( __XMK__ )
156  int fd; /* Backing file for the stream */
157  #ifdef __TESTIO__
158  char name[ MAX_PATH_LENGTH + 8 ];/* Data item associated with stream */
159  #endif /* __TESTIO__ */
160 #elif defined( __MAC__ )
161  short refNum; /* File stream reference number */
162  FSSpec fsspec; /* File system specification */
163 #elif defined( __PALMOS__ )
164  FileRef fileRef; /* File reference number */
165 #elif defined( __FileX__ )
166  FX_FILE filePtr; /* File associated with this stream */
167  long position; /* Position in file */
168 #elif defined( __UCOSII__ )
169  FS_FILE *pFile; /* File associated with this stream */
170 #elif defined( CONFIG_NO_STDIO )
171  #if defined( __IBM4758__ )
172  char name[ 8 + 1 ]; /* Data item associated with stream */
173  BOOLEAN isSensitive; /* Whether stream contains sensitive data */
174  #elif defined( __MVS__ ) || defined( __VMCMS__ ) || defined( __TESTIO__ )
175  char name[ MAX_PATH_LENGTH + 8 ];/* Data item associated with stream */
176  #endif /* Nonstandard I/O enviroments */
177 #else
178  FILE *filePtr; /* The file associated with this stream */
179 #endif /* System-specific file I/O information */
180 
181  /* Network stream information. This is dynamically allocated since it's
182  only used for (relatively rare) network streams and would lead to a
183  lot of wasted memory in the memory streams that are used constantly
184  throughout cryptlib */
185 #ifdef USE_TCP
186  void *netStreamInfo;
187 #endif /* USE_TCP */
188  } STREAM;
189 
190 /* Parsed URL information: schema://user@host:port/location. This is used
191  to parse URL data from an in-memory string and encodes pointers to
192  locations in the string data */
193 
197 
198 typedef struct {
200  BUFFER_OPT_FIXED( schemaLen ) \
201  const char *schema;
203  BUFFER_OPT_FIXED( userInfoLen ) \
204  const char *userInfo;
206  BUFFER_OPT_FIXED( hostLen ) \
207  const char *host;
208  int hostLen;
209  BUFFER_OPT_FIXED( locationLen ) \
210  const char *location;
212  int port;
213  } URL_INFO;
214 
215 /* Parsed HTTP URI information: location?attribute=value. The contents of a
216  string-form URI are broken down into the following fields by the HTTP
217  read code */
218 
219 typedef struct {
220  BUFFER( CRYPT_MAX_TEXTSIZE, locationLen ) \
221  char location[ CRYPT_MAX_TEXTSIZE + 8 ];
223  char attribute[ CRYPT_MAX_TEXTSIZE + 8 ];
225  char value[ CRYPT_MAX_TEXTSIZE + 8 ];
226  BUFFER( CRYPT_MAX_TEXTSIZE, extraDataLen ) \
227  char extraData[ CRYPT_MAX_TEXTSIZE + 8 ];
228  int locationLen, attributeLen, valueLen, extraDataLen;
229  } HTTP_URI_INFO;
230 
231 /* Information required when connecting a network stream. There are so many
232  parameters required that we pack them into a struct to keep the interface
233  more manageable */
234 
235 typedef enum {
236  NET_OPTION_NONE, /* No connect option type */
237  NET_OPTION_HOSTNAME, /* Use host/interface name + port */
238  NET_OPTION_HOSTNAME_TUNNEL, /* Use host + port tunnelled via proxy */
239  NET_OPTION_TRANSPORTSESSION,/* Use network transport session */
240  NET_OPTION_NETWORKSOCKET, /* Use user-supplied network socket */
241  NET_OPTION_NETWORKSOCKET_DUMMY, /* Dummy open to check socket OK */
242  NET_OPTION_LAST /* Last possible connect option type */
243  } NET_OPTION_TYPE;
244 
245 typedef struct {
246  /* Network link information, either a remote host and port, a pre-
247  connected network socket, or a cryptlib transport session */
248  BUFFER_OPT_FIXED( nameLength ) \
249  const char *name;
251  int port; /* Remote host info */
252  const char *interface;
253  int interfaceLength; /* Local interface info */
254  int networkSocket; /* Pre-connected network socket */
255  CRYPT_SESSION iCryptSession;/* cryptlib transport session */
256 
257  /* Auxiliary information: Owning user object, network status
258  information, general option type */
259  CRYPT_USER iUserObject; /* Owning user object */
260  int timeout, connectTimeout;/* Connect and data xfer.timeouts */
261  NET_OPTION_TYPE options; /* Connect options */
263 
264 #define initNetConnectInfo( netConnectInfo, netUserObject, netTimeout, \
265  netConnectTimeout, netOption ) \
266  { \
267  memset( netConnectInfo, 0, sizeof( NET_CONNECT_INFO ) ); \
268  ( netConnectInfo )->networkSocket = CRYPT_ERROR; \
269  ( netConnectInfo )->iCryptSession = CRYPT_ERROR; \
270  ( netConnectInfo )->iUserObject = netUserObject; \
271  ( netConnectInfo )->timeout = netTimeout; \
272  ( netConnectInfo )->connectTimeout = netConnectTimeout; \
273  ( netConnectInfo )->options = netOption; \
274  }
275 
276 /* Information required when reading from/writing to an HTTP stream.
277  Although we're in theory just using HTTP as a universal substrate,
278  there's a pile of additional HTTP-related data that we have to convey,
279  so when we perform a read or write to an HTTP stream we use a composite
280  data parameter */
281 
282 typedef struct {
283  /* Data payload informtion. On read the { buffer, bufSize } is the
284  amount of buffer space available to read data, with bytesAvail being
285  the length of the data item being read into the buffer and
286  bytesTransferred being the amount of data actually transferred. On
287  write the { buffer, bufSize } is the data to write and
288  bytesTransferred is the amount actually transferred. We have to
289  store this information here because the write call is passed the
290  HTTP_DATA_INFO structure rather than the data buffer so we can't
291  return a bytes-read or written count as the return value */
293  void *buffer; /* Data buffer */
294  int bufSize; /* Size of data buffer */
295  int bytesAvail, bytesTransferred; /* Actual data bytes on read */
296  BUFFER_FIXED( contentTypeLen ) \
297  const char *contentType; /* HTTP content type */
299 
300  /* HTTP read/write control flags. If the bufferResize flag is set then
301  the HTTP read code can dynamically resize the buffer in order to read
302  arbitrary-length input. If the buffer was resized during the read
303  then the flag is returned set and the caller has to reset their read
304  buffer to { buffer, bufSize }. If no resize took place then the flag
305  is returned cleared.
306 
307  If the softErrors flag is set then errors like a CRYPT_ERROR_NOTFOUND
308  (= HTTP 404) are treated as non-fatal because while (say) a
309  CRYPT_ERROR_BADDATA means that the stream has been corrupted and we
310  can't continue, the former merely indicates that the requested item
311  wasn't found but we can still submit further requests */
312  BOOLEAN bufferResize; /* Buffer is resizeable */
313  BOOLEAN softErrors; /* Treat soft errors as nonfatal */
314 
315  /* The client's request type and request info (for HTTP GET), and the
316  server's status in response to a client GET request */
317  STREAM_HTTPREQTYPE_TYPE reqType;/* HTTP request type */
319  int reqStatus; /* HTTP status in response to request */
320  } HTTP_DATA_INFO;
321 
322 #define initHttpDataInfo( httpDataInfo, dataBuffer, dataLength ) \
323  { \
324  memset( httpDataInfo, 0, sizeof( HTTP_DATA_INFO ) ); \
325  ( httpDataInfo )->buffer= dataBuffer; \
326  ( httpDataInfo )->bufSize = dataLength; \
327  }
328 #define initHttpDataInfoEx( httpDataInfo, dataBuffer, dataLength, uriInfo ) \
329  { \
330  memset( httpDataInfo, 0, sizeof( HTTP_DATA_INFO ) ); \
331  memset( uriInfo, 0, sizeof( HTTP_URI_INFO ) ); \
332  ( httpDataInfo )->buffer= dataBuffer; \
333  ( httpDataInfo )->bufSize = dataLength; \
334  ( httpDataInfo )->reqInfo = uriInfo; \
335  }
336 
337 /****************************************************************************
338 * *
339 * Stream Function Prototypes *
340 * *
341 ****************************************************************************/
342 
343 /* Functions corresponding to traditional/stdio-type I/O */
344 
345 RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
346 int sputc( INOUT STREAM *stream, IN_BYTE const int ch );
348 int sgetc( INOUT STREAM *stream );
349 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
350 int sread( INOUT STREAM *stream,
351  OUT_BUFFER_FIXED( length ) void *buffer,
353 RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
354 int swrite( INOUT STREAM *stream,
355  IN_BUFFER( length ) const void *buffer,
356  IN_LENGTH const int length );
357 CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
358 int sflush( INOUT STREAM *stream );
359 RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
360 int sseek( INOUT STREAM *stream, IN_LENGTH_Z const long position );
361 CHECK_RETVAL_RANGE( 0, MAX_INTLENGTH ) STDC_NONNULL_ARG( ( 1 ) ) \
362 int stell( const STREAM *stream );
363 RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
364 int sioctlSet( INOUT STREAM *stream,
365  IN_ENUM( STREAM_IOCTL ) const STREAM_IOCTL_TYPE type,
367 RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
368 int sioctlSetString( INOUT STREAM *stream,
369  IN_ENUM( STREAM_IOCTL ) const STREAM_IOCTL_TYPE type,
370  IN_BUFFER( dataLen ) const void *data,
372 CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
373 int sioctlGet( INOUT STREAM *stream,
374  IN_ENUM( STREAM_IOCTL ) const STREAM_IOCTL_TYPE type,
375  OUT_BUFFER_FIXED( dataMaxLen ) void *data,
377 
378 /* Nonstandard functions: Skip a number of bytes in a stream, peek at the
379  next value in the stream */
380 
381 RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
382 int sSkip( INOUT STREAM *stream, IN_LENGTH const long offset );
383 CHECK_RETVAL_RANGE( MAX_ERROR, 0xFF ) STDC_NONNULL_ARG( ( 1 ) ) \
384 int sPeek( INOUT STREAM *stream );
385 
386 /* Inquire as to the health of a stream. Currently these are only used in
387  debugging assertions, in int_api.c when exporting attributes to a stream,
388  and as a safety check in ssl_rw.c/ssh2_rw.c when wrapping a packet that
389  needs direct access to a memory stream */
390 
391 #define sGetStatus( stream ) ( stream )->status
392 #define sStatusOK( stream ) cryptStatusOK( ( stream )->status )
393 
394 /* Set/clear a user-defined error state for the stream */
395 
396 RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
397 int sSetError( INOUT STREAM *stream, IN_ERROR const int status );
398 STDC_NONNULL_ARG( ( 1 ) ) \
399 void sClearError( INOUT STREAM *stream );
400 
401 /* Stream query functions to determine whether a stream is a null stream,
402  a memory-mapped file stream, or a virtual file stream. The null stream
403  check is used to short-circuit unnecessary data transfers in higher-level
404  code where writing to a null stream is used to determine overall data
405  sizes. The memory-mapped stream check is used when we can eliminate
406  extra buffer allocation if all data is available in memory. The virtual
407  file stream check is used where the low-level access routines have
408  converted a file on a CONFIG_NO_STDIO system to a memory stream that acts
409  like a file stream */
410 
412 BOOLEAN sIsNullStream( const STREAM *stream );
413 
414 /* Functions to work with memory streams. A null stream is a special case of a
415  memory stream that just acts as a data sink. In some cases we may want to
416  open either a null stream or a standard memory stream depending on whether
417  the caller has specified an output buffer or not, in this case we provide a
418  function sMemOpenEx() to indicate that it's OK for the buffer value to be
419  NULL */
420 
421 RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
422 int sMemOpen( OUT STREAM *stream,
423  OUT_BUFFER_FIXED( length ) void *buffer,
424  IN_LENGTH const int length );
425 RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
426 int sMemOpenOpt( OUT STREAM *stream,
427  OUT_BUFFER_OPT_FIXED( length ) void *buffer,
428  IN_LENGTH_Z const int length );
429 RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
430 int sMemNullOpen( OUT STREAM *stream );
431 RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
432 int sMemClose( INOUT STREAM *stream );
433 RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
434 int sMemConnect( OUT STREAM *stream,
435  IN_BUFFER( length ) const void *buffer,
436  IN_LENGTH const int length );
437 RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
438 int sMemDisconnect( INOUT STREAM *stream );
439 
440 /* Memory stream direct-access functions, used when the contents of a memory
441  stream need to be encrypted/decrypted/signed/MACd. The basic
442  sMemGetDataBlock() returns a data block of a given size from the current
443  stream position, sMemGetDataBlockAbs() returns a data block from the
444  given stream position, and sMemGetDataBlockRemaining() returns a data
445  block containing all remaining data available in the stream. The stream
446  parameter is given as an INOUT even though the stream contents aren't
447  strictly affected because the functions can set the stream error state
448  in the case of a failure */
449 
450 CHECK_RETVAL_RANGE( 0, MAX_INTLENGTH ) STDC_NONNULL_ARG( ( 1 ) ) \
451 int sMemDataLeft( const STREAM *stream );
452 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
453 int sMemGetDataBlock( INOUT STREAM *stream,
456 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 3 ) ) \
457 int sMemGetDataBlockAbs( INOUT STREAM *stream,
458  IN_LENGTH_Z const int position,
459  OUT_BUFFER_ALLOC_OPT( dataSize ) void **dataPtrPtr,
460  IN_LENGTH const int dataSize );
461 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 2, 3 ) ) \
462 int sMemGetDataBlockRemaining( INOUT STREAM *stream,
463  OUT_BUFFER_ALLOC_OPT( *length ) void **dataPtrPtr,
464  OUT_LENGTH_Z int *length );
465 
466 /* Functions to work with file streams */
467 
468 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
469 int sFileOpen( OUT STREAM *stream, IN_STRING const char *fileName,
470  IN_FLAGS( FILE ) const int mode );
471 RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
472 int sFileClose( INOUT STREAM *stream );
473 
474 /* Convert a file stream to a memory stream */
475 
476 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 2, 3 ) ) \
477 int sFileToMemStream( OUT STREAM *memStream, INOUT STREAM *fileStream,
478  OUT_BUFFER_ALLOC_OPT( length ) void **bufPtrPtr,
479  IN_LENGTH const int length );
480 
481 /* Functions to work with network streams */
482 
483 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
484 int sNetParseURL( OUT URL_INFO *urlInfo,
485  IN_BUFFER( urlLen ) const char *url,
487  IN_ENUM_OPT( URL_TYPE ) const URL_TYPE urlTypeHint );
488 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 3, 4 ) ) \
489 int sNetConnect( OUT STREAM *stream,
490  IN_ENUM( STREAM_PROTOCOL ) \
491  const STREAM_PROTOCOL_TYPE protocol,
494 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 3, 4 ) ) \
495 int sNetListen( OUT STREAM *stream,
496  IN_ENUM( STREAM_PROTOCOL ) \
497  const STREAM_PROTOCOL_TYPE protocol,
498  const NET_CONNECT_INFO *connectInfo,
499  INOUT ERROR_INFO *errorInfo );
500 RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
501 int sNetDisconnect( INOUT STREAM *stream );
502 STDC_NONNULL_ARG( ( 1, 2 ) ) \
503 void sNetGetErrorInfo( INOUT STREAM *stream, OUT ERROR_INFO *errorInfo );
504 
505 /* Special-case file I/O calls */
506 
507 CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
508 BOOLEAN fileReadonly( IN_STRING const char *fileName );
509 STDC_NONNULL_ARG( ( 1 ) ) \
510 void fileClearToEOF( const STREAM *stream );
511 STDC_NONNULL_ARG( ( 1 ) ) \
512 void fileErase( IN_STRING const char *fileName );
513 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 3, 4 ) ) \
514 int fileBuildCryptlibPath( OUT_BUFFER( pathMaxLen, *pathLen ) char *path,
515  IN_LENGTH_SHORT const int pathMaxLen,
517  IN_BUFFER( fileNameLen ) const char *fileName,
519  IN_ENUM( BUILDPATH_OPTION ) \
521 
522 /* Initialisation/shutdown functions for network stream interfaces */
523 
524 #ifdef USE_TCP
525  RETVAL \
526  int netInitTCP( void );
527  void netSignalShutdown( void );
528  void netEndTCP( void );
529 #else
530  #define netInitTCP() CRYPT_OK
531  #define netSignalShutdown()
532  #define netEndTCP()
533 #endif /* NET_TCP */
534 
535 #endif /* _STREAM_DEFINED */