cryptlib  3.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
pgp_rw.h
Go to the documentation of this file.
1 /****************************************************************************
2 * *
3 * Miscellaneous (Non-ASN.1) Routines Header File *
4 * Copyright Peter Gutmann 1992-2004 *
5 * *
6 ****************************************************************************/
7 
8 #ifndef _PGPRW_DEFINED
9 
10 #define _PGPRW_DEFINED
11 
12 #include <time.h>
13 #if defined( INC_ALL )
14  #include "misc_rw.h"
15  #include "stream.h"
16  #include "pgp.h"
17 #else
18  #include "enc_dec/misc_rw.h"
19  #include "io/stream.h"
20  #include "misc/pgp.h"
21 #endif /* Compiler-specific includes */
22 
23 /****************************************************************************
24 * *
25 * Function Prototypes *
26 * *
27 ****************************************************************************/
28 
29 /* Read/write PGP length values */
30 
31 #define pgpSizeofLength( length ) \
32  ( ( length < 0 ) ? length : \
33  ( length <= 191 ) ? 1 : \
34  ( length <= 8383 ) ? 2 : 4 )
35 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
36 int pgpReadShortLength( INOUT STREAM *stream, OUT_LENGTH int *length,
37  IN_BYTE const int ctb );
38 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
39 int pgpReadPartialLength( INOUT STREAM *stream,
40  OUT_LENGTH_Z long *length );
41 RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
42 int pgpWriteLength( INOUT STREAM *stream, IN_LENGTH const long length );
43 
44 /* Read/write PGP packet headers. The difference between
45  pgpReadPacketHeader() and pgpReadPacketHeaderI() is that the latter
46  allows indefinite-length encoding for partial lengths. Once we've
47  read an indefinite length, we have to use pgpReadPartialLengh() to
48  read subsequence partial-length values */
49 
51 int pgpReadPacketHeader( INOUT STREAM *stream, OUT_OPT_BYTE int *ctb,
52  OUT_OPT_LENGTH_Z long *length,
53  IN_LENGTH_SHORT const int minLength );
55 int pgpReadPacketHeaderI( INOUT STREAM *stream, OUT_OPT_BYTE int *ctb,
56  OUT_OPT_LENGTH_Z long *length,
57  IN_LENGTH_SHORT const int minLength );
58 RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
59 int pgpWritePacketHeader( INOUT STREAM *stream,
60  IN_ENUM( PGP_PACKET ) \
61  const PGP_PACKET_TYPE packetType,
62  IN_LENGTH const long length );
63 
64 #endif /* _PGPRW_DEFINED */