1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-26 03:51:32 +00:00

Remove key checking code. (#251)

This wasn't actually hooked up any more, so it was pretty much
all dead code. The handling of this in the command line options
is gone.

In `bin/makefile-tail`, `DEVFILES` and `LIBFILES` became identical, so
`DEVFILES` went away.
This commit is contained in:
Bruce Mitchener
2021-01-20 14:47:55 +07:00
committed by GitHub
parent 397143d760
commit 85fa89ba88
19 changed files with 29 additions and 697 deletions

View File

@@ -1,191 +0,0 @@
/* $Id: keylib.c,v 1.4 2001/12/24 01:09:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
*/
/************************************************************************/
/* */
/* (C) Copyright 1989-1999 Venue. All Rights Reserved. */
/* Manufactured in the United States of America. */
/* */
/************************************************************************/
#include "version.h"
/* ==============================================================================
The functions defined in this file were called by KEYMAKER.C & KEYTESTER.C
Creation Date: May, 1988
============================================================================== */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "keylibdefs.h"
#define GOLDEN_RATIO_HACK -478700649
#define ULONG_MAX 4294967295
/* meaning of symbolic constant used:
FAILURE2 invalid date */
#define FAILURE2 -2
/* ===========================================================================
IMOD64BIT computes (IMOD X Y).
X is a 64-bit integer; x1 is the higher 32-bit while x0 is the lower 32-bit.
Y is less than 65535.
(((ULONG_MAX % y) + 1 ) % y) is equivalent to (expt 2 32) % y
=============================================================================*/
int imod64bit(unsigned long x1, unsigned long x0, unsigned long y) {
/* JDS 990601 ansi return (((x0 % y) + ((x1 % y) * (((ULONG_MAX % y) + 1 ) % y) )) % y); */
return (((x0 % y) + ((x1 % y) * ((y + 1) % y))) % y);
}
/* ===========================================================================
MAKE_VERIFICATION forms a new 32-bit integer by messaging the two input
long integers x and y. The number was created from the lower bits toward
higher bits.
=============================================================================*/
unsigned long make_verification(long unsigned int x, long unsigned int y) {
return (imod64bit(x, y, 4) | (imod64bit(x, y, 6) << 3) | (imod64bit(x, y, 13) << 6) |
(imod64bit(x, y, 25) << 10) | (imod64bit(x, y, 30) << 15) | (imod64bit(x, y, 63) << 20) |
(imod64bit(x, y, 5) << 26) | (imod64bit(x, y, 7) << 29));
}
/* ============================================================
DATE_INTEGER16 takes a date string and return an integer
=============================================================*/
unsigned long date_integer16(const char *date) {
unsigned long const1, const2;
const1 = 17152;
const2 = 86400;
return ((idate(date) - const1) / const2);
}
/* ===================================================================
IDATE takes a date string (dd-mmm-yy or dd mmm yy) and return an
integer.
dd - date in decimal digits
mmm - month name in alphabetic form or decimal digits
yy - year in decimal digits ; can be 2 or 4 digits
If date1 is before date2 then (idate date1) < (idate date2).
If date string is not valid, FAILURE2 is returned.
=====================================================================*/
unsigned long idate(const char *str) {
char ds[50];
char *decdigits = {"0123456789"};
char *tokendelimiters = {" -"};
char *yptr, *mptr, *dptr, *ptr1;
int day, month, year, maxday;
int i, len, s;
unsigned long days_since_day0, sec, hour;
static char *month_name[13] = {"", "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
static int days_each_month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
static int days_since_jan1st[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
/* copy input string to a local one */
ds[0] = '\0';
strcpy(ds, str);
/* get day, month, and year string tokens */
if ((dptr = strtok(ds, tokendelimiters)) == NULL) return FAILURE2;
if ((mptr = strtok(NULL, tokendelimiters)) == NULL) return FAILURE2;
if ((yptr = strtok(NULL, tokendelimiters)) == NULL) return FAILURE2;
/* validate year and convert it to numeric form 19xx */
if (strspn(yptr, decdigits) != strlen(yptr)) return FAILURE2;
if ((year = atoi(yptr)) <= 100) year += 1900;
if (year < 1970 || year > 2050) return FAILURE2;
/* validate month and convert it to numeric form if necessary */
if (strspn(mptr, decdigits) == (len = (strlen(mptr)))) {
/* input month is in numeric form */
if ((month = atoi(mptr)) < 1 || month > 12) return FAILURE2;
} else {
/* input month is in alphabetic form */
/* we're only interested in the first 3 chars */
if (len > 3) *(mptr + 3) = '\0';
ptr1 = mptr;
/* make sure month name is in upper case letters */
for (i = 0; (s = *(ptr1 + i)) != '\0'; ++i)
if (islower(s)) *(ptr1 + i) = toupper(s);
/* find out its corresponding numeric value */
for (i = 1; i <= 12; ++i)
if (strcmp(*(month_name + i), mptr) == 0) {
month = i;
break;
};
if (i == 13) return FAILURE2;
};
/* set up maxday to be the number of days of that month */
maxday = days_each_month[month];
/* watch out for leap year */
if (month == 2 && (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))) ++maxday;
/* validate day */
if (strspn(dptr, decdigits) != strlen(dptr) || (day = atoi(dptr)) < 1 || maxday < day)
return FAILURE2;
year -= 1901;
--month;
days_since_day0 = days_since_jan1st[month] + (day - 1) + (365 * year) + (year / 4);
if (month > 1 && year % 4 == 3 && year != -1) ++days_since_day0;
hour = (24 * days_since_day0) + 7;
/* JDS 990601 ANSI cleanup sec = (60 * (60 * hour)) ^ -2147483648L ; */
sec = (60 * (60 * hour)) ^ 0x80000000;
/* printf("\n days_since_day0: %ld hour: %ld sec: %ld\n", days_since_day0 , hour ,sec); */
return sec;
}
/* ============================================================
MODIFY turns on/off certain bits of the passed
in 32-bit hostid, depending on the value of (hostid % 16).
=============================================================*/
unsigned long modify(unsigned long hostid) {
unsigned long dividor;
#ifdef xBIGVM
hostid ^= 0xa3f5069e;
#endif /* xBIGVM */
dividor = 16;
switch (hostid % dividor) {
case 0: hostid = hostid | 0x48004802; break;
case 1: hostid = hostid ^ 0xfedc5793; break;
case 2: hostid = hostid ^ 0x9981afe3; break;
case 3: hostid = hostid & 0xffcb6ffd; break;
case 4: hostid = hostid ^ 0x3489dfa8; break;
case 5: hostid = hostid | 0x77012877; break;
case 6: hostid = hostid & 0xefc9fffd; break;
case 7: hostid = hostid | 0x22311300; break;
case 8: hostid = hostid & 0xdadf8871; break;
case 9: hostid = hostid ^ 0xe8c948ad; break;
case 10: hostid = hostid | 0x12488412; break;
case 11: hostid = hostid & 0xeffdea87; break;
case 12: hostid = hostid ^ 0xad8ce639; break;
case 13: hostid = hostid | 0x88221144; break;
case 14: hostid = hostid & 0xfffb6edd; break;
default: hostid = hostid ^ 0xfffddeee; break;
};
/* printf("\n ** new host id: result: %x ", hostid); */
return hostid;
}

View File

@@ -1,188 +0,0 @@
/* $Id: keymaker.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
*/
/************************************************************************/
/* */
/* (C) Copyright 1989-98 Venue. All Rights Reserved. */
/* Manufactured in the United States of America. */
/* */
/************************************************************************/
#include "version.h"
/* =====================================================================
This function is used to generate copyright protection keys for
Venue's Medley software. It prompts for a machine's host id and
the software's expiration date before generating a set of 3 keys.
The external functions called were stored in file 'keylib.o'.
Creation Date: May, 1988
===================================================================== */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "keylibdefs.h"
#define GOLDEN_RATIO_HACK -478700649
#define floadbyte(number, pos) ((number >> pos) & 0xFFFF)
#define hash_unhash(number, hashkey) \
(number ^ (GOLDEN_RATIO_HACK * (floadbyte(hashkey, 16) + floadbyte(hashkey, 0))))
/* meaning of symbolic constants used:
FAILURE1 invalid hostid
FAILURE2 invalid date entered from terminal
FAILURE3 can't open logfile in the command line */
#define FAILURE1 -1
#define FAILURE2 -2
#define FAILURE3 -3
void writeresults(FILE *fp, char *host, char *expdate,
unsigned long key1, unsigned long key2, unsigned long key3,
char *info);
/************************************************************************/
/* */
/* */
/* */
/* */
/* */
/************************************************************************/
int main(int argc, char **argv) {
int logfile = 0; /* set to 1 if logfile on command line */
FILE *fp; /* file pointer for the logfile */
unsigned long hostid;
unsigned long keys[3];
char s[50], expdate[30], saveexpdate[30];
char infostring[500];
char *sptr;
char *eptr;
int i, c;
int commandlineargs;
commandlineargs = (argc > 2);
/* If we have more than one argv we assume this is used as a filter */
/* == check if user enters logfile name in the command line == */
if ((argc > 1) & !commandlineargs) {
if ((fp = fopen(*++argv, "a")) == NULL) {
printf("\n Can't open %s \n", *argv);
exit(FAILURE3);
};
logfile = 1;
};
/* == prompt for machine's host id, verify, then do some modification == */
if (commandlineargs) {
/* assume that the second argument is hex-hostid */
sptr = *++argv;
hostid = strtoul(sptr, &eptr, 16);
} else {
printf("Enter Host ID (starts with 0x if the number is hexadecimal): ");
sptr = fgets(s, sizeof(s), stdin);
hostid = strtoul(s, &eptr, 0);
/* look for syntax error */
if (*eptr != '\n') {
printf("\nInvalid Host ID\n");
exit(FAILURE1);
} else {
/* trim off the trailing newline */
*eptr = '\0';
}
/* make sure Host ID is less than 32 bits */
/* XXX: why?, is 32-bits not OK -- compare to original code */
if ((hostid & 0x7FFFFFFF) != hostid) {
printf("\nInvalid Host ID\n");
exit(FAILURE1);
}
}
hostid = modify(hostid);
/* == prompt for the expiration date and validate it == */
if (!commandlineargs) {
/* assume that info is not needed when we use argc,argv */
printf("Enter information string (one line only, below)\n:");
fgets(infostring, sizeof(infostring), stdin);
infostring[strlen(infostring) - 1] = '\0';
}
/* == prompt for the expiration date and validate it == */
if (commandlineargs) {
strcpy(expdate, *++argv);
} else {
printf("Enter Software Expiration Date (dd-mmm-yy or never): ");
fgets(expdate, sizeof(expdate), stdin);
expdate[strlen(expdate) - 1] = '\0';
}
strcpy(saveexpdate, expdate);
/* check for 'never' entry */
if ((expdate[0] == 'N') || (expdate[0] == 'n')) {
for (i = 0; (c = expdate[i]) != '\0'; ++i)
if (islower(c)) expdate[i] = toupper(c);
if (strcmp(expdate, "NEVER") == 0)
strcpy(expdate, "29-DEC-77");
else {
printf("\nInvalid Software Expiration Date\n");
exit(FAILURE2);
};
};
/* validate the date */
if (idate(expdate) == FAILURE2) {
printf("\nInvalid Software Expiration Date\n");
exit(FAILURE2);
};
/* == generate 3 keys == */
keys[0] = hash_unhash(hostid, hostid);
keys[1] = hash_unhash(((date_integer16(expdate) << 16) | 0), hostid);
keys[2] = make_verification(keys[0], keys[1]);
/* == report the results == */
if (commandlineargs) {
printf("%8lx %8lx %8lx\n", keys[0], keys[1], keys[2]);
exit(1);
} else {
/* if logfile is open, append the results to the end of the file */
if (logfile == 1) {
if (argc > 2) {
fprintf(fp, "\n%s", *++argv);
printf("\n%s", *argv);
}
writeresults(fp, sptr, saveexpdate, keys[0], keys[1], keys[2], infostring);
fclose(fp);
};
/* display the results on the terminal */
writeresults(stdout, sptr, saveexpdate, keys[0], keys[1], keys[2], infostring);
};
exit(0);
}
/************************************************************************/
/* */
/* w r i t e r e s u l t s */
/* */
/* Prints the newly-generated key, along with identifying info */
/* */
/************************************************************************/
void writeresults(FILE *fp, char *host, char *expdate,
unsigned long key1, unsigned long key2, unsigned long key3,
char *info) {
fprintf(fp, "Host ID: %-14s Expiration: %-9s", host, expdate);
fprintf(fp, " Key: %8lx %8lx %8lx", key1, key2, key3);
fprintf(fp, " Doc: %s\n", info);
}

View File

@@ -1,151 +0,0 @@
/* $Id: keytst.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
*/
/************************************************************************/
/* */
/* (C) Copyright 1989-95 Venue. All Rights Reserved. */
/* Manufactured in the United States of America. */
/* */
/************************************************************************/
#include "version.h"
/* =========================================================================
The functions defined in this file are used to validate the copyright
protection keys for NewCo's Maiko software. The main function is
'keytester', which takes an input key string and returns a status
code after processing the keys.
The external functions called were stored in file 'keylib.o'.
Creation date: May, 1988
====================================================================== */
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "keylibdefs.h"
#define GOLDEN_RATIO_HACK -478700649
#define floadbyte(number, pos) ((number >> pos) & 0xFFFF)
#define hash_unhash(number, hashkey) \
(number ^ (GOLDEN_RATIO_HACK * (floadbyte(hashkey, 16) + floadbyte(hashkey, 0))))
#define KEYNUMBERS 3
#define RC0 0
/* meaning of symbolic constants used:
FAILURE2 invalid date
FAILURE3 invalid key
FAILURE4 key expired
FAILURE99 invalid date (this shouldn't happen unless string format returned
by ctime got changed) */
#define FAILURE2 -2
#define FAILURE3 -3
#define FAILURE4 -4
#define FAILURE99 -99
/* =====================================================================
KEYTESTER checks the input key string.
It returns 0 if the keys are valid, otherwise it returns non-0.
====================================================================== */
int keytester(char *keystring) {
unsigned long keyarray[KEYNUMBERS]; /* array which holds numeric keys */
unsigned long hostid; /* 32-bit unique identifier of the current host */
unsigned long hashedword;
int rc; /* return code */
/* check the keys and convert them from hexadecimal strings to numbers */
if (keystring == NULL) return FAILURE3;
if (read_hex(keystring, keyarray) == FAILURE3) return FAILURE3;
/* get machines host id */
hostid = gethostid();
printf("hostid = 0x%x\n", hostid);
hostid = modify(hostid);
/* generate hashword */
hashedword = hash_unhash(keyarray[1], hostid);
/* validate keys */
if (keyarray[0] != hash_unhash(hostid, hostid)) return FAILURE3;
if ((rc = ok_date(floadbyte(hashedword, 16))) != RC0) return rc;
if (keyarray[2] != make_verification(keyarray[0], keyarray[1])) return FAILURE3;
return 0;
}
/* =====================================================================
READ_HEX reads in keys from the input string , validates them, then
stores them in the input array.
====================================================================== */
int read_hex(char *s1, long unsigned int *array) {
char *s2 = {" "};
char *ptr;
char *hexdigits = {"0123456789abcdefABCDEF"};
int i;
for (i = 0; (i < KEYNUMBERS) && ((ptr = strtok(s1, s2)) != NULL); ++i) {
/* make sure the key contains only hexadecimal characters */
if ((strspn(ptr, hexdigits)) != strlen(ptr)) return FAILURE3;
/* convert key to numeric format*/
*(array + i) = strtol(ptr, NULL, 16); /* On suns, this works OK */
printf("0x%x ", *(array + i));
fflush(stdout);
/* continue search the next one */
s1 = NULL;
};
if (i == KEYNUMBERS)
return RC0;
else
return FAILURE3;
}
/* ============================================
OK_DATE checks the expiration of the key
============================================ */
int ok_date(long unsigned int date) {
char current_date[30];
char *mptr, *dptr, *yptr, *str;
long realtime, *clock;
/* first check if the expiration date is set to indefinite */
printf("\narg date: %ld %x\n", date, date);
printf("\narg date ?????: %ld %x\n", date_integer16("29-DEC-77"), date_integer16("29-DEC-77"));
if (date == date_integer16("29-DEC-77")) return RC0;
/* next check if current date is less than or equal to the expiration date */
/* get the current date string */
realtime = time(0);
clock = &realtime;
str = (char *)ctime(clock);
/* delete day and time info and rearrange the string format to be dd-mmm-yy */
mptr = strtok(str, " ");
mptr = strtok(NULL, " ");
dptr = strtok(NULL, " ");
yptr = strtok(NULL, " ");
yptr = strtok(NULL, " \n"); /* watch out for newline char */
current_date[0] = '\0';
strcat(current_date, dptr);
strcat(current_date, "-");
strcat(current_date, mptr);
strcat(current_date, "-");
strcat(current_date, yptr);
/* check the date */
if (idate(current_date) == FAILURE2) return FAILURE99;
printf("*current date*: %ld %x\n", date_integer16(current_date), date_integer16(current_date));
return (date_integer16(current_date) <= date) ? RC0 : FAILURE4;
}

View File

@@ -1,18 +0,0 @@
/* $Id: keytstno.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
*/
/* Loaded instead of keytst.c, with unlocked definition of keytester */
/************************************************************************/
/* */
/* (C) Copyright 1989-95 Venue. All Rights Reserved. */
/* Manufactured in the United States of America. */
/* */
/************************************************************************/
#include "version.h"
int keytester(void);
int keytester() {
return 0;
}

View File

@@ -244,8 +244,6 @@ extern int maxpages;
extern int *Lisp_errno;
extern int Dummy_errno; /* If errno cell is not provided by Lisp, dummy_errno is used. */
char keystring[128] = {""};
#define FALSE 0
#define TRUE !FALSE
@@ -292,7 +290,6 @@ const char *helpstring =
medley [<sysout-name>] [<options>]\n\
-info Print general info about the system\n\
-help Print this message\n\
-k access-key Your access key\n\
-d[isplay] host:srv.scr The host, X server and screen you want Medley on\n\
-bw <pixels> The Medley screen borderwidth\n\
-g[eometry] <geom>] The Medley screen geometry\n\
@@ -301,7 +298,7 @@ const char *helpstring =
const char *helpstring =
"\n\
either setenv LDESRCESYSOUT or do:\n\
lde[ether] [sysout-name] [-k access-key] [<options>]\n\
lde[ether] [sysout-name] [<options>]\n\
-info Print general info about the system\n\
-help Print this message\n";
#endif /* DOS */
@@ -318,7 +315,6 @@ int main(int argc, char *argv[])
int i;
char *envname;
extern int TIMER_INTERVAL;
char keytyped[255];
extern fd_set LispReadFds;
#ifdef MAIKO_ENABLE_FOREIGN_FUNCTION_INTERFACE
if (dld_find_executable(argv[0]) == 0) {
@@ -408,14 +404,6 @@ int main(int argc, char *argv[])
else if (!strcmp(argv[i], "-INIT")) { /*** init sysout, no packaged */
for_makeinit = 1;
} else if (!strcmp(argv[i], "-k")) { /**** security key ****/
if (argc > ++i) {
(void)strcpy(keystring, argv[i]);
} else {
fprintf(stderr, "Missing argument after -k\n");
exit(1);
}
}
#ifdef DOS
else if ((strcmp(argv[i], "-vga") == 0) || (strcmp(argv[i], "-VGA") == 0)) {
@@ -488,8 +476,6 @@ int main(int argc, char *argv[])
}
#endif /* DOS */
strcpy(keytyped, keystring);
FD_ZERO(&LispReadFds);
#ifdef MAIKO_ENABLE_ETHERNET

View File

@@ -1,10 +0,0 @@
/* $Id: mkkey.c,v 1.2 1999/01/03 02:07:24 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */
/************************************************************************/
/* */
/* (C) Copyright 1989-95 Venue. All Rights Reserved. */
/* Manufactured in the United States of America. */
/* */
/************************************************************************/
#include "version.h"

View File

@@ -64,8 +64,6 @@ XrmOptionDescRec opTable[] = {
{"-it", "*icontitle", XrmoptionSepArg, (caddr_t)NULL},
{"-iconbitmap", "*iconbitmap", XrmoptionSepArg, (caddr_t)NULL},
{"-ibm", "*iconbitmap", XrmoptionSepArg, (caddr_t)NULL},
{"-key", "*key", XrmoptionSepArg, (caddr_t)NULL},
{"-k", "*key", XrmoptionSepArg, (caddr_t)NULL},
{"-timer", "*timer", XrmoptionSepArg, (caddr_t)NULL},
{"-xpages", "*maxpages", XrmoptionSepArg, (caddr_t)NULL},
{"-m", "*memory", XrmoptionSepArg, (caddr_t)NULL},
@@ -87,13 +85,11 @@ char iconpixmapfile[1024];
char Window_Title[255];
char Icon_Title[255];
extern char sysout_name[], keystring[];
extern char sysout_name[];
extern int sysout_size, for_makeinit, please_fork, Scroll_Border;
/* diagnostic flag for sysout dumping */
/* extern int maxpages; */
extern char keystring[];
int Lisp_Border = 2;
/*** Ethernet stuff (JRB) **/
@@ -117,7 +113,6 @@ void print_Xusage(const char *prog)
{
fprintf(stderr, " %s options:\n", prog);
fprintf(stderr, " [-sysout] [<sysout>] -path to the Medley image\n");
fprintf(stderr, " -k[ey] <access-key> -see manual for details\n");
fprintf(stderr, " -h[elp] -prints this text\n");
fprintf(stderr, " -d[isplay] <host>:<display>.<screen>\n");
fprintf(stderr,
@@ -147,7 +142,7 @@ void print_lispusage(const char *prog)
TPRINT(("TRACE: print_lisp_usage()\n"));
/* Lisp Option */
fprintf(stderr, "lde[ether] [sysout] [-k access-key]");
fprintf(stderr, "lde[ether] [sysout]");
fprintf(stderr, " [-E <ethernet-info>]");
fprintf(stderr, "\n");
@@ -322,9 +317,6 @@ void read_Xoption(int *argc, char *argv[])
if (XrmGetResource(rDB, "ldex.Init", "Ldex.Init", str_type, &value) == True) { for_makeinit = 1; }
if (XrmGetResource(rDB, "ldex.key", "Ldex.key", str_type, &value) == True) {
(void)strncpy(keystring, value.addr, (int)value.size);
}
if (XrmGetResource(rDB, "ldex.xsync", "Ldex.xsync", str_type, &value) == True) { xsync = True; }
#ifdef MAIKO_ENABLE_ETHERNET
if (XrmGetResource(rDB, "ldex.EtherNet", "Ldex.EtherNet", str_type, &value) == True) {