mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 15:26:23 -05:00
Introduce ekey_t encryption key type and remove need for NKEY length constant.
This commit is contained in:
parent
e2ae45e187
commit
fa6edaa282
12
buffer.h
12
buffer.h
@ -4,12 +4,14 @@
|
||||
#include "crypt.h"
|
||||
#include "line.h"
|
||||
|
||||
#define NPAT 128 /* # of bytes, pattern */
|
||||
|
||||
typedef char fname_t[ 80] ; /* file name */
|
||||
typedef char bname_t[ 16] ; /* buffer name */
|
||||
typedef char fname_t[ 80] ; /* 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
|
||||
@ -35,7 +37,7 @@ struct buffer {
|
||||
fname_t b_fname ; /* File name */
|
||||
bname_t b_bname ; /* Buffer name */
|
||||
#if CRYPT
|
||||
char b_key[NPAT]; /* current encrypted key */
|
||||
ekey_t b_key ; /* current encrypted key */
|
||||
#endif
|
||||
};
|
||||
|
||||
|
4
file.c
4
file.c
@ -153,14 +153,14 @@ int set_encryption_key(int f, int n)
|
||||
{
|
||||
int status; /* return status */
|
||||
int odisinp; /* original vlaue of disinp */
|
||||
char key[NPAT]; /* new encryption string */
|
||||
ekey_t key ; /* new encryption string */
|
||||
|
||||
/* turn command input echo off */
|
||||
odisinp = disinp;
|
||||
disinp = FALSE;
|
||||
|
||||
/* get the string to use as an encrytion string */
|
||||
status = mlreply("Encryption String: ", key, NPAT - 1);
|
||||
status = mlreply("Encryption String: ", key, sizeof key - 1);
|
||||
disinp = odisinp;
|
||||
if (status != TRUE)
|
||||
return status;
|
||||
|
6
main.c
6
main.c
@ -159,7 +159,7 @@ int main(int argc, char **argv)
|
||||
bname_t bname ; /* buffer name of file to read */
|
||||
#if CRYPT
|
||||
int cryptflag; /* encrypting on the way in? */
|
||||
char ekey[NPAT]; /* startup encryption key */
|
||||
ekey_t ekey ; /* startup encryption key */
|
||||
#endif
|
||||
int newc;
|
||||
|
||||
@ -234,7 +234,7 @@ int main(int argc, char **argv)
|
||||
case 'k': /* -k<key> for code key */
|
||||
case 'K':
|
||||
cryptflag = TRUE;
|
||||
strncpy( ekey, &argv[ carg][ 2], sizeof ekey - 1) ; /* max encryption pattern limited to NPAT - 1 */
|
||||
strncpy( ekey, &argv[ carg][ 2], sizeof ekey - 1) ;
|
||||
ekey[ sizeof ekey - 1] = 0 ;
|
||||
break;
|
||||
#endif
|
||||
@ -288,7 +288,7 @@ int main(int argc, char **argv)
|
||||
#if CRYPT
|
||||
if (cryptflag) {
|
||||
bp->b_mode |= MDCRYPT;
|
||||
strncpy( bp->b_key, ekey, NPAT) ;
|
||||
strncpy( bp->b_key, ekey, sizeof ekey) ;
|
||||
cryptbufferkey( bp) ;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user