|
|
1.1.1.9 ! 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 __PUREC__ ! 34: #define sizeof(x) (int)sizeof(x) ! 35: #endif ! 36: ! 37: /* ! 38: ********************************************************************** ! 39: */ ! 40: ! 41: /* Cipher Type Byte (CTB) definitions follow...*/ ! 42: #define CTB_DESIGNATOR 0x80 ! 43: #define is_ctb(c) (((c) & CTB_DESIGNATOR)==CTB_DESIGNATOR) ! 44: #define CTB_TYPE_MASK 0x7c ! 45: #define CTB_LLEN_MASK 0x03 ! 46: ! 47: /* "length of length" field of packet, in bytes (1, 2, 4, 8 bytes): */ ! 48: #define ctb_llength(ctb) ((int) 1 << (int) ((ctb) & CTB_LLEN_MASK)) ! 49: ! 50: #define is_ctb_type(ctb,type) (((ctb) & CTB_TYPE_MASK)==(4*type)) ! 51: #define CTB_BYTE(type,llen) (CTB_DESIGNATOR + (4*type) + llen) ! 52: ! 53: #define CTB_PKE_TYPE 1 /* packet encrypted with RSA public ! 54: 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) ! 80: mpi(p) mpi(q) mpi(u) crc16 */ ! 81: #define CTB_CERT_PUBKEY CTB_BYTE(CTB_CERT_PUBKEY_TYPE,1) ! 82: /* CTB_CERT_PUBKEY len16 timestamp userID mpi(n) mpi(e) crc16 */ ! 83: ! 84: #define CTB_KEYCTRL CTB_BYTE(CTB_KEYCTRL_TYPE,0) ! 85: #define CTB_USERID CTB_BYTE(CTB_USERID_TYPE,0) ! 86: ! 87: #define CTB_CKE CTB_BYTE(CTB_CKE_TYPE,3) ! 88: /* CTB_CKE ciphertext */ ! 89: ! 90: #define CTB_LITERAL CTB_BYTE(CTB_LITERAL_TYPE,3) ! 91: #define CTB_LITERAL2 CTB_BYTE(CTB_LITERAL_TYPE,3) ! 92: /* CTB_LITERAL data */ ! 93: ! 94: #define CTB_COMPRESSED CTB_BYTE(CTB_COMPRESSED_TYPE,3) ! 95: /* CTB_COMPRESSED compressedtext */ ! 96: ! 97: /* Public key encryption algorithm selector bytes. */ ! 98: #define RSA_ALGORITHM_BYTE 1 /* use RSA */ ! 99: ! 100: /* Conventional encryption algorithm selector bytes. */ ! 101: #define IDEA_ALGORITHM_BYTE 1 /* use the IDEA cipher */ ! 102: ! 103: /* Message digest algorithm selector bytes. */ ! 104: #define MD5_ALGORITHM_BYTE 1 /* MD5 message digest algorithm */ ! 105: ! 106: /* Data compression algorithm selector bytes. */ ! 107: #define ZIP2_ALGORITHM_BYTE 1 /* Zip-based deflate compression algorithm */ ! 108: ! 109: /* Signature classification bytes. */ ! 110: #define SB_SIGNATURE_BYTE 0x00 /* Signature of a binary msg or doc */ ! 111: #define SM_SIGNATURE_BYTE 0x01 /* Signature of canonical msg or doc */ ! 112: #define K0_SIGNATURE_BYTE 0x10 /* Key certification, generic */ ! 113: #define K1_SIGNATURE_BYTE 0x11 /* Key certification, persona */ ! 114: #define K2_SIGNATURE_BYTE 0x12 /* Key certification, casual ID */ ! 115: #define K3_SIGNATURE_BYTE 0x13 /* Key certification, positive ID */ ! 116: #define KC_SIGNATURE_BYTE 0x20 /* Key compromise */ ! 117: #define KR_SIGNATURE_BYTE 0x30 /* Key revocation */ ! 118: #define TS_SIGNATURE_BYTE 0x40 /* Timestamp someone else's ! 119: signature */ ! 120: ! 121: /* Public key encrypted data classification bytes. */ ! 122: #define MD_ENCRYPTED_BYTE 1 /* Message digest is encrypted */ ! 123: #define CK_ENCRYPTED_BYTE 2 /* Conventional key is encrypted */ ! 124: ! 125: /* Version byte for data structures created by this version of PGP */ ! 126: #define VERSION_BYTE_OLD 2 /* PGP2 */ ! 127: #define VERSION_BYTE_NEW 3 ! 128: ! 129: /* Values for trust bits in keycntrl packet after key packet */ ! 130: #define KC_OWNERTRUST_MASK 0x07 /* Trust bits for key owner */ ! 131: #define KC_OWNERTRUST_UNDEFINED 0x00 ! 132: #define KC_OWNERTRUST_UNKNOWN 0x01 ! 133: #define KC_OWNERTRUST_NEVER 0x02 ! 134: /* 2 levels reserved */ ! 135: #define KC_OWNERTRUST_USUALLY 0x05 ! 136: #define KC_OWNERTRUST_ALWAYS 0x06 ! 137: #define KC_OWNERTRUST_ULTIMATE 0x07 /* Only for keys in secret ring */ ! 138: #define KC_BUCKSTOP 0x80 /* This key is in secret ring */ ! 139: #define KC_DISABLED 0x20 /* key is disabled */ ! 140: ! 141: /* Values for trust bits in keycntrl packet after userid packet */ ! 142: #define KC_LEGIT_MASK 0x03 /* Key legit bits for key */ ! 143: #define KC_LEGIT_UNKNOWN 0x00 ! 144: #define KC_LEGIT_UNTRUSTED 0x01 ! 145: #define KC_LEGIT_MARGINAL 0x02 ! 146: #define KC_LEGIT_COMPLETE 0x03 ! 147: #define KC_WARNONLY 0x80 ! 148: ! 149: /* Values for trust bits in keycntrl packet after signature packet */ ! 150: #define KC_SIGTRUST_MASK 0x07 /* Trust bits for key owner */ ! 151: #define KC_SIGTRUST_UNDEFINED 0x00 ! 152: #define KC_SIGTRUST_UNKNOWN 0x01 ! 153: #define KC_SIGTRUST_UNTRUSTED 0x02 ! 154: /* 2 levels reserved */ ! 155: #define KC_SIGTRUST_MARGINAL 0x05 ! 156: #define KC_SIGTRUST_COMPLETE 0x06 ! 157: #define KC_SIGTRUST_ULTIMATE 0x07 ! 158: #define KC_SIG_CHECKED 0x40 /* This sig has been checked */ ! 159: #define KC_CONTIG 0x80 /* This sig is on a cert. path */ ! 160: ! 161: #define is_secret_key(ctb) is_ctb_type(ctb,CTB_CERT_SECKEY_TYPE) ! 162: ! 163: #define MPILEN (2+MAX_BYTE_PRECISION) ! 164: #define MAX_SIGCERT_LENGTH (1+2+1 +1+7 +KEYFRAGSIZE+2+2+MPILEN) ! 165: #define MAX_KEYCERT_LENGTH (1+2+1+4+2+1 +(2*MPILEN) +1+8 +(4*MPILEN) +2) ! 166: ! 167: /* Modes for CTB_LITERAL2 packet */ ! 168: #ifdef EBCDIC ! 169: #define MODE_BINARY 0x62 ! 170: #define MODE_TEXT 0x74 ! 171: #define MODE_LOCAL 0x6c ! 172: #else ! 173: #define MODE_BINARY 'b' ! 174: #define MODE_TEXT 't' ! 175: #define MODE_LOCAL 'l' ! 176: #endif ! 177: ! 178: void user_error(void); ! 179: ! 180: /* Global filenames and system-wide file extensions... */ ! 181: extern char PGP_EXTENSION[]; ! 182: extern char ASC_EXTENSION[]; ! 183: extern char SIG_EXTENSION[]; ! 184: extern char BAK_EXTENSION[]; ! 185: extern char CONSOLE_FILENAME[]; ! 186: extern char rel_version[]; ! 187: ! 188: /* These files use the environmental variable PGPPATH as a default path: */ ! 189: extern char globalPubringName[MAX_PATH]; ! 190: extern char globalSecringName[MAX_PATH]; ! 191: extern char globalRandseedName[MAX_PATH]; ! 192: extern char globalCommentString[128]; ! 193: ! 194: /* Variables which are global across the driver code */ ! 195: extern boolean filter_mode; ! 196: extern boolean moreflag; ! 197: extern FILE *pgpout; /* FILE structure for routine output */ ! 198: ! 199: /* Variables settable by config.pgp and referenced in config.c ... */ ! 200: extern char language[]; /* foreign language prefix code for language.pgp ! 201: file */ ! 202: extern char charset[]; ! 203: extern char charset_header[]; ! 204: /* my_name is substring of default userid for secret key to make signatures */ ! 205: extern char my_name[]; ! 206: extern char floppyring[]; /* for comparing secret keys with backup on floppy */ ! 207: extern char literal_mode; /* text or binary mode for literal packet */ ! 208: extern boolean emit_radix_64; ! 209: extern boolean showpass; ! 210: extern boolean keepctx; ! 211: extern boolean verbose; /* display maximum information */ ! 212: extern boolean compress_enabled; /* attempt compression before encryption */ ! 213: extern boolean clear_signatures; ! 214: extern boolean encrypt_to_self; /* Should I encrypt to myself? */ ! 215: extern boolean sign_new_userids; ! 216: extern boolean batchmode; /* for batch processing */ ! 217: extern boolean quietmode; /* less verbose */ ! 218: extern boolean force_flag; /* overwrite existing file without asking */ ! 219: /* Ask for each key separately if it should be added to the keyring */ ! 220: extern boolean interactive_add; ! 221: extern long timeshift; /* seconds from GMT timezone */ ! 222: extern boolean signature_checked; ! 223: extern int checksig_pass; ! 224: extern int pem_lines; ! 225: extern int marg_min; /* number of marginally trusted signatures needed to ! 226: make a key fully-legit */ ! 227: extern int compl_min; /* number of fully trusted signatures needed */ ! 228: extern int max_cert_depth; ! 229: extern char pager[]; /* file lister command */ ! 230: extern int version_byte; ! 231: extern boolean nomanual; ! 232: extern int makerandom; /* Fill in file with this many random bytes */ ! 233: ! 234: /* These lists store hashed passwords for future use. */ ! 235: /* passwds are passwords of as-yet-unknown purpose; keypasswds ! 236: are passwords used to decrypt keys. */ ! 237: struct hashedpw { ! 238: struct hashedpw *next; ! 239: byte hash[16]; ! 240: }; ! 241: extern struct hashedpw *keypasswds, *passwds; ! 242: ! 243: extern boolean strip_spaces; ! 244: extern boolean use_charset_header; ! 245: ! 246: #ifdef VMS ! 247: /* ! 248: * FDL Support Prototypes, Currently Used Only In SYSTEM.C and CRYPTO.C ! 249: */ ! 250: ! 251: int fdl_generate(char *in_file, char **fdl, short *len); ! 252: VOID *fdl_create( char *fdl, short len, char *outfile, char *preserved_name); ! 253: int fdl_copyfile2bin(FILE *f, VOID *rab, word32 longcount); ! 254: void fdl_close( VOID *rab); ! 255: #endif /* VMS */ ! 256: ! 257: extern int compressSignature(byte *header); ! 258: ! 259: #endif /* PGP_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.