Old vim63.crypt.patches
1 *** vim63/src/buffer.c 2004-06-01 14:42:34.000000000 +0100
2 --- vim63/src/buffer.c.new 2004-07-25 23:02:33.324492000 +0100
3 ***************
4 *** 1628,1636 ****
5 clear_string_option(&buf->b_p_inde);
6 clear_string_option(&buf->b_p_indk);
7 #endif
8 - #ifdef FEAT_CRYPT
9 - clear_string_option(&buf->b_p_key);
10 - #endif
11 clear_string_option(&buf->b_p_kp);
12 clear_string_option(&buf->b_p_mps);
13 clear_string_option(&buf->b_p_fo);
14 --- 1628,1633 ----
15 *** vim63/src/digraph.c 2004-04-19 18:00:45.000000000 +0100
16 --- vim63/src/digraph.c.new 2004-07-25 23:05:08.521006000 +0100
17 ***************
18 *** 2041,2047 ****
19 if (cmdline)
20 {
21 if (char2cells(c) == 1
22 ! #if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
23 && cmdline_star == 0
24 #endif
25 )
26 --- 2041,2047 ----
27 if (cmdline)
28 {
29 if (char2cells(c) == 1
30 ! #if defined(FEAT_EVAL)
31 && cmdline_star == 0
32 #endif
33 )
34 *** vim63/src/eval.c 2004-05-26 15:34:38.000000000 +0100
35 --- vim63/src/eval.c.new 2004-07-25 23:05:37.563832000 +0100
36 ***************
37 *** 4779,4787 ****
38 #ifdef FEAT_COMMENTS
39 "comments",
40 #endif
41 - #ifdef FEAT_CRYPT
42 - "cryptv",
43 - #endif
44 #ifdef FEAT_CSCOPE
45 "cscope",
46 #endif
47 --- 4779,4784 ----
48 *** vim63/src/ex_docmd.c 2004-05-30 19:23:31.000000000 +0100
49 --- vim63/src/ex_docmd.c.new 2004-07-25 23:07:10.924911000 +0100
50 ***************
51 *** 377,387 ****
52 # define ex_nohlsearch ex_ni
53 # define ex_match ex_ni
54 #endif
55 - #ifdef FEAT_CRYPT
56 - static void ex_X __ARGS((exarg_T *eap));
57 - #else
58 # define ex_X ex_ni
59 - #endif
60 #ifdef FEAT_FOLDING
61 static void ex_fold __ARGS((exarg_T *eap));
62 static void ex_foldopen __ARGS((exarg_T *eap));
63 --- 377,383 ----
64 ***************
65 *** 9654,9672 ****
66 }
67 #endif
68
69 - #ifdef FEAT_CRYPT
70 - /*
71 - * ":X": Get crypt key
72 - */
73 - /*ARGSUSED*/
74 - static void
75 - ex_X(eap)
76 - exarg_T *eap;
77 - {
78 - (void)get_crypt_key(TRUE, TRUE);
79 - }
80 - #endif
81 -
82 #ifdef FEAT_FOLDING
83 static void
84 ex_fold(eap)
85 --- 9650,9655 ----
86 *** vim63/src/ex_getln.c 2004-06-01 08:42:18.000000000 +0100
87 --- vim63/src/ex_getln.c.new 2004-07-25 23:09:42.493586000 +0100
88 ***************
89 *** 326,332 ****
90 || c == intr_char
91 #endif
92 )
93 ! #if defined(FEAT_EVAL) || defined(FEAT_CRYPT)
94 && firstc != '@'
95 #endif
96 #ifdef FEAT_EVAL
97 --- 326,332 ----
98 || c == intr_char
99 #endif
100 )
101 ! #if defined(FEAT_EVAL)
102 && firstc != '@'
103 #endif
104 #ifdef FEAT_EVAL
105 ***************
106 *** 1725,1731 ****
107 return ccline.cmdbuff;
108 }
109
110 ! #if (defined(FEAT_CRYPT) || defined(FEAT_EVAL)) || defined(PROTO)
111 /*
112 * Get a command line with a prompt.
113 * This is prepared to be called recursively from getcmdline() (e.g. by
114 --- 1725,1731 ----
115 return ccline.cmdbuff;
116 }
117
118 ! #if defined(FEAT_EVAL) || defined(PROTO)
119 /*
120 * Get a command line with a prompt.
121 * This is prepared to be called recursively from getcmdline() (e.g. by
122 ***************
123 *** 1759,1765 ****
124 cmdline_charsize(idx)
125 int idx;
126 {
127 ! #if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
128 if (cmdline_star > 0) /* showing '*', always 1 position */
129 return 1;
130 #endif
131 --- 1759,1765 ----
132 cmdline_charsize(idx)
133 int idx;
134 {
135 ! #if defined(FEAT_EVAL)
136 if (cmdline_star > 0) /* showing '*', always 1 position */
137 return 1;
138 #endif
139 ***************
140 *** 2231,2237 ****
141 int start;
142 int len;
143 {
144 ! #if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
145 int i;
146
147 if (cmdline_star > 0)
148 --- 2231,2237 ----
149 int start;
150 int len;
151 {
152 ! #if defined(FEAT_EVAL)
153 int i;
154
155 if (cmdline_star > 0)
156 ***************
157 *** 4668,4674 ****
158
159 #endif /* FEAT_EVAL */
160
161 ! #if defined(FEAT_CRYPT) || defined(PROTO)
162 /*
163 * Very specific function to remove the value in ":set key=val" from the
164 * history.
165 --- 4668,4674 ----
166
167 #endif /* FEAT_EVAL */
168
169 ! #if defined(PROTO)
170 /*
171 * Very specific function to remove the value in ":set key=val" from the
172 * history.
173 ***************
174 *** 5126,5132 ****
175
176 /* Can't do this recursively. Can't do it when typing a password. */
177 if (cmdwin_type != 0
178 ! # if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
179 || cmdline_star > 0
180 # endif
181 )
182 --- 5126,5132 ----
183
184 /* Can't do this recursively. Can't do it when typing a password. */
185 if (cmdwin_type != 0
186 ! # if defined(FEAT_EVAL)
187 || cmdline_star > 0
188 # endif
189 )
190 *** vim63/src/feature.h 2004-03-11 09:30:21.000000000 +0000
191 --- vim63/src/feature.h.new 2004-07-25 23:10:19.604954000 +0100
192 ***************
193 *** 542,554 ****
194 #endif
195
196 /*
197 - * +cryptv Encryption (by Mohsin Ahmed <mosh@sasi.com>).
198 - */
199 - #if defined(FEAT_NORMAL) || defined(PROTO)
200 - # define FEAT_CRYPT
201 - #endif
202 -
203 - /*
204 * +mksession ":mksession" command.
205 * Requires +windows and +vertsplit.
206 */
207 --- 542,547 ----
208 *** vim63/src/fileio.c 2004-06-01 14:02:00.000000000 +0100
209 --- vim63/src/fileio.c.new 2004-07-25 23:15:39.736922000 +0100
210 ***************
211 *** 36,46 ****
212 #define BUFSIZE 8192 /* size of normal write buffer */
213 #define SMBUFSIZE 256 /* size of emergency write buffer */
214
215 - #ifdef FEAT_CRYPT
216 - # define CRYPT_MAGIC "VimCrypt~01!" /* "01" is the version nr */
217 - # define CRYPT_MAGIC_LEN 12 /* must be multiple of 4! */
218 - #endif
219 -
220 /* Is there any system that doesn't have access()? */
221 #ifndef MACOS_CLASSIC /* Not available on MacOS 9 */
222 # define USE_MCH_ACCESS
223 --- 36,41 ----
224 ***************
225 *** 55,63 ****
226 #ifdef FEAT_VIMINFO
227 static void check_marks_read __ARGS((void));
228 #endif
229 - #ifdef FEAT_CRYPT
230 - static char_u *check_for_cryptkey __ARGS((char_u *cryptkey, char_u *ptr, long *sizep, long *filesizep, int newfile));
231 - #endif
232 #ifdef UNIX
233 static void set_file_time __ARGS((char_u *fname, time_t atime, time_t mtime));
234 #endif
235 --- 50,55 ----
236 ***************
237 *** 71,77 ****
238 static int apply_autocmds_exarg __ARGS((EVENT_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf, exarg_T *eap));
239 #endif
240
241 ! #if defined(FEAT_CRYPT) || defined(FEAT_MBYTE)
242 # define HAS_BW_FLAGS
243 # define FIO_LATIN1 0x01 /* convert Latin1 */
244 # define FIO_UTF8 0x02 /* convert UTF-8 */
245 --- 63,69 ----
246 static int apply_autocmds_exarg __ARGS((EVENT_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf, exarg_T *eap));
247 #endif
248
249 ! #if defined(FEAT_MBYTE)
250 # define HAS_BW_FLAGS
251 # define FIO_LATIN1 0x01 /* convert Latin1 */
252 # define FIO_UTF8 0x02 /* convert UTF-8 */
253 ***************
254 *** 235,243 ****
255 char_u *p;
256 long filesize = 0;
257 int skip_read = FALSE;
258 - #ifdef FEAT_CRYPT
259 - char_u *cryptkey = NULL;
260 - #endif
261 int split = 0; /* number of split lines */
262 #define UNKNOWN 0x0fffffff /* file size is unknown */
263 linenr_T linecnt;
264 --- 227,232 ----
265 ***************
266 *** 1224,1244 ****
267 conv_error = TRUE;
268 #endif
269 }
270 -
271 - #ifdef FEAT_CRYPT
272 - /*
273 - * At start of file: Check for magic number of encryption.
274 - */
275 - if (filesize == 0)
276 - cryptkey = check_for_cryptkey(cryptkey, ptr, &size,
277 - &filesize, newfile);
278 - /*
279 - * Decrypt the read bytes.
280 - */
281 - if (cryptkey != NULL && size > 0)
282 - for (p = ptr; p < ptr + size; ++p)
283 - ZDECODE(*p);
284 - #endif
285 }
286 skip_read = FALSE;
287
288 --- 1213,1218 ----
289 ***************
290 *** 1249,1259 ****
291 * converting with 'charconvert' or when a BOM has already been
292 * found.
293 */
294 ! if ((filesize == 0
295 ! # ifdef FEAT_CRYPT
296 ! || (filesize == CRYPT_MAGIC_LEN && cryptkey != NULL)
297 ! # endif
298 ! )
299 && (fio_flags == FIO_UCSBOM
300 || (!curbuf->b_p_bomb
301 && tmpname == NULL
302 --- 1223,1229 ----
303 * converting with 'charconvert' or when a BOM has already been
304 * found.
305 */
306 ! if ((filesize == 0)
307 && (fio_flags == FIO_UCSBOM
308 || (!curbuf->b_p_bomb
309 && tmpname == NULL
310 ***************
311 *** 1987,1996 ****
312 if (newfile)
313 save_file_ff(curbuf); /* remember the current file format */
314
315 - #ifdef FEAT_CRYPT
316 - if (cryptkey != curbuf->b_p_key)
317 - vim_free(cryptkey);
318 - #endif
319
320 #ifdef FEAT_MBYTE
321 /* If editing a new file: set 'fenc' for the current buffer. */
322 --- 1957,1962 ----
323 ***************
324 *** 2156,2168 ****
325 c = TRUE;
326 }
327 #endif
328 - #ifdef FEAT_CRYPT
329 - if (cryptkey != NULL)
330 - {
331 - STRCAT(IObuff, _("[crypted]"));
332 - c = TRUE;
333 - }
334 - #endif
335 #ifdef FEAT_MBYTE
336 if (conv_error)
337 {
338 --- 2122,2127 ----
339 ***************
340 *** 2184,2194 ****
341 }
342 if (msg_add_fileformat(fileformat))
343 c = TRUE;
344 - #ifdef FEAT_CRYPT
345 - if (cryptkey != NULL)
346 - msg_add_lines(c, (long)linecnt, filesize - CRYPT_MAGIC_LEN);
347 - else
348 - #endif
349 msg_add_lines(c, (long)linecnt, filesize);
350
351 vim_free(keep_msg);
352 --- 2143,2148 ----
353 ***************
354 *** 2449,2510 ****
355 }
356 #endif
357
358 - #ifdef FEAT_CRYPT
359 - /*
360 - * Check for magic number used for encryption.
361 - * If found, the magic number is removed from ptr[*sizep] and *sizep and
362 - * *filesizep are updated.
363 - * Return the (new) encryption key, NULL for no encryption.
364 - */
365 - static char_u *
366 - check_for_cryptkey(cryptkey, ptr, sizep, filesizep, newfile)
367 - char_u *cryptkey; /* previous encryption key or NULL */
368 - char_u *ptr; /* pointer to read bytes */
369 - long *sizep; /* length of read bytes */
370 - long *filesizep; /* nr of bytes used from file */
371 - int newfile; /* editing a new buffer */
372 - {
373 - if (*sizep >= CRYPT_MAGIC_LEN
374 - && STRNCMP(ptr, CRYPT_MAGIC, CRYPT_MAGIC_LEN) == 0)
375 - {
376 - if (cryptkey == NULL)
377 - {
378 - if (*curbuf->b_p_key)
379 - cryptkey = curbuf->b_p_key;
380 - else
381 - {
382 - /* When newfile is TRUE, store the typed key
383 - * in the 'key' option and don't free it. */
384 - cryptkey = get_crypt_key(newfile, FALSE);
385 - /* check if empty key entered */
386 - if (cryptkey != NULL && *cryptkey == NUL)
387 - {
388 - if (cryptkey != curbuf->b_p_key)
389 - vim_free(cryptkey);
390 - cryptkey = NULL;
391 - }
392 - }
393 - }
394 -
395 - if (cryptkey != NULL)
396 - {
397 - crypt_init_keys(cryptkey);
398 -
399 - /* Remove magic number from the text */
400 - *filesizep += CRYPT_MAGIC_LEN;
401 - *sizep -= CRYPT_MAGIC_LEN;
402 - mch_memmove(ptr, ptr + CRYPT_MAGIC_LEN, (size_t)*sizep);
403 - }
404 - }
405 - /* When starting to edit a new file which does not have
406 - * encryption, clear the 'key' option, except when
407 - * starting up (called with -x argument) */
408 - else if (newfile && *curbuf->b_p_key && !starting)
409 - set_option_value((char_u *)"key", 0L, (char_u *)"", OPT_LOCAL);
410 -
411 - return cryptkey;
412 - }
413 - #endif
414
415 #ifdef UNIX
416 static void
417 --- 2403,2408 ----
418 ***************
419 *** 3797,3818 ****
420
421 write_info.bw_fd = fd;
422
423 - #ifdef FEAT_CRYPT
424 - if (*buf->b_p_key && !filtering)
425 - {
426 - crypt_init_keys(buf->b_p_key);
427 - /* Write magic number, so that Vim knows that this file is encrypted
428 - * when reading it again. This also undergoes utf-8 to ucs-2/4
429 - * conversion when needed. */
430 - write_info.bw_buf = (char_u *)CRYPT_MAGIC;
431 - write_info.bw_len = CRYPT_MAGIC_LEN;
432 - write_info.bw_flags = FIO_NOCONVERT;
433 - if (buf_write_bytes(&write_info) == FAIL)
434 - end = 0;
435 - wb_flags |= FIO_ENCRYPTED;
436 - }
437 - #endif
438 -
439 write_info.bw_buf = buffer;
440 nchars = 0;
441
442 --- 3695,3700 ----
443 ***************
444 *** 4151,4163 ****
445 /* may add [unix/dos/mac] */
446 if (msg_add_fileformat(fileformat))
447 c = TRUE;
448 - #ifdef FEAT_CRYPT
449 - if (wb_flags & FIO_ENCRYPTED)
450 - {
451 - STRCAT(IObuff, _("[crypted]"));
452 - c = TRUE;
453 - }
454 - #endif
455 msg_add_lines(c, (long)lnum, nchars); /* add line/char count */
456 if (!shortmess(SHM_WRITE))
457 {
458 --- 4033,4038 ----
459 ***************
460 *** 4896,4913 ****
461 }
462 #endif /* FEAT_MBYTE */
463
464 - #ifdef FEAT_CRYPT
465 - if (flags & FIO_ENCRYPTED) /* encrypt the data */
466 - {
467 - int ztemp, t, i;
468 -
469 - for (i = 0; i < len; i++)
470 - {
471 - ztemp = buf[i];
472 - buf[i] = ZENCODE(ztemp, t);
473 - }
474 - }
475 - #endif
476
477 /* Repeat the write(), it may be interrupted by a signal. */
478 while (len)
479 --- 4771,4776 ----
480 *** vim63/src/getchar.c 2004-05-16 12:25:18.000000000 +0100
481 --- vim63/src/getchar.c.new 2004-07-25 23:16:14.080393000 +0100
482 ***************
483 *** 2485,2491 ****
484
485 /* this looks nice when typing a dead character map */
486 if ((State & CMDLINE)
487 ! #if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
488 && cmdline_star == 0
489 #endif
490 && ptr2cells(typebuf.tb_buf + typebuf.tb_off
491 --- 2485,2491 ----
492
493 /* this looks nice when typing a dead character map */
494 if ((State & CMDLINE)
495 ! #if defined(FEAT_EVAL)
496 && cmdline_star == 0
497 #endif
498 && ptr2cells(typebuf.tb_buf + typebuf.tb_off
499 *** vim63/src/globals.h 2004-05-29 12:36:36.000000000 +0100
500 --- vim63/src/globals.h.new 2004-07-25 23:17:04.646527000 +0100
501 ***************
502 *** 80,86 ****
503
504 EXTERN int redraw_cmdline INIT(= FALSE); /* cmdline must be redrawn */
505 EXTERN int clear_cmdline INIT(= FALSE); /* cmdline must be cleared */
506 ! #if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
507 EXTERN int cmdline_star INIT(= FALSE); /* cmdline is crypted */
508 #endif
509 EXTERN int exec_from_reg INIT(= FALSE); /* executing register */
510 --- 80,86 ----
511
512 EXTERN int redraw_cmdline INIT(= FALSE); /* cmdline must be redrawn */
513 EXTERN int clear_cmdline INIT(= FALSE); /* cmdline must be cleared */
514 ! #if defined(FEAT_EVAL)
515 EXTERN int cmdline_star INIT(= FALSE); /* cmdline is crypted */
516 #endif
517 EXTERN int exec_from_reg INIT(= FALSE); /* executing register */
518 *** vim63/src/macros.h 2004-04-19 19:10:12.000000000 +0100
519 --- vim63/src/macros.h.new 2004-07-25 23:17:48.153489000 +0100
520 ***************
521 *** 202,226 ****
522 # endif
523 #endif
524
525 - /*
526 - * Encryption macros. Mohsin Ahmed, mosh@sasi.com 98-09-24
527 - * Based on zip/crypt sources.
528 - */
529 -
530 - #ifdef FEAT_CRYPT
531 -
532 - #ifndef __MINGW32__
533 - # define PWLEN 80
534 - #endif
535 -
536 - /* encode byte c, using temp t. Warning: c must not have side effects. */
537 - # define ZENCODE(c, t) (t = decrypt_byte(), update_keys(c), t^(c))
538 -
539 - /* decode byte c in place */
540 - # define ZDECODE(c) update_keys(c ^= decrypt_byte())
541 -
542 - #endif
543 -
544 #ifdef STARTUPTIME
545 # define TIME_MSG(s) time_msg(s, NULL)
546 #else
547 --- 202,207 ----
548 *** vim63/src/main.c 2004-05-30 19:02:39.000000000 +0100
549 --- vim63/src/main.c.new 2004-07-25 23:18:52.334107000 +0100
550 ***************
551 *** 99,107 ****
552 #ifdef FEAT_QUICKFIX
553 char_u *use_ef = NULL; /* 'errorfile' from -q option */
554 #endif
555 - #ifdef FEAT_CRYPT
556 - int ask_for_key = FALSE; /* -x argument */
557 - #endif
558 int n_commands = 0; /* no. of commands from + or -c */
559 char_u *commands[MAX_ARG_CMDS]; /* commands from + or -c option */
560 #ifdef FEAT_PRECOMMANDS
561 --- 99,104 ----
562 ***************
563 *** 820,831 ****
564 want_argument = TRUE;
565 break;
566
567 - #ifdef FEAT_CRYPT
568 - case 'x': /* "-x" encrypted reading/writing of files */
569 - ask_for_key = TRUE;
570 - break;
571 - #endif
572 -
573 case 'X': /* "-X" don't connect to X server */
574 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_X11)
575 x_no_connect = TRUE;
576 --- 817,822 ----
577 ***************
578 *** 1712,1725 ****
579 TIME_MSG("clearing screen");
580 }
581
582 - #ifdef FEAT_CRYPT
583 - if (ask_for_key)
584 - {
585 - (void)get_crypt_key(TRUE, TRUE);
586 - TIME_MSG("getting crypt key");
587 - }
588 - #endif
589 -
590 no_wait_return = TRUE;
591
592 #ifdef FEAT_WINDOWS
593 --- 1703,1708 ----
594 ***************
595 *** 2540,2548 ****
596 main_msg(_("-s <scriptin>\tRead Normal mode commands from file <scriptin>"));
597 main_msg(_("-w <scriptout>\tAppend all typed commands to file <scriptout>"));
598 main_msg(_("-W <scriptout>\tWrite all typed commands to file <scriptout>"));
599 - #ifdef FEAT_CRYPT
600 - main_msg(_("-x\t\t\tEdit encrypted files"));
601 - #endif
602 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_X11)
603 # if defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK)
604 main_msg(_("-display <display>\tConnect vim to this particular X-server"));
605 --- 2523,2528 ----
606 *** vim63/src/misc2.c 2004-05-05 10:43:49.000000000 +0100
607 --- vim63/src/misc2.c.new 2004-07-25 23:20:51.172351000 +0100
608 ***************
609 *** 3124,3280 ****
610 #endif /* CURSOR_SHAPE */
611
612
613 - #ifdef FEAT_CRYPT
614 - /*
615 - * Optional encryption suypport.
616 - * Mohsin Ahmed, mosh@sasi.com, 98-09-24
617 - * Based on zip/crypt sources.
618 - *
619 - * NOTE FOR USA: Since 2000 exporting this code from the USA is allowed to
620 - * most countries. There are a few exceptions, but that still should not be a
621 - * problem since this code was originally created in Europe and India.
622 - */
623 -
624 - /* from zip.h */
625 -
626 - typedef unsigned short ush; /* unsigned 16-bit value */
627 - typedef unsigned long ulg; /* unsigned 32-bit value */
628 -
629 - static void make_crc_tab __ARGS((void));
630 -
631 - ulg crc_32_tab[256];
632 -
633 - /*
634 - * Fill the CRC table.
635 - */
636 - static void
637 - make_crc_tab()
638 - {
639 - ulg s,t,v;
640 - static int done = FALSE;
641 -
642 - if (done)
643 - return;
644 - for (t = 0; t < 256; t++)
645 - {
646 - v = t;
647 - for (s = 0; s < 8; s++)
648 - v = (v >> 1) ^ ((v & 1) * (ulg)0xedb88320L);
649 - crc_32_tab[t] = v;
650 - }
651 - done = TRUE;
652 - }
653 -
654 - #define CRC32(c, b) (crc_32_tab[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8))
655 -
656 -
657 - static ulg keys[3]; /* keys defining the pseudo-random sequence */
658 -
659 - /*
660 - * Return the next byte in the pseudo-random sequence
661 - */
662 - int
663 - decrypt_byte()
664 - {
665 - ush temp;
666 -
667 - temp = (ush)keys[2] | 2;
668 - return (int)(((unsigned)(temp * (temp ^ 1)) >> 8) & 0xff);
669 - }
670 -
671 - /*
672 - * Update the encryption keys with the next byte of plain text
673 - */
674 - int
675 - update_keys(c)
676 - int c; /* byte of plain text */
677 - {
678 - keys[0] = CRC32(keys[0], c);
679 - keys[1] += keys[0] & 0xff;
680 - keys[1] = keys[1] * 134775813L + 1;
681 - keys[2] = CRC32(keys[2], (int)(keys[1] >> 24));
682 - return c;
683 - }
684 -
685 - /*
686 - * Initialize the encryption keys and the random header according to
687 - * the given password.
688 - * If "passwd" is NULL or empty, don't do anything.
689 - */
690 - void
691 - crypt_init_keys(passwd)
692 - char_u *passwd; /* password string with which to modify keys */
693 - {
694 - if (passwd != NULL && *passwd != NUL)
695 - {
696 - make_crc_tab();
697 - keys[0] = 305419896L;
698 - keys[1] = 591751049L;
699 - keys[2] = 878082192L;
700 - while (*passwd != '\0')
701 - update_keys((int)*passwd++);
702 - }
703 - }
704 -
705 - /*
706 - * Ask the user for a crypt key.
707 - * When "store" is TRUE, the new key in stored in the 'key' option, and the
708 - * 'key' option value is returned: Don't free it.
709 - * When "store" is FALSE, the typed key is returned in allocated memory.
710 - * Returns NULL on failure.
711 - */
712 - char_u *
713 - get_crypt_key(store, twice)
714 - int store;
715 - int twice; /* Ask for the key twice. */
716 - {
717 - char_u *p1, *p2 = NULL;
718 - int round;
719 -
720 - for (round = 0; ; ++round)
721 - {
722 - cmdline_star = TRUE;
723 - cmdline_row = msg_row;
724 - p1 = getcmdline_prompt(NUL, round == 0
725 - ? (char_u *)_("Enter encryption key: ")
726 - : (char_u *)_("Enter same key again: "), 0);
727 - cmdline_star = FALSE;
728 -
729 - if (p1 == NULL)
730 - break;
731 -
732 - if (round == twice)
733 - {
734 - if (p2 != NULL && STRCMP(p1, p2) != 0)
735 - {
736 - MSG(_("Keys don't match!"));
737 - vim_free(p1);
738 - vim_free(p2);
739 - p2 = NULL;
740 - round = -1; /* do it again */
741 - continue;
742 - }
743 - if (store)
744 - {
745 - set_option_value((char_u *)"key", 0L, p1, OPT_LOCAL);
746 - vim_free(p1);
747 - p1 = curbuf->b_p_key;
748 - }
749 - break;
750 - }
751 - p2 = p1;
752 - }
753 -
754 - /* since the user typed this, no need to wait for return */
755 - need_wait_return = FALSE;
756 - msg_didout = FALSE;
757 -
758 - vim_free(p2);
759 - return p1;
760 - }
761 -
762 - #endif /* FEAT_CRYPT */
763 -
764 /* TODO: make some #ifdef for this */
765 /*--------[ file searching ]-------------------------------------------------*/
766 /*
767 --- 3124,3129 ----
768 *** vim63/src/option.c 2004-05-15 11:20:06.000000000 +0100
769 --- vim63/src/option.c.new 2004-07-25 23:22:25.460439000 +0100
770 ***************
771 *** 190,198 ****
772 #endif
773 static int p_inf;
774 static char_u *p_isk;
775 - #ifdef FEAT_CRYPT
776 - static char_u *p_key;
777 - #endif
778 #ifdef FEAT_LISP
779 static int p_lisp;
780 #endif
781 --- 190,195 ----
782 ***************
783 *** 1276,1288 ****
784 (char_u *)&p_js, PV_NONE,
785 {(char_u *)TRUE, (char_u *)0L}},
786 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
787 - #ifdef FEAT_CRYPT
788 - (char_u *)&p_key, PV_KEY,
789 - {(char_u *)"", (char_u *)0L}
790 - #else
791 (char_u *)NULL, PV_NONE,
792 {(char_u *)0L, (char_u *)0L}
793 - #endif
794 },
795 {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT,
796 #ifdef FEAT_KEYMAP
797 --- 1273,1280 ----
798 ***************
799 *** 4361,4369 ****
800 check_string_option(&buf->b_p_inde);
801 check_string_option(&buf->b_p_indk);
802 #endif
803 - #ifdef FEAT_CRYPT
804 - check_string_option(&buf->b_p_key);
805 - #endif
806 check_string_option(&buf->b_p_kp);
807 check_string_option(&buf->b_p_mps);
808 check_string_option(&buf->b_p_fo);
809 --- 4353,4358 ----
810 ***************
811 *** 4970,4985 ****
812 }
813 }
814
815 - #if defined(FEAT_CRYPT) && defined(FEAT_CMDHIST)
816 - /* 'cryptkey' */
817 - else if (gvarp == &p_key)
818 - {
819 - /* Make sure the ":set" command doesn't show the new value in the
820 - * history. */
821 - remove_key_from_history();
822 - }
823 - #endif
824 -
825 /* 'matchpairs' */
826 else if (gvarp == &p_mps)
827 {
828 --- 4959,4964 ----
829 ***************
830 *** 7055,7066 ****
831 return -2;
832 if (stringval != NULL)
833 {
834 - #ifdef FEAT_CRYPT
835 - /* never return the value of the crypt key */
836 - if ((char_u **)varp == &curbuf->b_p_key)
837 - *stringval = vim_strsave((char_u *)"*****");
838 - else
839 - #endif
840 *stringval = vim_strsave(*(char_u **)(varp));
841 }
842 return 0;
843 --- 7034,7039 ----
844 ***************
845 *** 7894,7902 ****
846 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
847 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
848 #endif
849 - #ifdef FEAT_CRYPT
850 - case PV_KEY: return (char_u *)&(curbuf->b_p_key);
851 - #endif
852 #ifdef FEAT_LISP
853 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
854 #endif
855 --- 7867,7872 ----
856 ***************
857 *** 8218,8226 ****
858 buf->b_p_inde = vim_strsave(p_inde);
859 buf->b_p_indk = vim_strsave(p_indk);
860 #endif
861 - #ifdef FEAT_CRYPT
862 - buf->b_p_key = vim_strsave(p_key);
863 - #endif
864 #ifdef FEAT_SEARCHPATH
865 buf->b_p_sua = vim_strsave(p_sua);
866 #endif
867 --- 8188,8193 ----
868 ***************
869 *** 8783,8793 ****
870 varp = *(char_u **)(varp);
871 if (varp == NULL) /* just in case */
872 NameBuff[0] = NUL;
873 - #ifdef FEAT_CRYPT
874 - /* don't show the actual value of 'key', only that it's set */
875 - if (opp->var == (char_u *)&p_key && *varp)
876 - STRCPY(NameBuff, "*****");
877 - #endif
878 else if (opp->flags & P_EXPAND)
879 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
880 /* Translate 'pastetoggle' into special key names */
881 --- 8750,8755 ----
882 *** vim63/src/structs.h 2004-06-02 11:09:24.000000000 +0100
883 --- vim63/src/structs.h.new 2004-07-25 23:22:57.212660000 +0100
884 ***************
885 *** 1113,1121 ****
886 char_u *b_p_inde; /* 'indentexpr' */
887 char_u *b_p_indk; /* 'indentkeys' */
888 #endif
889 - #ifdef FEAT_CRYPT
890 - char_u *b_p_key; /* 'key' */
891 - #endif
892 char_u *b_p_kp; /* 'keywordprg' */
893 #ifdef FEAT_LISP
894 int b_p_lisp; /* 'lisp' */
895 --- 1113,1118 ----
896 *** vim63/src/version.c 2004-06-07 10:07:34.000000000 +0100
897 --- vim63/src/version.c.new 2004-07-25 23:23:28.027333000 +0100
898 ***************
899 *** 133,143 ****
900 #else
901 "-comments",
902 #endif
903 - #ifdef FEAT_CRYPT
904 - "+cryptv",
905 - #else
906 "-cryptv",
907 - #endif
908 #ifdef FEAT_CSCOPE
909 "+cscope",
910 #else
911 --- 133,139 ----