mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-23 09:36:31 -05:00
Cleanup encryption key setting by moving core to file.
This commit is contained in:
parent
a3b5257bfe
commit
fb395c3f01
39
crypt.c
39
crypt.c
@ -9,47 +9,12 @@
|
|||||||
* written by Dana Hoggatt and Daniel Lawrence
|
* written by Dana Hoggatt and Daniel Lawrence
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "display.h"
|
|
||||||
#include "estruct.h"
|
|
||||||
#include "edef.h"
|
|
||||||
#include "input.h"
|
|
||||||
|
|
||||||
#if CRYPT
|
#if CRYPT
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
static int mod95(int);
|
static int mod95(int);
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 vlaue of disinp */
|
|
||||||
char key[NPAT]; /* 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);
|
|
||||||
disinp = odisinp;
|
|
||||||
if (status != TRUE)
|
|
||||||
return status;
|
|
||||||
|
|
||||||
/* and encrypt it */
|
|
||||||
myencrypt((char *) NULL, 0);
|
|
||||||
myencrypt(key, strlen(key));
|
|
||||||
|
|
||||||
/* and save it off */
|
|
||||||
strcpy(curbp->b_key, key);
|
|
||||||
mlwrite(" "); /* clear it off the bottom line */
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********
|
/**********
|
||||||
*
|
*
|
||||||
|
5
crypt.h
5
crypt.h
@ -1,7 +1,10 @@
|
|||||||
#ifndef _CRYPT_H_
|
#ifndef _CRYPT_H_
|
||||||
#define _CRYPT_H_
|
#define _CRYPT_H_
|
||||||
|
|
||||||
int set_encryption_key( int f, int n) ;
|
#include "estruct.h"
|
||||||
|
|
||||||
|
#if CRYPT
|
||||||
void myencrypt( char *bptr, unsigned len) ;
|
void myencrypt( char *bptr, unsigned len) ;
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
1
ebind.c
1
ebind.c
@ -12,7 +12,6 @@
|
|||||||
#include "bind.h"
|
#include "bind.h"
|
||||||
#include "bindable.h"
|
#include "bindable.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "crypt.h"
|
|
||||||
#include "eval.h"
|
#include "eval.h"
|
||||||
#include "exec.h"
|
#include "exec.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
41
file.c
41
file.c
@ -119,6 +119,41 @@ int viewfile(int f, int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CRYPT
|
#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 vlaue of disinp */
|
||||||
|
char key[NPAT]; /* 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);
|
||||||
|
disinp = odisinp;
|
||||||
|
if (status != TRUE)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
/* save it off and encrypt it*/
|
||||||
|
strcpy(curbp->b_key, key);
|
||||||
|
cryptbufferkey( curbp) ;
|
||||||
|
|
||||||
|
mlwrite(" "); /* clear it off the bottom line */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static int resetkey(void)
|
static int resetkey(void)
|
||||||
{ /* reset the encryption key if needed */
|
{ /* reset the encryption key if needed */
|
||||||
int s; /* return status */
|
int s; /* return status */
|
||||||
@ -139,12 +174,10 @@ static int resetkey(void)
|
|||||||
|
|
||||||
/* and set up the key to be used! */
|
/* and set up the key to be used! */
|
||||||
/* de-encrypt it */
|
/* de-encrypt it */
|
||||||
myencrypt((char *) NULL, 0);
|
cryptbufferkey( curbp) ;
|
||||||
myencrypt(curbp->b_key, strlen(curbp->b_key));
|
|
||||||
|
|
||||||
/* re-encrypt it...seeding it to start */
|
/* re-encrypt it...seeding it to start */
|
||||||
myencrypt((char *) NULL, 0);
|
cryptbufferkey( curbp) ;
|
||||||
myencrypt(curbp->b_key, strlen(curbp->b_key));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
5
file.h
5
file.h
@ -1,6 +1,11 @@
|
|||||||
#ifndef _FILE_H_
|
#ifndef _FILE_H_
|
||||||
#define _FILE_H_
|
#define _FILE_H_
|
||||||
|
|
||||||
|
#if CRYPT
|
||||||
|
void cryptbufferkey( struct buffer *bp) ;
|
||||||
|
int set_encryption_key( int f, int n) ;
|
||||||
|
#endif
|
||||||
|
|
||||||
int fileread( int f, int n) ;
|
int fileread( int f, int n) ;
|
||||||
int insfile( int f, int n) ;
|
int insfile( int f, int n) ;
|
||||||
int filefind( int f, int n) ;
|
int filefind( int f, int n) ;
|
||||||
|
6
main.c
6
main.c
@ -61,7 +61,6 @@
|
|||||||
#include "bind.h"
|
#include "bind.h"
|
||||||
#include "bindable.h"
|
#include "bindable.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "crypt.h"
|
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "edef.h" /* Global definitions. */
|
#include "edef.h" /* Global definitions. */
|
||||||
#include "estruct.h" /* Global structures and defines. */
|
#include "estruct.h" /* Global structures and defines. */
|
||||||
@ -269,9 +268,8 @@ int main(int argc, char **argv)
|
|||||||
#if CRYPT
|
#if CRYPT
|
||||||
if (cryptflag) {
|
if (cryptflag) {
|
||||||
bp->b_mode |= MDCRYPT;
|
bp->b_mode |= MDCRYPT;
|
||||||
myencrypt((char *) NULL, 0);
|
strncpy( bp->b_key, ekey, NPAT) ;
|
||||||
myencrypt(ekey, strlen(ekey));
|
cryptbufferkey( bp) ;
|
||||||
strncpy(bp->b_key, ekey, NPAT);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user