1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-18 07:16:23 -05:00

Remove encryption as implementation is too weak.

This commit is contained in:
Renaud 2016-03-23 21:11:05 +08:00
parent 8c968322f6
commit 645a0d734b
12 changed files with 56 additions and 434 deletions

View File

@ -1,8 +1,8 @@
# Makefile for emacs, updated Fri, Feb 13, 2015 12:02:52 PM
SRC=basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c input.c isearch.c line.c lock.c main.c mingw32.c mlout.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c window.c word.c wrapper.c wscreen.c
OBJ=basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o input.o isearch.o line.o lock.o main.o mingw32.o mlout.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o window.o word.o wrapper.o wscreen.o
HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h mlout.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h wscreen.h
SRC=basic.c bind.c bindable.c buffer.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c input.c isearch.c line.c lock.c main.c mingw32.c mlout.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c window.c word.c wrapper.c wscreen.c
OBJ=basic.o bind.o bindable.o buffer.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o input.o isearch.o line.o lock.o main.o mingw32.o mlout.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o window.o word.o wrapper.o wscreen.o
HDR=basic.h bind.h bindable.h buffer.h defines.h display.h ebind.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h mlout.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h wscreen.h
# DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them
@ -129,74 +129,71 @@ depend: ${SRC}
# DO NOT DELETE THIS LINE -- make depend uses it
basic.o: basic.c basic.h buffer.h crypt.h line.h retcode.h utf8.h \
estruct.h input.h bind.h mlout.h random.h terminal.h defines.h window.h
bind.o: bind.c bind.h estruct.h bindable.h buffer.h crypt.h line.h \
retcode.h utf8.h display.h ebind.h exec.h file.h flook.h input.h names.h \
window.h defines.h
bindable.o: bindable.c bindable.h defines.h buffer.h crypt.h line.h \
retcode.h utf8.h display.h estruct.h file.h input.h bind.h lock.h \
mlout.h terminal.h
buffer.o: buffer.c buffer.h crypt.h line.h retcode.h utf8.h defines.h \
estruct.h file.h input.h bind.h mlout.h window.h
crypt.o: crypt.c crypt.h
display.o: display.c display.h estruct.h buffer.h crypt.h line.h \
retcode.h utf8.h input.h bind.h termio.h terminal.h defines.h version.h \
wrapper.h window.h
ebind.o: ebind.c ebind.h basic.h bind.h estruct.h bindable.h buffer.h \
crypt.h line.h retcode.h utf8.h eval.h exec.h file.h isearch.h random.h \
region.h search.h spawn.h window.h defines.h word.h
eval.o: eval.c eval.h basic.h bind.h buffer.h crypt.h line.h retcode.h \
utf8.h display.h estruct.h exec.h execute.h flook.h input.h random.h \
search.h terminal.h defines.h termio.h version.h window.h
exec.o: exec.c exec.h retcode.h buffer.h crypt.h line.h utf8.h bind.h \
display.h estruct.h eval.h file.h flook.h input.h random.h window.h \
basic.o: basic.c basic.h buffer.h line.h retcode.h utf8.h estruct.h \
input.h bind.h mlout.h random.h terminal.h defines.h window.h
bind.o: bind.c bind.h estruct.h bindable.h buffer.h line.h retcode.h \
utf8.h display.h ebind.h exec.h file.h flook.h input.h names.h window.h \
defines.h
bindable.o: bindable.c bindable.h defines.h buffer.h line.h retcode.h \
utf8.h display.h estruct.h file.h input.h bind.h lock.h mlout.h \
terminal.h
buffer.o: buffer.c buffer.h line.h retcode.h utf8.h defines.h estruct.h \
file.h input.h bind.h mlout.h window.h
display.o: display.c display.h estruct.h buffer.h line.h retcode.h utf8.h \
input.h bind.h termio.h terminal.h defines.h version.h wrapper.h \
window.h
ebind.o: ebind.c ebind.h basic.h bind.h estruct.h bindable.h buffer.h \
line.h retcode.h utf8.h eval.h exec.h file.h isearch.h random.h region.h \
search.h spawn.h window.h defines.h word.h
eval.o: eval.c eval.h basic.h bind.h buffer.h line.h retcode.h utf8.h \
display.h estruct.h exec.h execute.h flook.h input.h random.h search.h \
terminal.h defines.h termio.h version.h window.h
exec.o: exec.c exec.h retcode.h buffer.h line.h utf8.h bind.h display.h \
estruct.h eval.h file.h flook.h input.h random.h window.h defines.h
execute.o: execute.c execute.h estruct.h bind.h random.h retcode.h \
display.h file.h buffer.h crypt.h line.h utf8.h input.h mlout.h search.h \
display.h file.h buffer.h line.h utf8.h input.h mlout.h search.h \
terminal.h defines.h window.h
file.o: file.c file.h buffer.h crypt.h line.h retcode.h utf8.h defines.h \
file.o: file.c file.h buffer.h line.h retcode.h utf8.h defines.h \
display.h estruct.h execute.h fileio.h input.h bind.h lock.h mlout.h \
window.h
fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h utf8.h
flook.o: flook.c flook.h retcode.h defines.h fileio.h crypt.h
fileio.o: fileio.c fileio.h defines.h retcode.h utf8.h
flook.o: flook.c flook.h retcode.h defines.h fileio.h
input.o: input.c input.h bind.h estruct.h bindable.h display.h exec.h \
retcode.h names.h terminal.h defines.h utf8.h wrapper.h
isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h retcode.h \
utf8.h display.h estruct.h exec.h input.h bind.h search.h terminal.h \
defines.h window.h
line.o: line.c line.h retcode.h utf8.h buffer.h crypt.h estruct.h mlout.h \
isearch.o: isearch.c isearch.h basic.h buffer.h line.h retcode.h utf8.h \
display.h estruct.h exec.h input.h bind.h search.h terminal.h defines.h \
window.h
line.o: line.c line.h retcode.h utf8.h buffer.h estruct.h mlout.h \
window.h defines.h
lock.o: lock.c estruct.h lock.h
main.o: main.c estruct.h basic.h bind.h bindable.h buffer.h crypt.h \
line.h retcode.h utf8.h display.h eval.h execute.h file.h lock.h mlout.h \
main.o: main.c estruct.h basic.h bind.h bindable.h buffer.h line.h \
retcode.h utf8.h display.h eval.h execute.h file.h lock.h mlout.h \
random.h search.h terminal.h defines.h termio.h version.h window.h
mingw32.o: mingw32.c
mlout.o: mlout.c mlout.h
names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \
line.h retcode.h utf8.h display.h estruct.h eval.h exec.h file.h \
isearch.h region.h random.h search.h spawn.h window.h defines.h word.h
names.o: names.c names.h basic.h bind.h bindable.h buffer.h line.h \
retcode.h utf8.h display.h estruct.h eval.h exec.h file.h isearch.h \
region.h random.h search.h spawn.h window.h defines.h word.h
pklock.o: pklock.c estruct.h pklock.h
posix.o: posix.c
random.o: random.c random.h retcode.h basic.h buffer.h crypt.h line.h \
utf8.h display.h estruct.h execute.h input.h bind.h search.h terminal.h \
random.o: random.c random.h retcode.h basic.h buffer.h line.h utf8.h \
display.h estruct.h execute.h input.h bind.h search.h terminal.h \
defines.h window.h
region.o: region.c region.h line.h retcode.h utf8.h buffer.h crypt.h \
estruct.h mlout.h random.h window.h defines.h
region.o: region.c region.h line.h retcode.h utf8.h buffer.h estruct.h \
mlout.h random.h window.h defines.h
search.o: search.c search.h line.h retcode.h utf8.h basic.h buffer.h \
crypt.h display.h estruct.h input.h bind.h mlout.h terminal.h defines.h \
display.h estruct.h input.h bind.h mlout.h terminal.h defines.h window.h
spawn.o: spawn.c spawn.h defines.h buffer.h line.h retcode.h utf8.h \
display.h estruct.h exec.h file.h flook.h input.h bind.h terminal.h \
window.h
spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h retcode.h \
utf8.h display.h estruct.h exec.h file.h flook.h input.h bind.h \
terminal.h window.h
tcap.o: tcap.c terminal.h defines.h retcode.h display.h estruct.h \
termio.h
termio.o: termio.c termio.h estruct.h retcode.h utf8.h
utf8.o: utf8.c utf8.h
window.o: window.c window.h defines.h buffer.h crypt.h line.h retcode.h \
utf8.h basic.h display.h estruct.h execute.h terminal.h wrapper.h
word.o: word.c word.h basic.h buffer.h crypt.h line.h retcode.h utf8.h \
estruct.h mlout.h random.h region.h window.h defines.h
window.o: window.c window.h defines.h buffer.h line.h retcode.h utf8.h \
basic.h display.h estruct.h execute.h terminal.h wrapper.h
word.o: word.c word.h basic.h buffer.h line.h retcode.h utf8.h estruct.h \
mlout.h random.h region.h window.h defines.h
wrapper.o: wrapper.c wrapper.h
wscreen.o: wscreen.c wscreen.h

View File

@ -31,17 +31,12 @@ struct buffer *blistp ; /* Buffer for C-X C-B */
const char *modename[] = { /* name of modes */
"Wrap", "Cmode", "Exact", "View", "Over",
"Magic",
#if CRYPT
"Crypt",
#else
"",
#endif
"Asave", "Utf-8", "Dos"
} ;
int gmode = 0 ; /* global editor mode */
static const char modecode[] = "WCEVOMYAUD" ; /* letters to represent modes */
static const char modecode[] = "WCEVOMAUD" ; /* letters to represent modes */
static int makelist( int iflag) ;
@ -333,7 +328,7 @@ static int makelist( int iflag)
int i;
long nbytes; /* # of bytes in current buffer */
long nlines ; /* # of lines in current buffer */
char b[ 9 + 1] ;
char b[ 10 + 1] ;
char line[MAXLINE];
blistp->b_flag &= ~BFCHG; /* Don't complain! */
@ -358,7 +353,7 @@ static int makelist( int iflag)
*cp1++ = modecode[i];
else
*cp1++ = '.';
strcpy(cp1, " Global Modes");
strcpy(cp1, " Global Modes");
if (addline(line) == FALSE)
return FALSE;
@ -414,7 +409,7 @@ static int makelist( int iflag)
if( bp->b_mode & MDDOS)
nbytes += nlines ;
l_to_a( b, sizeof b, nbytes) ; /* 8 digits string buffer size. */
l_to_a( b, sizeof b, nbytes) ; /* 10 digits string buffer size. */
cp2 = &b[0];
while ((c = *cp2++) != 0)
*cp1++ = c;
@ -560,9 +555,6 @@ struct buffer *bfind( const char *bname, int cflag, int bflag)
bp->b_fname[ 0] = '\0' ;
strncpy( bp->b_bname, bname, sizeof( bname_t) - 1) ;
bp->b_bname[ sizeof( bname_t) - 1] = '\0' ;
#if CRYPT
bp->b_key[0] = 0;
#endif
lp->l_fp = lp;
lp->l_bp = lp;
}

View File

@ -1,17 +1,12 @@
#ifndef _BUFFER_H_
#define _BUFFER_H_
#include "crypt.h"
#include "line.h"
typedef char fname_t[ 256] ; /* file name type */
typedef char bname_t[ 16] ; /* buffer name type */
#define NBUFN sizeof( bname_t)
#if CRYPT
typedef char ekey_t[ 128] ; /* encryption key type */
#endif
/*
* Text is kept in buffers. A buffer header, described below, exists for every
* buffer in the system. The buffers are kept in a big list, so that commands
@ -36,9 +31,6 @@ struct buffer {
char b_flag; /* Flags */
fname_t b_fname ; /* File name */
bname_t b_bname ; /* Buffer name */
#if CRYPT
ekey_t b_key ; /* current encrypted key */
#endif
};
extern struct buffer *curbp ; /* Current buffer */
@ -50,7 +42,7 @@ extern struct buffer *blistp ; /* Buffer for C-X C-B */
#define BFTRUNC 0x04 /* buffer was truncated when read */
/* mode flags */
#define NUMMODES 10 /* # of defined modes */
#define NUMMODES 9 /* # of defined modes */
#define MDWRAP 0x0001 /* word wrap */
#define MDCMOD 0x0002 /* C indentation and fence match */
@ -58,12 +50,9 @@ extern struct buffer *blistp ; /* Buffer for C-X C-B */
#define MDVIEW 0x0008 /* read-only buffer */
#define MDOVER 0x0010 /* overwrite mode */
#define MDMAGIC 0x0020 /* regular expresions in search */
#if CRYPT
#define MDCRYPT 0x0040 /* encrytion mode active */
#endif
#define MDASAVE 0x0080 /* auto-save mode */
#define MDUTF8 0x0100 /* utf8 mode */
#define MDDOS 0x0200 /* CRLF eol mode */
#define MDASAVE 0x0040 /* auto-save mode */
#define MDUTF8 0x0080 /* utf8 mode */
#define MDDOS 0x0100 /* CRLF eol mode */
extern const char *modename[] ; /* text names of modes */

190
crypt.c
View File

@ -1,190 +0,0 @@
/* crypt.c -- implements crypt.h */
#include "crypt.h"
/* CRYPT.C
*
* Encryption routines
*
* written by Dana Hoggatt and Daniel Lawrence
*/
#if CRYPT
#include <stdio.h>
static int mod95(int);
/**********
*
* myencrypt - in place encryption/decryption of a buffer
*
* (C) Copyright 1986, Dana L. Hoggatt
* 1216, Beck Lane, Lafayette, IN
*
* When consulting directly with the author of this routine,
* please refer to this routine as the "DLH-POLY-86-B CIPHER".
*
* This routine was written for Dan Lawrence, for use in V3.8 of
* MicroEMACS, a public domain text/program editor.
*
* I kept the following goals in mind when preparing this function:
*
* 1. All printable characters were to be encrypted back
* into the printable range, control characters and
* high-bit characters were to remain unaffected. this
* way, encrypted would still be just as cheap to
* transmit down a 7-bit data path as they were before.
*
* 2. The encryption had to be portable. The encrypted
* file from one computer should be able to be decrypted
* on another computer.
*
* 3. The encryption had to be inexpensive, both in terms
* of speed and space.
*
* 4. The system needed to be secure against all but the
* most determined of attackers.
*
* For encryption of a block of data, one calls myencrypt passing
* a pointer to the data block and its length. The data block is
* encrypted in place, that is, the encrypted output overwrites
* the input. Decryption is totally isomorphic, and is performed
* in the same manner by the same routine.
*
* Before using this routine for encrypting data, you are expected
* to specify an encryption key. This key is an arbitrary string,
* to be supplied by the user. To set the key takes two calls to
* myencrypt(). First, you call
*
* myencrypt(NULL, vector)
*
* This resets all internal control information. Typically (and
* specifically in the case on MICRO-emacs) you would use a "vector"
* of 0. Other values can be used to customize your editor to be
* "incompatable" with the normally distributed version. For
* this purpose, the best results will be obtained by avoiding
* multiples of 95.
*
* Then, you "encrypt" your password by calling
*
* myencrypt(pass, strlen(pass))
*
* where "pass" is your password string. Myencrypt() will destroy
* the original copy of the password (it becomes encrypted),
* which is good. You do not want someone on a multiuser system
* to peruse your memory space and bump into your password.
* Still, it is a better idea to erase the password buffer to
* defeat memory perusal by a more technical snooper.
*
* For the interest of cryptologists, at the heart of this
* function is a Beaufort Cipher. The cipher alphabet is the
* range of printable characters (' ' to '~'), all "control"
* and "high-bit" characters are left unaltered.
*
* The key is a variant autokey, derived from a wieghted sum
* of all the previous clear text and cipher text. A counter
* is used as salt to obiterate any simple cyclic behavior
* from the clear text, and key feedback is used to assure
* that the entire message is based on the original key,
* preventing attacks on the last part of the message as if
* it were a pure autokey system.
*
* Overall security of encrypted data depends upon three
* factors: the fundamental cryptographic system must be
* difficult to compromise; exhaustive searching of the key
* space must be computationally expensive; keys and plaintext
* must remain out of sight. This system satisfies this set
* of conditions to within the degree desired for MicroEMACS.
*
* Though direct methods of attack (against systems such as
* this) do exist, they are not well known and will consume
* considerable amounts of computing time. An exhaustive
* search requires over a billion investigations, on average.
*
* The choice, entry, storage, manipulation, alteration,
* protection and security of the keys themselves are the
* responsiblity of the user.
*
*
* char *bptr; buffer of characters to be encrypted
* unsigned len; number of characters in the buffer
*
**********/
void myencrypt(char *bptr, unsigned len)
{
int cc; /* current character being considered */
static long key = 0; /* 29 bit encipherment key */
static int salt = 0; /* salt to spice up key with */
if (!bptr) { /* is there anything here to encrypt? */
key = len; /* set the new key */
salt = len; /* set the new salt */
return;
}
while (len--) { /* for every character in the buffer */
cc = *bptr; /* get a character out of the buffer */
/* only encipher printable characters */
if ((cc >= ' ') && (cc <= '~')) {
/** If the upper bit (bit 29) is set, feed it back into the key. This
assures us that the starting key affects the entire message. **/
key &= 0x1FFFFFFFL; /* strip off overflow */
if (key & 0x10000000L) {
key ^= 0x0040A001L; /* feedback */
}
/** Down-bias the character, perform a Beaufort encipherment, and
up-bias the character again. We want key to be positive
so that the left shift here will be more portable and the
mod95() faster **/
cc = mod95((int) (key % 95) - (cc - ' ')) + ' ';
/** the salt will spice up the key a little bit, helping to obscure
any patterns in the clear text, particularly when all the
characters (or long sequences of them) are the same. We do
not want the salt to go negative, or it will affect the key
too radically. It is always a good idea to chop off cyclics
to prime values. **/
if (++salt >= 20857) { /* prime modulus */
salt = 0;
}
/** our autokey (a special case of the running key) is being
generated by a wieghted checksum of clear text, cipher
text, and salt. **/
key = key + key + cc + *bptr + salt;
}
*bptr++ = cc; /* put character back into buffer */
}
return;
}
static int mod95(int val)
{
/* The mathematical MOD does not match the computer MOD */
/* Yes, what I do here may look strange, but it gets the
job done, and portably at that. */
while (val >= 9500)
val -= 9500;
while (val >= 950)
val -= 950;
while (val >= 95)
val -= 95;
while (val < 0)
val += 95;
return val;
}
#endif

10
crypt.h
View File

@ -1,10 +0,0 @@
#ifndef _CRYPT_H_
#define _CRYPT_H_
#define CRYPT 1 /* file encryption enabled? */
#if CRYPT
void myencrypt( char *bptr, unsigned len) ;
#endif
#endif

View File

@ -270,10 +270,6 @@ struct key_tab keytab[NBINDS] = {
,
{META | 'D', delfword}
,
#if CRYPT
{META | 'E', set_encryption_key}
,
#endif
{META | 'F', forwword}
,
{META | 'G', gotoline}

88
file.c
View File

@ -17,7 +17,6 @@
#include <unistd.h>
#include "buffer.h"
#include "crypt.h"
#include "defines.h"
#include "display.h"
#include "estruct.h"
@ -174,77 +173,6 @@ int viewfile( int f, int n) { /* visit a file in VIEW mode */
return status ;
}
#if CRYPT
void cryptbufferkey( struct buffer *bp) {
myencrypt( (char *) NULL, 0) ;
myencrypt( bp->b_key, strlen( bp->b_key)) ;
}
/*
* reset encryption key of current buffer
*
* int f; default flag
* int n; numeric argument
*/
int set_encryption_key( int f, int n) {
int status ; /* return status */
int odisinp ; /* original value of disinp */
char *key ; /* new encryption string */
/* turn command input echo off */
odisinp = disinp ;
disinp = FALSE ;
/* get the string to use as an encrytion string */
status = newmlarg( &key, "Encryption String: ", sizeof( ekey_t)) ;
disinp = odisinp ;
if( status != TRUE)
return status ;
/* save it off and encrypt it*/
strncpy( curbp->b_key, key, sizeof( ekey_t) - 1) ;
curbp->b_key[ sizeof( ekey_t) - 1] = '\0' ;
free( key) ;
cryptbufferkey( curbp) ;
if( !(curbp->b_mode & MDCRYPT)) {
curbp->b_mode |= MDCRYPT ;
upmode() ;
}
mloutstr( "") ; /* clear the message line */
return TRUE ;
}
static int resetkey(void)
{ /* reset the encryption key if needed */
int s; /* return status */
/* turn off the encryption flag */
is_crypted = FALSE;
/* if we are in crypt mode */
if (curbp->b_mode & MDCRYPT) {
if (curbp->b_key[0] == 0) {
s = set_encryption_key(FALSE, 0);
if (s != TRUE)
return s;
}
/* let others know... */
is_crypted = TRUE;
/* and set up the key to be used! */
/* de-encrypt it */
cryptbufferkey( curbp) ;
/* re-encrypt it...seeding it to start */
cryptbufferkey( curbp) ;
}
return TRUE;
}
#endif
/*
* getfile()
*
@ -348,11 +276,6 @@ int readin(const char *fname, boolean lockfl)
#else
return ABORT;
#endif
#endif
#if CRYPT
s = resetkey();
if (s != TRUE)
return s;
#endif
bp = curbp; /* Cheap. */
if ((s = bclear(bp)) != TRUE) /* Might be old. */
@ -618,12 +541,6 @@ int writeout( const char *fn)
struct line *lp;
int nline;
#if CRYPT
s = resetkey();
if (s != TRUE)
return s;
#endif
if ((s = ffwopen(fn)) != FIOSUC) { /* Open writes message. */
mloutstr( "Cannot open file for writing") ;
return FALSE;
@ -723,11 +640,6 @@ static int ifile( const char *fname) {
}
mloutstr( "(Inserting file)") ;
#if CRYPT
s = resetkey();
if (s != TRUE)
return s;
#endif
/* back up a line and save the mark here */
curwp->w_dotp = lback(curwp->w_dotp);
curwp->w_doto = 0;

6
file.h
View File

@ -2,14 +2,8 @@
#define _FILE_H_
#include "buffer.h"
#include "crypt.h"
#include "retcode.h"
#if CRYPT
void cryptbufferkey( struct buffer *bp) ;
int set_encryption_key( int f, int n) ;
#endif
extern boolean restflag ; /* restricted use? */
boolean resterr( void) ; /* restricted error message */

View File

@ -23,10 +23,6 @@
#include "retcode.h"
#include "utf8.h"
#if CRYPT
boolean is_crypted ; /* currently encrypting? */
#endif
char *fline = NULL ; /* dynamic return line */
static int flen = 0 ; /* current allocated length of fline */
int ftype ;
@ -103,20 +99,6 @@ fio_code ffclose(void)
* Check only at the newline.
*/
fio_code ffputline( char *buf, int nbuf, int dosflag) {
#if CRYPT
if( is_crypted) {
int i ;
for( i = 0 ; i < nbuf ; i++) {
char c ;
c = buf[ i] ;
myencrypt( &c, 1) ;
fputc( c, ffp) ;
}
} else
#endif
fwrite( buf, 1, nbuf, ffp) ;
if( dosflag)
@ -217,11 +199,7 @@ fio_code ffgetline(void)
} else /* c == '\n' */
ftype |= FTYPE_UNIX ;
/* terminate and decrypt the string */
/* terminate the string */
fline[i] = 0;
#if CRYPT
if( is_crypted)
myencrypt( fline, fpayload);
#endif
return FIOSUC;
}

View File

@ -1,8 +1,6 @@
#ifndef _FILEIO_H_
#define _FILEIO_H_
#include "crypt.h"
typedef enum {
FIOSUC, /* File I/O, success. */
FIOFNF, /* File I/O, file not found. */
@ -24,12 +22,6 @@ typedef enum {
#define FCODE_EXTND 0x82
#define FCODE_MIXED 0x83
#if CRYPT
#include "retcode.h"
extern boolean is_crypted ; /* currently encrypting? */
#endif
extern char *fline ; /* dynamic return line */
extern int ftype ;
extern int fcode ; /* encoding type */

25
main.c
View File

@ -125,9 +125,6 @@ static void usage( void) {
" -a|A process error file\n"
" -e|E edit file\n"
" -g|G<n> go to line <n>\n"
#if CRYPT
" -k|K<key> use code key\n"
#endif
" -r|R restrictive use\n"
" -s|S<string> search string\n"
" -v|V view file\n"
@ -150,10 +147,6 @@ int main(int argc, char **argv)
int searchflag; /* Do we need to search at start? */
int errflag; /* C error processing? */
bname_t bname ; /* buffer name of file to read */
#if CRYPT
int cryptflag; /* encrypting on the way in? */
ekey_t ekey ; /* startup encryption key */
#endif
#if PKCODE & VMS
(void) umask(-1); /* Use old protection (this is at wrong place). */
@ -192,9 +185,6 @@ int main(int argc, char **argv)
firstfile = TRUE; /* no file to edit yet */
startflag = FALSE; /* startup file not executed yet */
errflag = FALSE; /* not doing C error parsing */
#if CRYPT
cryptflag = FALSE; /* no encryption by default */
#endif
/* Insure screen is initialized before startup and goto/search */
update( FALSE) ;
@ -224,14 +214,6 @@ int main(int argc, char **argv)
gotoflag = TRUE;
gline = atoi(&argv[carg][2]);
break;
#if CRYPT
case 'k': /* -k<key> for code key */
case 'K':
cryptflag = TRUE;
strncpy( ekey, &argv[ carg][ 2], sizeof ekey - 1) ;
ekey[ sizeof ekey - 1] = 0 ;
break;
#endif
case 'r': /* -r restrictive use */
case 'R':
restflag = TRUE;
@ -297,13 +279,6 @@ int main(int argc, char **argv)
/* set the modes appropriatly */
if (viewflag)
bp->b_mode |= MDVIEW;
#if CRYPT
if (cryptflag) {
bp->b_mode |= MDCRYPT;
strncpy( bp->b_key, ekey, sizeof ekey) ;
cryptbufferkey( bp) ;
}
#endif
}
}

View File

@ -205,9 +205,6 @@ struct name_bind names[] = {
{"search-reverse", backsearch},
{"select-buffer", usebuffer},
{"set", setvar},
#if CRYPT
{"set-encryption-key", set_encryption_key},
#endif
{"set-fill-column", setfillcol},
{"set-mark", setmark},
{"shell-command", spawn},