|
|
1.1.1.6 ! 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: #ifndef PGP_H ! 13: #define PGP_H ! 14: ! 15: #include "usuals.h" ! 16: #include "more.h" ! 17: #include "armor.h" ! 18: ! 19: #define KEYFRAGSIZE 8 /* # of bytes in key ID modulus fragment */ ! 20: #define SIZEOF_TIMESTAMP 4 /* 32-bit timestamp */ ! 21: ! 22: /* The maximum length of the file path for this system. Varies on UNIX ! 23: systems */ ! 24: ! 25: #ifndef MAX_PATH ! 26: #ifdef MSDOS ! 27: #define MAX_PATH 64 ! 28: #else ! 29: #define MAX_PATH 256 ! 30: #endif ! 31: #endif ! 32: ! 33: #ifdef ATARI ! 34: #define sizeof(x) (int)sizeof(x) ! 35: #define fread(a,b,c,d) ((int)fread(a,b,c,d)) ! 36: #endif ! 37: ! 38: /* ! 39: ********************************************************************** ! 40: */ ! 41: ! 42: /* Cipher Type Byte (CTB) definitions follow...*/ ! 43: #define CTB_DESIGNATOR 0x80 ! 44: #define is_ctb(c) (((c) & CTB_DESIGNATOR)==CTB_DESIGNATOR) ! 45: #define CTB_TYPE_MASK 0x7c ! 46: #define CTB_LLEN_MASK 0x03 ! 47: ! 48: /* "length of length" field of packet, in bytes (1, 2, 4, 8 bytes): */ ! 49: #define ctb_llength(ctb) ((int) 1 << (int) ((ctb) & CTB_LLEN_MASK)) ! 50: ! 51: #define is_ctb_type(ctb,type) (((ctb) & CTB_TYPE_MASK)==(4*type)) ! 52: #define CTB_BYTE(type,llen) (CTB_DESIGNATOR + (4*type) + llen) ! 53: ! 54: #define CTB_PKE_TYPE 1 /* packet encrypted with RSA public key */ ! 55: #define CTB_SKE_TYPE 2 /* packet signed with RSA secret key */ ! 56: #define CTB_MD_TYPE 3 /* message digest packet */ ! 57: #define CTB_CERT_SECKEY_TYPE 5 /* secret key certificate */ ! 58: #define CTB_CERT_PUBKEY_TYPE 6 /* public key certificate */ ! 59: #define CTB_COMPRESSED_TYPE 8 /* compressed data packet */ ! 60: #define CTB_CKE_TYPE 9 /* conventional-key-encrypted data */ ! 61: #define CTB_LITERAL_TYPE 10 /* raw data with filename and mode */ ! 62: #define CTB_LITERAL2_TYPE 11 /* Fixed literal packet */ ! 63: #define CTB_KEYCTRL_TYPE 12 /* key control packet */ ! 64: #define CTB_USERID_TYPE 13 /* user id packet */ ! 65: #define CTB_COMMENT_TYPE 14 /* comment packet */ ! 66: ! 67: /* Unimplemented CTB packet types follow... */ ! 68: /* #define CTB_EXTENDED_TYPE 15 */ /* 2-byte CTB, 256 extra CTB types */ ! 69: ! 70: #define CTB_PKE CTB_BYTE(CTB_PKE_TYPE,1) ! 71: /* CTB_PKE len16 keyID mpi(RSA(CONKEYPKT)) */ ! 72: /* 1 2 SIZE countbytes()+2 */ ! 73: #define CTB_SKE CTB_BYTE(CTB_SKE_TYPE,1) ! 74: /* CTB_SKE len16 keyID mpi(RSA(MDPKT)) */ ! 75: /* 1 2 SIZE countbytes()+2 */ ! 76: #define CTB_MD CTB_BYTE(CTB_MD_TYPE,0) ! 77: /* CTB_MD len8 algorithm MD timestamp */ ! 78: #define CTB_CERT_SECKEY CTB_BYTE(CTB_CERT_SECKEY_TYPE,1) ! 79: /* CTB_CERT_SECKEY len16 timestamp userID mpi(n) mpi(e) mpi(d) mpi(p) mpi(q) mpi(u) crc16 */ ! 80: #define CTB_CERT_PUBKEY CTB_BYTE(CTB_CERT_PUBKEY_TYPE,1) ! 81: /* CTB_CERT_PUBKEY len16 timestamp userID mpi(n) mpi(e) crc16 */ ! 82: ! 83: #define CTB_KEYCTRL CTB_BYTE(CTB_KEYCTRL_TYPE,0) ! 84: #define CTB_USERID CTB_BYTE(CTB_USERID_TYPE,0) ! 85: ! 86: #define CTB_CKE CTB_BYTE(CTB_CKE_TYPE,3) ! 87: /* CTB_CKE ciphertext */ ! 88: ! 89: #define CTB_LITERAL CTB_BYTE(CTB_LITERAL_TYPE,3) ! 90: #define CTB_LITERAL2 CTB_BYTE(CTB_LITERAL_TYPE,3) ! 91: /* CTB_LITERAL data */ ! 92: ! 93: #define CTB_COMPRESSED CTB_BYTE(CTB_COMPRESSED_TYPE,3) ! 94: /* CTB_COMPRESSED compressedtext */ ! 95: ! 96: /* Public key encryption algorithm selector bytes. */ ! 97: #define RSA_ALGORITHM_BYTE 1 /* use RSA */ ! 98: ! 99: /* Conventional encryption algorithm selector bytes. */ ! 100: #define IDEA_ALGORITHM_BYTE 1 /* use the IDEA cipher */ ! 101: ! 102: /* Message digest algorithm selector bytes. */ ! 103: #define MD5_ALGORITHM_BYTE 1 /* MD5 message digest algorithm */ ! 104: ! 105: /* Data compression algorithm selector bytes. */ ! 106: #define ZIP2_ALGORITHM_BYTE 1 /* Zip-based deflate compression algorithm */ ! 107: ! 108: /* Signature classification bytes. */ ! 109: #define SB_SIGNATURE_BYTE 0x00 /* Signature of a binary msg or doc */ ! 110: #define SM_SIGNATURE_BYTE 0x01 /* Signature of canonical msg or doc */ ! 111: #define K0_SIGNATURE_BYTE 0x10 /* Key certification, generic */ ! 112: #define K1_SIGNATURE_BYTE 0x11 /* Key certification, persona */ ! 113: #define K2_SIGNATURE_BYTE 0x12 /* Key certification, casual ID */ ! 114: #define K3_SIGNATURE_BYTE 0x13 /* Key certification, positive ID */ ! 115: #define KC_SIGNATURE_BYTE 0x20 /* Key compromise */ ! 116: #define KR_SIGNATURE_BYTE 0x30 /* Key revocation */ ! 117: #define TS_SIGNATURE_BYTE 0x40 /* Timestamp someone else's signature */ ! 118: ! 119: /* Public key encrypted data classification bytes. */ ! 120: #define MD_ENCRYPTED_BYTE 1 /* Message digest is encrypted */ ! 121: #define CK_ENCRYPTED_BYTE 2 /* Conventional key is encrypted */ ! 122: ! 123: /* Version byte for data structures created by this version of PGP */ ! 124: #define VERSION_BYTE_OLD 2 /* PGP2 */ ! 125: #define VERSION_BYTE_KLUDGE 3 ! 126: ! 127: /* Values for trust bits in keycntrl packet after key packet */ ! 128: #define KC_OWNERTRUST_MASK 0x07 /* Trust bits for key owner */ ! 129: #define KC_OWNERTRUST_UNDEFINED 0x00 ! 130: #define KC_OWNERTRUST_UNKNOWN 0x01 ! 131: #define KC_OWNERTRUST_NEVER 0x02 ! 132: /* 2 levels reserved */ ! 133: #define KC_OWNERTRUST_USUALLY 0x05 ! 134: #define KC_OWNERTRUST_ALWAYS 0x06 ! 135: #define KC_OWNERTRUST_ULTIMATE 0x07 /* Only for keys in secret ring */ ! 136: #define KC_BUCKSTOP 0x80 /* This key is in secret ring */ ! 137: #define KC_DISABLED 0x20 /* key is disabled */ ! 138: ! 139: /* Values for trust bits in keycntrl packet after userid packet */ ! 140: #define KC_LEGIT_MASK 0x03 /* Key legit bits for key */ ! 141: #define KC_LEGIT_UNKNOWN 0x00 ! 142: #define KC_LEGIT_UNTRUSTED 0x01 ! 143: #define KC_LEGIT_MARGINAL 0x02 ! 144: #define KC_LEGIT_COMPLETE 0x03 ! 145: #define KC_WARNONLY 0x80 ! 146: ! 147: /* Values for trust bits in keycntrl packet after signature packet */ ! 148: #define KC_SIGTRUST_MASK 0x07 /* Trust bits for key owner */ ! 149: #define KC_SIGTRUST_UNDEFINED 0x00 ! 150: #define KC_SIGTRUST_UNKNOWN 0x01 ! 151: #define KC_SIGTRUST_UNTRUSTED 0x02 ! 152: /* 2 levels reserved */ ! 153: #define KC_SIGTRUST_MARGINAL 0x05 ! 154: #define KC_SIGTRUST_COMPLETE 0x06 ! 155: #define KC_SIGTRUST_ULTIMATE 0x07 ! 156: #define KC_SIG_CHECKED 0x40 /* This sig has been checked */ ! 157: #define KC_CONTIG 0x80 /* This sig is on a cert. path */ ! 158: ! 159: #define is_secret_key(ctb) is_ctb_type(ctb,CTB_CERT_SECKEY_TYPE) ! 160: ! 161: #define MPILEN (2+MAX_BYTE_PRECISION) ! 162: #define MAX_SIGCERT_LENGTH (1+2+1 +1+7 +KEYFRAGSIZE+2+2+MPILEN) ! 163: #define MAX_KEYCERT_LENGTH (1+2+1+4+2+1 +(2*MPILEN) +1+8 +(4*MPILEN) +2) ! 164: ! 165: /* Modes for CTB_LITERAL2 packet */ ! 166: #define MODE_BINARY 'b' ! 167: #define MODE_TEXT 't' ! 168: #define MODE_LOCAL 'l' ! 169: ! 170: /* Define CANONICAL_TEXT for any system which normally uses CRLF's ! 171: for text separators */ ! 172: #ifdef MSDOS ! 173: #define CANONICAL_TEXT ! 174: #endif /* MSDOS */ ! 175: ! 176: /* Prototype for the 'more' function, which blorts a file to the screen with ! 177: page breaks, intelligent handling of line terminators, truncation of ! 178: overly long lines, and zapping of illegal chars. Implemented in MORE.C */ ! 179: ! 180: int more_file(char *fileName); ! 181: ! 182: /* Prototypes for the transport armor routines */ ! 183: ! 184: boolean is_armor_file(char *infile, long startline); ! 185: int armor_file(char *infile, char *outfile, char *filename, char *clearname); ! 186: int de_armor_file(char *infile, char *outfile, long *curline); ! 187: ! 188: void user_error(void); ! 189: ! 190: /* Global filenames and system-wide file extensions... */ ! 191: extern char PGP_EXTENSION[]; ! 192: extern char ASC_EXTENSION[]; ! 193: extern char SIG_EXTENSION[]; ! 194: extern char BAK_EXTENSION[]; ! 195: extern char CONSOLE_FILENAME[]; ! 196: extern char rel_version[]; ! 197: ! 198: /* These files use the environmental variable PGPPATH as a default path: */ ! 199: extern char globalPubringName[MAX_PATH]; ! 200: extern char globalSecringName[MAX_PATH]; ! 201: extern char globalRandseedName[MAX_PATH]; ! 202: extern char globalCommentString[128]; ! 203: ! 204: /* Variables which are global across the driver code */ ! 205: extern boolean filter_mode; ! 206: extern boolean moreflag; ! 207: extern FILE *pgpout; /* FILE structure for routine output */ ! 208: ! 209: /* Variables settable by config.pgp and referenced in config.c ... */ ! 210: extern char language[]; /* foreign language prefix code for language.pgp file */ ! 211: extern char charset[]; ! 212: /* my_name is substring of default userid for secret key to make signatures */ ! 213: extern char my_name[]; ! 214: extern char floppyring[]; /* for comparing secret keys with backup on floppy */ ! 215: extern char literal_mode; /* text or binary mode for literal packet */ ! 216: extern boolean emit_radix_64; ! 217: extern boolean showpass; ! 218: extern boolean keepctx; ! 219: extern boolean verbose; /* display maximum information */ ! 220: extern boolean compress_enabled; /* attempt compression before encryption */ ! 221: extern boolean clear_signatures; ! 222: extern boolean encrypt_to_self; /* Should I encrypt to myself? */ ! 223: extern boolean batchmode; /* for batch processing */ ! 224: extern boolean quietmode; /* less verbose */ ! 225: extern boolean force_flag; /* overwrite existing file without asking */ ! 226: extern boolean pkcs_compat; /* Use PKCS format messages */ ! 227: /* Ask for each key separately if it should be added to the keyring */ ! 228: extern boolean interactive_add; ! 229: extern long timeshift; /* seconds from GMT timezone */ ! 230: extern boolean signature_checked; ! 231: extern int pem_lines; ! 232: extern int marg_min; /* number of marginally trusted signatures needed to ! 233: make a key fully-legit */ ! 234: extern int compl_min; /* number of fully trusted signatures needed */ ! 235: extern int max_cert_depth; ! 236: extern char pager[]; /* file lister command */ ! 237: extern boolean legal_kludge; ! 238: extern int version_byte; ! 239: extern boolean nomanual; ! 240: ! 241: /* These lists store hashed passwords for future use. */ ! 242: /* passwds are passwords of as-yet-unknown purpose; keypasswds ! 243: are passwords used to decrypt keys. */ ! 244: struct hashedpw { ! 245: struct hashedpw *next; ! 246: byte hash[16]; ! 247: }; ! 248: extern struct hashedpw *keypasswds, *passwds; ! 249: ! 250: extern boolean strip_spaces; ! 251: ! 252: #ifdef VMS ! 253: /* ! 254: * FDL Support Prototypes, Currently Used Only In SYSTEM.C and CRYPTO.C ! 255: */ ! 256: ! 257: int fdl_generate(char *in_file, char **fdl, short *len); ! 258: VOID *fdl_create( char *fdl, short len, char *outfile, char *preserved_name); ! 259: int fdl_copyfile2bin(FILE *f, VOID *rab, word32 longcount); ! 260: void fdl_close( VOID *rab); ! 261: #endif /* VMS */ ! 262: ! 263: extern int compressSignature(byte *header); ! 264: ! 265: #endif /* PGP_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.