|
|
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 */
128: #define VERSION_BYTE_KLUDGE 3
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: /* Define CANONICAL_TEXT for any system which normally uses CRLF's
174: for text separators */
175: #ifdef MSDOS
176: #define CANONICAL_TEXT
177: #endif /* MSDOS */
178:
179: /* Prototype for the 'more' function, which blorts a file to the screen with
180: page breaks, intelligent handling of line terminators, truncation of
181: overly long lines, and zapping of illegal chars. Implemented in MORE.C */
182:
183: int more_file(char *fileName);
184:
185: /* Prototypes for the transport armor routines */
186:
187: boolean is_armor_file(char *infile, long startline);
188: int armor_file(char *infile, char *outfile, char *filename, char *clearname);
189: int de_armor_file(char *infile, char *outfile, long *curline);
190:
191: void user_error(void);
192:
193: /* Global filenames and system-wide file extensions... */
194: extern char PGP_EXTENSION[];
195: extern char ASC_EXTENSION[];
196: extern char SIG_EXTENSION[];
197: extern char BAK_EXTENSION[];
198: extern char CONSOLE_FILENAME[];
199: extern char rel_version[];
200:
201: /* These files use the environmental variable PGPPATH as a default path: */
202: extern char globalPubringName[MAX_PATH];
203: extern char globalSecringName[MAX_PATH];
204: extern char globalRandseedName[MAX_PATH];
205: extern char globalCommentString[128];
206:
207: /* Variables which are global across the driver code */
208: extern boolean filter_mode;
209: extern boolean moreflag;
210: extern FILE *pgpout; /* FILE structure for routine output */
211:
212: /* Variables settable by config.pgp and referenced in config.c ... */
1.1.1.7 ! root 213: extern char language[]; /* foreign language prefix code for language.pgp
! 214: file */
1.1.1.6 root 215: extern char charset[];
216: /* my_name is substring of default userid for secret key to make signatures */
217: extern char my_name[];
218: extern char floppyring[]; /* for comparing secret keys with backup on floppy */
219: extern char literal_mode; /* text or binary mode for literal packet */
220: extern boolean emit_radix_64;
221: extern boolean showpass;
222: extern boolean keepctx;
223: extern boolean verbose; /* display maximum information */
1.1.1.7 ! root 224: extern boolean compress_enabled; /* attempt compression before encryption */
1.1.1.6 root 225: extern boolean clear_signatures;
226: extern boolean encrypt_to_self; /* Should I encrypt to myself? */
227: extern boolean batchmode; /* for batch processing */
228: extern boolean quietmode; /* less verbose */
229: extern boolean force_flag; /* overwrite existing file without asking */
230: extern boolean pkcs_compat; /* Use PKCS format messages */
231: /* Ask for each key separately if it should be added to the keyring */
232: extern boolean interactive_add;
233: extern long timeshift; /* seconds from GMT timezone */
234: extern boolean signature_checked;
235: extern int pem_lines;
236: extern int marg_min; /* number of marginally trusted signatures needed to
237: make a key fully-legit */
238: extern int compl_min; /* number of fully trusted signatures needed */
239: extern int max_cert_depth;
240: extern char pager[]; /* file lister command */
241: extern boolean legal_kludge;
242: extern int version_byte;
243: extern boolean nomanual;
244:
245: /* These lists store hashed passwords for future use. */
246: /* passwds are passwords of as-yet-unknown purpose; keypasswds
247: are passwords used to decrypt keys. */
248: struct hashedpw {
249: struct hashedpw *next;
250: byte hash[16];
251: };
252: extern struct hashedpw *keypasswds, *passwds;
253:
254: extern boolean strip_spaces;
255:
256: #ifdef VMS
257: /*
258: * FDL Support Prototypes, Currently Used Only In SYSTEM.C and CRYPTO.C
259: */
260:
261: int fdl_generate(char *in_file, char **fdl, short *len);
262: VOID *fdl_create( char *fdl, short len, char *outfile, char *preserved_name);
263: int fdl_copyfile2bin(FILE *f, VOID *rab, word32 longcount);
264: void fdl_close( VOID *rab);
265: #endif /* VMS */
266:
267: extern int compressSignature(byte *header);
268:
269: #endif /* PGP_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.