|
|
1.1.1.5 ! 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 2 /* PGP2 */ ! 125: ! 126: /* Values for trust bits in keycntrl packet after key packet */ ! 127: #define KC_OWNERTRUST_MASK 0x07 /* Trust bits for key owner */ ! 128: #define KC_OWNERTRUST_UNDEFINED 0x00 ! 129: #define KC_OWNERTRUST_UNKNOWN 0x01 ! 130: #define KC_OWNERTRUST_NEVER 0x02 ! 131: /* 2 levels reserved */ ! 132: #define KC_OWNERTRUST_USUALLY 0x05 ! 133: #define KC_OWNERTRUST_ALWAYS 0x06 ! 134: #define KC_OWNERTRUST_ULTIMATE 0x07 /* Only for keys in secret ring */ ! 135: #define KC_BUCKSTOP 0x80 /* This key is in secret ring */ ! 136: #define KC_DISABLED 0x20 /* key is disabled */ ! 137: ! 138: /* Values for trust bits in keycntrl packet after userid packet */ ! 139: #define KC_LEGIT_MASK 0x03 /* Key legit bits for key */ ! 140: #define KC_LEGIT_UNKNOWN 0x00 ! 141: #define KC_LEGIT_UNTRUSTED 0x01 ! 142: #define KC_LEGIT_MARGINAL 0x02 ! 143: #define KC_LEGIT_COMPLETE 0x03 ! 144: #define KC_WARNONLY 0x80 ! 145: ! 146: /* Values for trust bits in keycntrl packet after signature packet */ ! 147: #define KC_SIGTRUST_MASK 0x07 /* Trust bits for key owner */ ! 148: #define KC_SIGTRUST_UNDEFINED 0x00 ! 149: #define KC_SIGTRUST_UNKNOWN 0x01 ! 150: #define KC_SIGTRUST_UNTRUSTED 0x02 ! 151: /* 2 levels reserved */ ! 152: #define KC_SIGTRUST_MARGINAL 0x05 ! 153: #define KC_SIGTRUST_COMPLETE 0x06 ! 154: #define KC_SIGTRUST_ULTIMATE 0x07 ! 155: #define KC_SIG_CHECKED 0x40 /* This sig has been checked */ ! 156: #define KC_CONTIG 0x80 /* This sig is on a cert. path */ ! 157: ! 158: #define is_secret_key(ctb) is_ctb_type(ctb,CTB_CERT_SECKEY_TYPE) ! 159: ! 160: #define MPILEN (2+MAX_BYTE_PRECISION) ! 161: #define MAX_SIGCERT_LENGTH (1+2+1 +1+7 +KEYFRAGSIZE+2+2+MPILEN) ! 162: #define MAX_KEYCERT_LENGTH (1+2+1+4+2+1 +(2*MPILEN) +1+8 +(4*MPILEN) +2) ! 163: ! 164: /* Modes for CTB_LITERAL2 packet */ ! 165: #define MODE_BINARY 'b' ! 166: #define MODE_TEXT 't' ! 167: #define MODE_LOCAL 'l' ! 168: ! 169: /* Define CANONICAL_TEXT for any system which normally uses CRLF's ! 170: for text separators */ ! 171: #ifdef MSDOS ! 172: #define CANONICAL_TEXT ! 173: #endif /* MSDOS */ ! 174: ! 175: /* Prototype for the 'more' function, which blorts a file to the screen with ! 176: page breaks, intelligent handling of line terminators, truncation of ! 177: overly long lines, and zapping of illegal chars. Implemented in MORE.C */ ! 178: ! 179: int more_file(char *fileName); ! 180: ! 181: /* Prototypes for the transport armor routines */ ! 182: ! 183: boolean is_armor_file(char *infile, long startline); ! 184: int armor_file(char *infile, char *outfile, char *filename, char *clearname); ! 185: int de_armor_file(char *infile, char *outfile, long *curline); ! 186: ! 187: void user_error(void); ! 188: ! 189: /* Global filenames and system-wide file extensions... */ ! 190: extern char PGP_EXTENSION[]; ! 191: extern char ASC_EXTENSION[]; ! 192: extern char SIG_EXTENSION[]; ! 193: extern char BAK_EXTENSION[]; ! 194: extern char CONSOLE_FILENAME[]; ! 195: extern char rel_version[]; ! 196: ! 197: /* These files use the environmental variable PGPPATH as a default path: */ ! 198: extern char globalPubringName[MAX_PATH]; ! 199: extern char globalSecringName[MAX_PATH]; ! 200: extern char globalRandseedName[MAX_PATH]; ! 201: extern char globalCommentString[128]; ! 202: ! 203: /* Variables which are global across the driver code */ ! 204: extern boolean filter_mode; ! 205: extern boolean moreflag; ! 206: extern FILE *pgpout; /* FILE structure for routine output */ ! 207: ! 208: /* Variables settable by config.pgp and referenced in config.c ... */ ! 209: extern char language[]; /* foreign language prefix code for language.pgp file */ ! 210: extern char charset[]; ! 211: /* my_name is substring of default userid for secret key to make signatures */ ! 212: extern char my_name[]; ! 213: extern char floppyring[]; /* for comparing secret keys with backup on floppy */ ! 214: extern char literal_mode; /* text or binary mode for literal packet */ ! 215: extern boolean emit_radix_64; ! 216: extern boolean showpass; ! 217: extern boolean keepctx; ! 218: extern boolean verbose; /* display maximum information */ ! 219: extern boolean compress_enabled; /* attempt compression before encryption */ ! 220: extern boolean clear_signatures; ! 221: extern boolean encrypt_to_self; /* Should I encrypt to myself? */ ! 222: extern boolean batchmode; /* for batch processing */ ! 223: extern boolean quietmode; /* less verbose */ ! 224: extern boolean force_flag; /* overwrite existing file without asking */ ! 225: extern boolean pkcs_compat; /* Use PKCS format messages */ ! 226: /* Ask for each key separately if it should be added to the keyring */ ! 227: extern boolean interactive_add; ! 228: extern long timeshift; /* seconds from GMT timezone */ ! 229: extern boolean signature_checked; ! 230: extern int pem_lines; ! 231: extern int marg_min; /* number of marginally trusted signatures needed to ! 232: make a key fully-legit */ ! 233: extern int compl_min; /* number of fully trusted signatures needed */ ! 234: extern int max_cert_depth; ! 235: extern char pager[]; /* file lister command */ ! 236: ! 237: /* These lists store hashed passwords for future use. */ ! 238: /* passwds are passwords of as-yet-unknown purpose; keypasswds ! 239: are passwords used to decrypt keys. */ ! 240: struct hashedpw { ! 241: struct hashedpw *next; ! 242: byte hash[16]; ! 243: }; ! 244: extern struct hashedpw *keypasswds, *passwds; ! 245: ! 246: extern boolean strip_spaces; ! 247: ! 248: #ifdef VMS ! 249: /* ! 250: * FDL Support Prototypes, Currently Used Only In SYSTEM.C and CRYPTO.C ! 251: */ ! 252: ! 253: int fdl_generate(char *in_file, char **fdl, short *len); ! 254: VOID *fdl_create( char *fdl, short len, char *outfile, char *preserved_name); ! 255: int fdl_copyfile2bin(FILE *f, VOID *rab, word32 longcount); ! 256: void fdl_close( VOID *rab); ! 257: #endif /* VMS */ ! 258: ! 259: extern int compressSignature(byte *header); ! 260: ! 261: #endif /* PGP_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.