Annotation of pgp/src/pgp.h, revision 1.1.1.1

1.1       root        1: /*
                      2:        Pretty Good(tm) Privacy - RSA public key cryptography for the masses
                      3:        Written by Philip Zimmermann, Phil's Pretty Good(tm) Software.
                      4:        Version 1.0 - 5 Jun 91, last revised 6 Jul 91 by PRZ
                      5: 
                      6:        This file defines the various formats, filenames, and general control
                      7:        methods used by PGP, as well as a few global switches which control
                      8:        the functioning of the driver code.
                      9: 
                     10: */
                     11: 
                     12: #include "usuals.h"
                     13: #define KEYFRAGSIZE 8  /* # of bytes in key ID modulus fragment */
                     14: #define SIZEOF_TIMESTAMP 4 /* 32-bit timestamp */
                     15: 
                     16: /* The maximum length of the file path for this system.  Varies on UNIX
                     17:    systems */
                     18: 
                     19: #ifndef        MAX_PATH
                     20: #ifdef MSDOS
                     21: #define MAX_PATH       64
                     22: #else
                     23: #define MAX_PATH       256
                     24: #endif
                     25: #endif
                     26: 
                     27: #ifdef ATARI
                     28: #define sizeof(x) (int)sizeof(x)
                     29: #define fread(a,b,c,d) ((int)fread(a,b,c,d))
                     30: #endif
                     31: 
                     32: /*
                     33: **********************************************************************
                     34: */
                     35: 
                     36: /* Cipher Type Byte (CTB) definitions follow...*/
                     37: #define CTB_DESIGNATOR 0x80
                     38: #define is_ctb(c) (((c) & CTB_DESIGNATOR)==CTB_DESIGNATOR)
                     39: #define CTB_TYPE_MASK 0x7c
                     40: #define CTB_LLEN_MASK 0x03
                     41: 
                     42: /* "length of length" field of packet, in bytes (1, 2, 4, 8 bytes): */
                     43: #define ctb_llength(ctb) ((int) 1 << (int) ((ctb) & CTB_LLEN_MASK))
                     44: 
                     45: #define is_ctb_type(ctb,type) (((ctb) & CTB_TYPE_MASK)==(4*type))
                     46: #define CTB_BYTE(type,llen) (CTB_DESIGNATOR + (4*type) + llen)
                     47: 
                     48: #define CTB_PKE_TYPE 1                 /* packet encrypted with RSA public key */
                     49: #define CTB_SKE_TYPE 2                 /* packet signed with RSA secret key */
                     50: #define CTB_MD_TYPE 3                  /* message digest packet */
                     51: #define CTB_CERT_SECKEY_TYPE 5  /* secret key certificate */
                     52: #define CTB_CERT_PUBKEY_TYPE 6  /* public key certificate */
                     53: #define CTB_COMPRESSED_TYPE 8  /* compressed data packet */
                     54: #define CTB_CKE_TYPE 9                 /* conventional-key-encrypted data */
                     55: #define        CTB_LITERAL_TYPE 10             /* raw data with filename and mode */
                     56: #define CTB_KEYCTRL_TYPE 12            /* key control packet */
                     57: #define CTB_USERID_TYPE 13             /* user id packet */
                     58: #define CTB_COMMENT_TYPE 14            /* comment packet */
                     59: 
                     60: /* Unimplemented CTB packet types follow... */
                     61: /* #define CTB_EXTENDED_TYPE 15 */ /* 2-byte CTB, 256 extra CTB types */
                     62: 
                     63: #define CTB_PKE CTB_BYTE(CTB_PKE_TYPE,1)
                     64:        /* CTB_PKE len16 keyID mpi(RSA(CONKEYPKT)) */
                     65:        /*        1              2       SIZE  countbytes()+2 */
                     66: #define CTB_SKE CTB_BYTE(CTB_SKE_TYPE,1)
                     67:        /* CTB_SKE len16 keyID mpi(RSA(MDPKT)) */
                     68:        /*        1              2       SIZE  countbytes()+2 */
                     69: #define CTB_MD CTB_BYTE(CTB_MD_TYPE,0)
                     70:        /* CTB_MD len8 algorithm MD timestamp */
                     71: #define CTB_CERT_SECKEY CTB_BYTE(CTB_CERT_SECKEY_TYPE,1)
                     72:        /* CTB_CERT_SECKEY len16 timestamp userID mpi(n) mpi(e) mpi(d) mpi(p) mpi(q) mpi(u) crc16 */
                     73: #define CTB_CERT_PUBKEY CTB_BYTE(CTB_CERT_PUBKEY_TYPE,1)
                     74:        /* CTB_CERT_PUBKEY len16 timestamp userID mpi(n) mpi(e) crc16 */
                     75: 
                     76: #define CTB_KEYCTRL CTB_BYTE(CTB_KEYCTRL_TYPE,0)
                     77: #define        CTB_USERID      CTB_BYTE(CTB_USERID_TYPE,0)
                     78: 
                     79: #define CTB_CKE CTB_BYTE(CTB_CKE_TYPE,3)
                     80:        /*      CTB_CKE ciphertext */
                     81: 
                     82: #define CTB_LITERAL CTB_BYTE(CTB_LITERAL_TYPE,3)
                     83:        /*      CTB_LITERAL data */
                     84: 
                     85: #define CTB_COMPRESSED CTB_BYTE(CTB_COMPRESSED_TYPE,3)
                     86:        /*      CTB_COMPRESSED compressedtext */
                     87: 
                     88: /*     Public key encryption algorithm selector bytes. */
                     89: #define RSA_ALGORITHM_BYTE     1       /*      use RSA */
                     90: 
                     91: /*     Conventional encryption algorithm selector bytes. */
                     92: #define IDEA_ALGORITHM_BYTE    1       /*      use the IDEA cipher */
                     93: 
                     94: /*     Message digest algorithm selector bytes. */
                     95: #define MD5_ALGORITHM_BYTE 1   /* MD5 message digest algorithm */
                     96: 
                     97: /*     Data compression algorithm selector bytes. */
                     98: #define ZIP2_ALGORITHM_BYTE  1 /* Zip-based deflate compression algorithm */
                     99: 
                    100: /* Signature classification bytes. */
                    101: #define SB_SIGNATURE_BYTE      0x00    /* Signature of a binary msg or doc */
                    102: #define SM_SIGNATURE_BYTE      0x01    /* Signature of canonical msg or doc */
                    103: #define        K0_SIGNATURE_BYTE       0x10    /* Key certification, generic */
                    104: #define        K1_SIGNATURE_BYTE       0x11    /* Key certification, persona */
                    105: #define        K2_SIGNATURE_BYTE       0x12    /* Key certification, casual ID */
                    106: #define        K3_SIGNATURE_BYTE       0x13    /* Key certification, positive ID */
                    107: #define KC_SIGNATURE_BYTE      0x20    /* Key compromise */
                    108: #define KR_SIGNATURE_BYTE      0x30    /* Key revocation */
                    109: #define        TS_SIGNATURE_BYTE       0x40    /* Timestamp someone else's signature */
                    110: 
                    111: /* Public key encrypted data classification bytes. */
                    112: #define MD_ENCRYPTED_BYTE      1       /* Message digest is encrypted */
                    113: #define CK_ENCRYPTED_BYTE      2       /* Conventional key is encrypted */
                    114: 
                    115: /* Version byte for data structures created by this version of PGP */
                    116: #define        VERSION_BYTE            2       /* PGP2 */
                    117: 
                    118: /* Values for trust bits in keycntrl packet after key packet */
                    119: #define        KC_OWNERTRUST_MASK              0x07    /* Trust bits for key owner */
                    120: #define        KC_OWNERTRUST_UNDEFINED 0x00
                    121: #define        KC_OWNERTRUST_UNKNOWN   0x01
                    122: #define        KC_OWNERTRUST_NEVER             0x02
                    123: /* 2 levels reserved */
                    124: #define        KC_OWNERTRUST_USUALLY   0x05
                    125: #define        KC_OWNERTRUST_ALWAYS    0x06
                    126: #define        KC_OWNERTRUST_ULTIMATE  0x07    /* Only for keys in secret ring */
                    127: #define        KC_BUCKSTOP                             0x80    /* This key is in secret ring */
                    128: #define        KC_VISITED                              0x40
                    129: 
                    130: /* Values for trust bits in keycntrl packet after userid packet */
                    131: #define        KC_LEGIT_MASK                   0x03    /* Key legit bits for key */
                    132: #define        KC_LEGIT_UNKNOWN                0x00
                    133: #define KC_LEGIT_UNTRUSTED             0x01
                    134: #define KC_LEGIT_MARGINAL              0x02
                    135: #define        KC_LEGIT_COMPLETE               0x03
                    136: #define        KC_WARNONLY                             0x80
                    137: 
                    138: /* Values for trust bits in keycntrl packet after signature packet */
                    139: #define        KC_SIGTRUST_MASK                0x07    /* Trust bits for key owner */
                    140: #define        KC_SIGTRUST_UNDEFINED   0x00
                    141: #define        KC_SIGTRUST_UNKNOWN             0x01
                    142: #define        KC_SIGTRUST_UNTRUSTED   0x02
                    143: /* 2 levels reserved */
                    144: #define        KC_SIGTRUST_MARGINAL    0x05
                    145: #define        KC_SIGTRUST_COMPLETE    0x06
                    146: #define        KC_SIGTRUST_ULTIMATE    0x07
                    147: #define        KC_CONTIG                               0x80    /* This sig is on a cert. path */
                    148: 
                    149: #define        MAINT_CHECK                             0x01
                    150: #define        MAINT_VERBOSE                   0x02
                    151: #define        MAINT_SILENT                    0x04
                    152: 
                    153: #define is_secret_key(ctb) is_ctb_type(ctb,CTB_CERT_SECKEY_TYPE)
                    154: 
                    155: #define MAX_SIGCERT_LENGTH (1+2 + KEYFRAGSIZE + 2+MAX_BYTE_PRECISION)
                    156: 
                    157: #define MAX_KEYCERT_LENGTH (1+2+4+256 + 5*(2+MAX_BYTE_PRECISION))
                    158: 
                    159: /* Modes for CTB_LITERAL2 packet */
                    160: #define        MODE_BINARY     'b'
                    161: #define        MODE_TEXT       't'
                    162: 
                    163: /* Define CANONICAL_TEXT for any system which normally uses CRLF's
                    164:    for text separators */
                    165: #ifdef MSDOS
                    166: #define        CANONICAL_TEXT
                    167: #endif /* MSDOS */
                    168: 
                    169: /* Prototype for the 'more' function, which blorts a file to the screen with
                    170:    page breaks, intelligent handling of line terminators, truncation of
                    171:    overly long lines, and zapping of illegal chars.  Implemented in MORE.C */
                    172: 
                    173: int more_file(char *fileName);
                    174: 
                    175: /* Prototypes for the transport armor routines */
                    176: 
                    177: boolean is_armor_file(char *infile);
                    178: int armor_file(char *infile, char *outfile, char *filename);
                    179: int de_armor_file(char *infile, char *outfile, boolean *newname);
                    180: 
                    181: void exitPGP(int);
                    182: void user_error();
                    183: 
                    184: /* Global filenames and system-wide file extensions... */
                    185: extern char CTX_EXTENSION[];
                    186: extern char PGP_EXTENSION[];
                    187: extern char ASC_EXTENSION[];
                    188: extern char SIG_EXTENSION[];
                    189: extern char BAK_EXTENSION[];
                    190: extern char SCRATCH_KEYRING_FILENAME[]; /* gets modified */
                    191: extern char CONSOLE_FILENAME[];
                    192: extern char SCRATCH_KEYRING_PATH[MAX_PATH];
                    193: extern char rel_version[];
                    194: extern char rel_date[];
                    195: 
                    196: /* These files use the environmental variable PGPPATH as a default path: */
                    197: extern char PUBLIC_KEYRING_FILENAME[32];
                    198: extern char SECRET_KEYRING_FILENAME[32];
                    199: extern char RANDSEED_FILENAME[32];
                    200: 
                    201: /* Variables which are global across the driver code */
                    202: extern boolean filter_mode;
                    203: extern FILE    *pgpout;        /* FILE structure for routine output */
                    204: 
                    205: /* Variables settable by config.pgp and referenced in config.c ... */
                    206: extern char language[];        /* foreign language prefix code for language.pgp file */
                    207: extern char charset[];
                    208: /* my_name is substring of default userid for secret key to make signatures */
                    209: extern char my_name[];
                    210: extern char tmpdir[];  /* directory for temp files, usually RAMdisk */
                    211: extern char floppyring[]; /* for comparing secret keys with backup on floppy */
                    212: extern char lit_mode;  /* text or binary mode for literal packet */
                    213: extern boolean emit_radix_64;
                    214: extern boolean showpass;
                    215: extern boolean keepctx;
                    216: extern boolean verbose;        /* display maximum information */
                    217: extern boolean compress_enabled;       /* attempt compression before encryption */
                    218: extern long timeshift; /* seconds from GMT timezone */
                    219: extern int pem_lines;
                    220: extern int marg_min;   /* number of marginally trusted signatures needed to
                    221:                                                   make a key fully-legit */
                    222: extern int compl_min;  /* number of fully trusted signatures needed */
                    223: extern int max_cert_depth;
                    224: extern char pager[];   /* file lister command */
                    225: 
                    226: extern char trust_lst[8][16];
                    227: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.