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