|
|
1.1.1.2 ! 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_LITERAL2_TYPE 11 /* Fixed literal packet */ ! 57: #define CTB_KEYCTRL_TYPE 12 /* key control packet */ ! 58: #define CTB_USERID_TYPE 13 /* user id packet */ ! 59: #define CTB_COMMENT_TYPE 14 /* comment packet */ ! 60: ! 61: /* Unimplemented CTB packet types follow... */ ! 62: /* #define CTB_EXTENDED_TYPE 15 */ /* 2-byte CTB, 256 extra CTB types */ ! 63: ! 64: #define CTB_PKE CTB_BYTE(CTB_PKE_TYPE,1) ! 65: /* CTB_PKE len16 keyID mpi(RSA(CONKEYPKT)) */ ! 66: /* 1 2 SIZE countbytes()+2 */ ! 67: #define CTB_SKE CTB_BYTE(CTB_SKE_TYPE,1) ! 68: /* CTB_SKE len16 keyID mpi(RSA(MDPKT)) */ ! 69: /* 1 2 SIZE countbytes()+2 */ ! 70: #define CTB_MD CTB_BYTE(CTB_MD_TYPE,0) ! 71: /* CTB_MD len8 algorithm MD timestamp */ ! 72: #define CTB_CERT_SECKEY CTB_BYTE(CTB_CERT_SECKEY_TYPE,1) ! 73: /* CTB_CERT_SECKEY len16 timestamp userID mpi(n) mpi(e) mpi(d) mpi(p) mpi(q) mpi(u) crc16 */ ! 74: #define CTB_CERT_PUBKEY CTB_BYTE(CTB_CERT_PUBKEY_TYPE,1) ! 75: /* CTB_CERT_PUBKEY len16 timestamp userID mpi(n) mpi(e) crc16 */ ! 76: ! 77: #define CTB_KEYCTRL CTB_BYTE(CTB_KEYCTRL_TYPE,0) ! 78: #define CTB_USERID CTB_BYTE(CTB_USERID_TYPE,0) ! 79: ! 80: #define CTB_CKE CTB_BYTE(CTB_CKE_TYPE,3) ! 81: /* CTB_CKE ciphertext */ ! 82: ! 83: #define CTB_LITERAL CTB_BYTE(CTB_LITERAL_TYPE,3) ! 84: #define CTB_LITERAL2 CTB_BYTE(CTB_LITERAL_TYPE,3) ! 85: /* CTB_LITERAL data */ ! 86: ! 87: #define CTB_COMPRESSED CTB_BYTE(CTB_COMPRESSED_TYPE,3) ! 88: /* CTB_COMPRESSED compressedtext */ ! 89: ! 90: /* Public key encryption algorithm selector bytes. */ ! 91: #define RSA_ALGORITHM_BYTE 1 /* use RSA */ ! 92: ! 93: /* Conventional encryption algorithm selector bytes. */ ! 94: #define IDEA_ALGORITHM_BYTE 1 /* use the IDEA cipher */ ! 95: ! 96: /* Message digest algorithm selector bytes. */ ! 97: #define MD5_ALGORITHM_BYTE 1 /* MD5 message digest algorithm */ ! 98: ! 99: /* Data compression algorithm selector bytes. */ ! 100: #define ZIP2_ALGORITHM_BYTE 1 /* Zip-based deflate compression algorithm */ ! 101: ! 102: /* Signature classification bytes. */ ! 103: #define SB_SIGNATURE_BYTE 0x00 /* Signature of a binary msg or doc */ ! 104: #define SM_SIGNATURE_BYTE 0x01 /* Signature of canonical msg or doc */ ! 105: #define K0_SIGNATURE_BYTE 0x10 /* Key certification, generic */ ! 106: #define K1_SIGNATURE_BYTE 0x11 /* Key certification, persona */ ! 107: #define K2_SIGNATURE_BYTE 0x12 /* Key certification, casual ID */ ! 108: #define K3_SIGNATURE_BYTE 0x13 /* Key certification, positive ID */ ! 109: #define KC_SIGNATURE_BYTE 0x20 /* Key compromise */ ! 110: #define KR_SIGNATURE_BYTE 0x30 /* Key revocation */ ! 111: #define TS_SIGNATURE_BYTE 0x40 /* Timestamp someone else's signature */ ! 112: ! 113: /* Public key encrypted data classification bytes. */ ! 114: #define MD_ENCRYPTED_BYTE 1 /* Message digest is encrypted */ ! 115: #define CK_ENCRYPTED_BYTE 2 /* Conventional key is encrypted */ ! 116: ! 117: /* Version byte for data structures created by this version of PGP */ ! 118: #define VERSION_BYTE 2 /* PGP2 */ ! 119: ! 120: /* Values for trust bits in keycntrl packet after key packet */ ! 121: #define KC_OWNERTRUST_MASK 0x07 /* Trust bits for key owner */ ! 122: #define KC_OWNERTRUST_UNDEFINED 0x00 ! 123: #define KC_OWNERTRUST_UNKNOWN 0x01 ! 124: #define KC_OWNERTRUST_NEVER 0x02 ! 125: /* 2 levels reserved */ ! 126: #define KC_OWNERTRUST_USUALLY 0x05 ! 127: #define KC_OWNERTRUST_ALWAYS 0x06 ! 128: #define KC_OWNERTRUST_ULTIMATE 0x07 /* Only for keys in secret ring */ ! 129: #define KC_BUCKSTOP 0x80 /* This key is in secret ring */ ! 130: #define KC_VISITED 0x40 ! 131: ! 132: /* Values for trust bits in keycntrl packet after userid packet */ ! 133: #define KC_LEGIT_MASK 0x03 /* Key legit bits for key */ ! 134: #define KC_LEGIT_UNKNOWN 0x00 ! 135: #define KC_LEGIT_UNTRUSTED 0x01 ! 136: #define KC_LEGIT_MARGINAL 0x02 ! 137: #define KC_LEGIT_COMPLETE 0x03 ! 138: #define KC_WARNONLY 0x80 ! 139: ! 140: /* Values for trust bits in keycntrl packet after signature packet */ ! 141: #define KC_SIGTRUST_MASK 0x07 /* Trust bits for key owner */ ! 142: #define KC_SIGTRUST_UNDEFINED 0x00 ! 143: #define KC_SIGTRUST_UNKNOWN 0x01 ! 144: #define KC_SIGTRUST_UNTRUSTED 0x02 ! 145: /* 2 levels reserved */ ! 146: #define KC_SIGTRUST_MARGINAL 0x05 ! 147: #define KC_SIGTRUST_COMPLETE 0x06 ! 148: #define KC_SIGTRUST_ULTIMATE 0x07 ! 149: #define KC_CONTIG 0x80 /* This sig is on a cert. path */ ! 150: ! 151: #define MAINT_CHECK 0x01 ! 152: #define MAINT_VERBOSE 0x02 ! 153: #define MAINT_SILENT 0x04 ! 154: ! 155: #define is_secret_key(ctb) is_ctb_type(ctb,CTB_CERT_SECKEY_TYPE) ! 156: ! 157: #define MPILEN (2+MAX_BYTE_PRECISION) ! 158: #define MAX_SIGCERT_LENGTH (1+2+1 +1+7 +KEYFRAGSIZE+2+2+MPILEN) ! 159: #define MAX_KEYCERT_LENGTH (1+2+1+4+2+1 +(2*MPILEN) +1+8 +(4*MPILEN) +2) ! 160: ! 161: /* Modes for CTB_LITERAL2 packet */ ! 162: #define MODE_BINARY 'b' ! 163: #define MODE_TEXT 't' ! 164: #define MODE_LOCAL 'l' ! 165: ! 166: /* Define CANONICAL_TEXT for any system which normally uses CRLF's ! 167: for text separators */ ! 168: #ifdef MSDOS ! 169: #define CANONICAL_TEXT ! 170: #endif /* MSDOS */ ! 171: ! 172: /* Prototype for the 'more' function, which blorts a file to the screen with ! 173: page breaks, intelligent handling of line terminators, truncation of ! 174: overly long lines, and zapping of illegal chars. Implemented in MORE.C */ ! 175: ! 176: int more_file(char *fileName); ! 177: ! 178: /* Prototypes for the transport armor routines */ ! 179: ! 180: boolean is_armor_file(char *infile, long startline); ! 181: int armor_file(char *infile, char *outfile, char *filename, char *clearname); ! 182: int de_armor_file(char *infile, char *outfile, long *curline); ! 183: ! 184: void exitPGP(int); ! 185: void user_error(); ! 186: ! 187: /* Global filenames and system-wide file extensions... */ ! 188: extern char CTX_EXTENSION[]; ! 189: extern char PGP_EXTENSION[]; ! 190: extern char ASC_EXTENSION[]; ! 191: extern char SIG_EXTENSION[]; ! 192: extern char BAK_EXTENSION[]; ! 193: extern char CONSOLE_FILENAME[]; ! 194: extern char rel_version[]; ! 195: extern char rel_date[]; ! 196: ! 197: /* These files use the environmental variable PGPPATH as a default path: */ ! 198: extern char PUBLIC_KEYRING_FILENAME[32]; ! 199: extern char SECRET_KEYRING_FILENAME[32]; ! 200: extern char RANDSEED_FILENAME[32]; ! 201: ! 202: /* Variables which are global across the driver code */ ! 203: extern boolean filter_mode; ! 204: extern FILE *pgpout; /* FILE structure for routine output */ ! 205: ! 206: /* Variables settable by config.pgp and referenced in config.c ... */ ! 207: extern char language[]; /* foreign language prefix code for language.pgp file */ ! 208: extern char charset[]; ! 209: /* my_name is substring of default userid for secret key to make signatures */ ! 210: extern char my_name[]; ! 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 boolean clear_signatures; ! 219: extern long timeshift; /* seconds from GMT timezone */ ! 220: extern int pem_lines; ! 221: extern int marg_min; /* number of marginally trusted signatures needed to ! 222: make a key fully-legit */ ! 223: extern int compl_min; /* number of fully trusted signatures needed */ ! 224: extern int max_cert_depth; ! 225: extern char pager[]; /* file lister command */ ! 226: ! 227: extern char trust_lst[8][16]; ! 228: ! 229: #ifdef VMS ! 230: /* ! 231: * FDL Support Prototypes, Currently Used Only In SYSTEM.C and CRYPTO.C ! 232: */ ! 233: ! 234: int fdl_generate(char *in_file, char **fdl, short *len); ! 235: void *fdl_create( char *fdl, short len, char *outfile, char *preserved_name); ! 236: int fdl_copyfile2bin(FILE *f, void *rab, word32 longcount); ! 237: void fdl_close( void *rab); ! 238: #endif /* VMS */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.