mirror of https://github.com/0intro/conterm
#%*&*@#(@ sun
This commit is contained in:
parent
ee4955c879
commit
1125f094ce
|
@ -0,0 +1,21 @@
|
||||||
|
# Sun-specific
|
||||||
|
PTHREAD=
|
||||||
|
AR=ar
|
||||||
|
AS=as
|
||||||
|
RANLIB=ranlib
|
||||||
|
X11=/usr/X11R6
|
||||||
|
CC=cc
|
||||||
|
CFLAGS=-xCC -I$(ROOT) -I$(ROOT)/include -I$(ROOT)/kern -c -g -D_THREAD_SAFE
|
||||||
|
O=o
|
||||||
|
OS=posix
|
||||||
|
GUI=x11
|
||||||
|
LDADD=-L$(X11)/lib -lX11 -lrt -lpthread -lsocket -lnsl
|
||||||
|
LDFLAGS=
|
||||||
|
TARG=drawterm
|
||||||
|
AUDIO=none
|
||||||
|
|
||||||
|
all: default
|
||||||
|
|
||||||
|
libmachdep.a:
|
||||||
|
arch=`uname -m|sed 's/i.86/386/;s/Power Macintosh/power/'`; \
|
||||||
|
(cd posix-$$arch && make)
|
2
README
2
README
|
@ -2,6 +2,8 @@ INSTALLATION
|
||||||
--------------
|
--------------
|
||||||
To build on Unix, run CONF=unix make.
|
To build on Unix, run CONF=unix make.
|
||||||
|
|
||||||
|
To build on Solaris using Sun cc, run CONF=sun make.
|
||||||
|
|
||||||
To build on Windows, you need Mingw. See http://www.mingw.org.
|
To build on Windows, you need Mingw. See http://www.mingw.org.
|
||||||
Edit Make.config to uncomment the Windows section
|
Edit Make.config to uncomment the Windows section
|
||||||
and comment out the rest. Then run CONF=windows make.
|
and comment out the rest. Then run CONF=windows make.
|
||||||
|
|
2
cpu.c
2
cpu.c
|
@ -54,7 +54,7 @@ struct AuthMethod {
|
||||||
{ "p9", p9auth, srvp9auth,},
|
{ "p9", p9auth, srvp9auth,},
|
||||||
{ "netkey", netkeyauth, netkeysrvauth,},
|
{ "netkey", netkeyauth, netkeysrvauth,},
|
||||||
// { "none", noauth, srvnoauth,},
|
// { "none", noauth, srvnoauth,},
|
||||||
{ nil, nil}
|
{ 0 }
|
||||||
};
|
};
|
||||||
AuthMethod *am = authmethod; /* default is p9 */
|
AuthMethod *am = authmethod; /* default is p9 */
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ typedef struct AuthRpc AuthRpc;
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MAXCHLEN= 256, /* max challenge length */
|
MAXCHLEN= 256, /* max challenge length */
|
||||||
MAXNAMELEN= 256, /* maximum name length */
|
AMAXNAMELEN= 256, /* maximum name length */
|
||||||
MD5LEN= 16,
|
MD5LEN= 16,
|
||||||
|
|
||||||
ARok = 0, /* rpc return values */
|
ARok = 0, /* rpc return values */
|
||||||
|
@ -63,7 +63,7 @@ struct Chalstate
|
||||||
/* for implementation only */
|
/* for implementation only */
|
||||||
int afd; /* to factotum */
|
int afd; /* to factotum */
|
||||||
AuthRpc *rpc; /* to factotum */
|
AuthRpc *rpc; /* to factotum */
|
||||||
char userbuf[MAXNAMELEN]; /* temp space if needed */
|
char userbuf[AMAXNAMELEN]; /* temp space if needed */
|
||||||
int userinchal; /* user was sent to obtain challenge */
|
int userinchal; /* user was sent to obtain challenge */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#if defined(linux) || defined(IRIX) || defined(SOLARIS) || defined(OSF1) || defined(__FreeBSD__) || defined(__APPLE__) || defined(__NetBSD__)
|
#if defined(linux) || defined(IRIX) || defined(SOLARIS) || defined(OSF1) || defined(__FreeBSD__) || defined(__APPLE__) || defined(__NetBSD__) || defined(__sun) || defined(sun)
|
||||||
# include "unix.h"
|
# include "unix.h"
|
||||||
# ifdef __APPLE__
|
# ifdef __APPLE__
|
||||||
# define panic dt_panic
|
# define panic dt_panic
|
||||||
|
|
|
@ -36,7 +36,6 @@ OFILES=\
|
||||||
qio.$O\
|
qio.$O\
|
||||||
qlock.$O\
|
qlock.$O\
|
||||||
term.$O\
|
term.$O\
|
||||||
todo.$O\
|
|
||||||
uart.$O\
|
uart.$O\
|
||||||
waserror.$O\
|
waserror.$O\
|
||||||
$(OS).$O
|
$(OS).$O
|
||||||
|
|
|
@ -236,7 +236,7 @@ struct Dirtab
|
||||||
char name[KNAMELEN];
|
char name[KNAMELEN];
|
||||||
Qid qid;
|
Qid qid;
|
||||||
vlong length;
|
vlong length;
|
||||||
long perm;
|
ulong perm;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Walkqid
|
struct Walkqid
|
||||||
|
|
|
@ -45,18 +45,18 @@ static struct
|
||||||
int irval;
|
int irval;
|
||||||
} volumes[] =
|
} volumes[] =
|
||||||
{
|
{
|
||||||
[Vaudio] "audio", Fout, 50, 50,
|
"audio", Fout, 50, 50,
|
||||||
[Vsynth] "synth", Fin|Fout, 0, 0,
|
"synth", Fin|Fout, 0, 0,
|
||||||
[Vcd] "cd", Fin|Fout, 0, 0,
|
"cd", Fin|Fout, 0, 0,
|
||||||
[Vline] "line", Fin|Fout, 0, 0,
|
"line", Fin|Fout, 0, 0,
|
||||||
[Vmic] "mic", Fin|Fout|Fmono, 0, 0,
|
"mic", Fin|Fout|Fmono, 0, 0,
|
||||||
[Vspeaker] "speaker", Fout|Fmono, 0, 0,
|
"speaker", Fout|Fmono, 0, 0,
|
||||||
|
|
||||||
[Vtreb] "treb", Fout, 50, 50,
|
"treb", Fout, 50, 50,
|
||||||
[Vbass] "bass", Fout, 50, 50,
|
"bass", Fout, 50, 50,
|
||||||
|
|
||||||
[Vspeed] "speed", Fin|Fout|Fmono, Speed, Speed,
|
"speed", Fin|Fout|Fmono, Speed, Speed,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
static char Emode[] = "illegal open mode";
|
static char Emode[] = "illegal open mode";
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
|
|
||||||
void (*consdebug)(void) = nil;
|
void (*consdebug)(void) = 0;
|
||||||
void (*screenputs)(char*, int) = nil;
|
void (*screenputs)(char*, int) = 0;
|
||||||
|
|
||||||
Queue* kbdq; /* unprocessed console input */
|
Queue* kbdq; /* unprocessed console input */
|
||||||
Queue* lineq; /* processed console input */
|
Queue* lineq; /* processed console input */
|
||||||
|
@ -86,7 +86,7 @@ return0(void *v)
|
||||||
void
|
void
|
||||||
printinit(void)
|
printinit(void)
|
||||||
{
|
{
|
||||||
lineq = qopen(2*1024, 0, nil, nil);
|
lineq = qopen(2*1024, 0, 0, nil);
|
||||||
if(lineq == nil)
|
if(lineq == nil)
|
||||||
panic("printinit");
|
panic("printinit");
|
||||||
qnoblock(lineq, 1);
|
qnoblock(lineq, 1);
|
||||||
|
@ -332,14 +332,14 @@ echo(char *buf, int n)
|
||||||
pagersummary();
|
pagersummary();
|
||||||
return;
|
return;
|
||||||
case 'd':
|
case 'd':
|
||||||
if(consdebug == nil)
|
if(consdebug == 0)
|
||||||
consdebug = rdb;
|
consdebug = rdb;
|
||||||
else
|
else
|
||||||
consdebug = nil;
|
consdebug = 0;
|
||||||
print("consdebug now 0x%p\n", consdebug);
|
print("consdebug now 0x%p\n", consdebug);
|
||||||
return;
|
return;
|
||||||
case 'D':
|
case 'D':
|
||||||
if(consdebug == nil)
|
if(consdebug == 0)
|
||||||
consdebug = rdb;
|
consdebug = rdb;
|
||||||
consdebug();
|
consdebug();
|
||||||
return;
|
return;
|
||||||
|
@ -363,7 +363,7 @@ echo(char *buf, int n)
|
||||||
qproduce(kbdq, buf, n);
|
qproduce(kbdq, buf, n);
|
||||||
if(kbd.raw)
|
if(kbd.raw)
|
||||||
return;
|
return;
|
||||||
if(screenputs != nil)
|
if(screenputs != 0)
|
||||||
echoscreen(buf, n);
|
echoscreen(buf, n);
|
||||||
if(serialoq)
|
if(serialoq)
|
||||||
echoserialoq(buf, n);
|
echoserialoq(buf, n);
|
||||||
|
|
|
@ -1411,7 +1411,7 @@ drawmesg(Client *client, void *av, int n)
|
||||||
scrn = dscrn->screen;
|
scrn = dscrn->screen;
|
||||||
if(repl || chan!=scrn->image->chan)
|
if(repl || chan!=scrn->image->chan)
|
||||||
error("image parameters incompatible with screen");
|
error("image parameters incompatible with screen");
|
||||||
reffn = nil;
|
reffn = 0;
|
||||||
switch(refresh){
|
switch(refresh){
|
||||||
case Refbackup:
|
case Refbackup:
|
||||||
break;
|
break;
|
||||||
|
@ -1554,9 +1554,9 @@ drawmesg(Client *client, void *av, int n)
|
||||||
oy = BGLONG(a+41);
|
oy = BGLONG(a+41);
|
||||||
op = drawclientop(client);
|
op = drawclientop(client);
|
||||||
/* high bit indicates arc angles are present */
|
/* high bit indicates arc angles are present */
|
||||||
if(ox & (1<<31)){
|
if(ox & (1U<<31)){
|
||||||
if((ox & (1<<30)) == 0)
|
if((ox & (1<<30)) == 0)
|
||||||
ox &= ~(1<<31);
|
ox &= ~(1U<<31);
|
||||||
memarc(dst, p, e0, e1, c, src, sp, ox, oy, op);
|
memarc(dst, p, e0, e1, c, src, sp, ox, oy, op);
|
||||||
}else
|
}else
|
||||||
memellipse(dst, p, e0, e1, c, src, sp, op);
|
memellipse(dst, p, e0, e1, c, src, sp, op);
|
||||||
|
|
|
@ -216,7 +216,7 @@ mntversion(Chan *c, char *version, int msize, int returnlen)
|
||||||
m->version = nil;
|
m->version = nil;
|
||||||
kstrdup(&m->version, f.version);
|
kstrdup(&m->version, f.version);
|
||||||
m->id = mntalloc.id++;
|
m->id = mntalloc.id++;
|
||||||
m->q = qopen(10*MAXRPC, 0, nil, nil);
|
m->q = qopen(10*MAXRPC, 0, 0, nil);
|
||||||
m->msize = f.msize;
|
m->msize = f.msize;
|
||||||
unlock(&mntalloc.lk);
|
unlock(&mntalloc.lk);
|
||||||
|
|
||||||
|
@ -970,7 +970,7 @@ mountmux(Mnt *m, Mntrpc *r)
|
||||||
}
|
}
|
||||||
q->done = 1;
|
q->done = 1;
|
||||||
unlock(&m->lk);
|
unlock(&m->lk);
|
||||||
if(mntstats != nil)
|
if(mntstats != 0)
|
||||||
(*mntstats)(q->request.type,
|
(*mntstats)(q->request.type,
|
||||||
m->c, q->stime,
|
m->c, q->stime,
|
||||||
q->reqlen + r->replen);
|
q->reqlen + r->replen);
|
||||||
|
|
|
@ -467,7 +467,7 @@ tlsopen(Chan *c, int omode)
|
||||||
lock(&tr->hqlock);
|
lock(&tr->hqlock);
|
||||||
if(tr->handq != nil)
|
if(tr->handq != nil)
|
||||||
error(Einuse);
|
error(Einuse);
|
||||||
tr->handq = qopen(2 * MaxCipherRecLen, 0, nil, nil);
|
tr->handq = qopen(2 * MaxCipherRecLen, 0, 0, nil);
|
||||||
if(tr->handq == nil)
|
if(tr->handq == nil)
|
||||||
error("cannot allocate handshake queue");
|
error("cannot allocate handshake queue");
|
||||||
tr->hqref = 1;
|
tr->hqref = 1;
|
||||||
|
|
|
@ -15,7 +15,7 @@ dorpc(AuthRpc *rpc, char *verb, char *val, int len, AuthGetkey *getkey)
|
||||||
for(;;){
|
for(;;){
|
||||||
if((ret = auth_rpc(rpc, verb, val, len)) != ARneedkey && ret != ARbadkey)
|
if((ret = auth_rpc(rpc, verb, val, len)) != ARneedkey && ret != ARbadkey)
|
||||||
return ret;
|
return ret;
|
||||||
if(getkey == nil)
|
if(getkey == 0)
|
||||||
return ARgiveup; /* don't know how */
|
return ARgiveup; /* don't know how */
|
||||||
if((*getkey)(rpc->arg) < 0)
|
if((*getkey)(rpc->arg) < 0)
|
||||||
return ARgiveup; /* user punted */
|
return ARgiveup; /* user punted */
|
||||||
|
|
|
@ -106,7 +106,7 @@ dorpc(AuthRpc *rpc, char *verb, char *val, int len, AuthGetkey *getkey)
|
||||||
for(;;){
|
for(;;){
|
||||||
if((ret = auth_rpc(rpc, verb, val, len)) != ARneedkey && ret != ARbadkey)
|
if((ret = auth_rpc(rpc, verb, val, len)) != ARneedkey && ret != ARbadkey)
|
||||||
return ret;
|
return ret;
|
||||||
if(getkey == nil)
|
if(getkey == 0)
|
||||||
return ARgiveup; /* don't know how */
|
return ARgiveup; /* don't know how */
|
||||||
if((*getkey)(rpc->arg) < 0)
|
if((*getkey)(rpc->arg) < 0)
|
||||||
return ARgiveup; /* user punted */
|
return ARgiveup; /* user punted */
|
||||||
|
|
|
@ -16,7 +16,7 @@ dorpc(AuthRpc *rpc, char *verb, char *val, int len, AuthGetkey *getkey)
|
||||||
for(;;){
|
for(;;){
|
||||||
if((ret = auth_rpc(rpc, verb, val, len)) != ARneedkey && ret != ARbadkey)
|
if((ret = auth_rpc(rpc, verb, val, len)) != ARneedkey && ret != ARbadkey)
|
||||||
return ret;
|
return ret;
|
||||||
if(getkey == nil)
|
if(getkey == 0)
|
||||||
return ARgiveup; /* don't know how */
|
return ARgiveup; /* don't know how */
|
||||||
if((*getkey)(rpc->arg) < 0)
|
if((*getkey)(rpc->arg) < 0)
|
||||||
return ARgiveup; /* user punted */
|
return ARgiveup; /* user punted */
|
||||||
|
|
|
@ -61,7 +61,7 @@ static Convfmt knownfmt[] = {
|
||||||
'u', __ifmt,
|
'u', __ifmt,
|
||||||
#endif
|
#endif
|
||||||
'x', __ifmt,
|
'x', __ifmt,
|
||||||
0, nil,
|
0, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ fmtfmt(int c)
|
||||||
ep = &fmtalloc.fmt[fmtalloc.nfmt];
|
ep = &fmtalloc.fmt[fmtalloc.nfmt];
|
||||||
for(p=fmtalloc.fmt; p<ep; p++)
|
for(p=fmtalloc.fmt; p<ep; p++)
|
||||||
if(p->c == c){
|
if(p->c == c){
|
||||||
while(p->fmt == nil) /* loop until value is updated */
|
while(p->fmt == 0) /* loop until value is updated */
|
||||||
;
|
;
|
||||||
return p->fmt;
|
return p->fmt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ __quotesetup(char *s, Rune *r, int nin, int nout, Quoteinfo *q, int sharp, int r
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((c <= L' ') || (c == L'\'') || (fmtdoquote!=nil && fmtdoquote(c))){
|
if((c <= L' ') || (c == L'\'') || (fmtdoquote!=0 && fmtdoquote(c))){
|
||||||
if(!q->quoted){
|
if(!q->quoted){
|
||||||
if(runesout){
|
if(runesout){
|
||||||
if(1+q->nrunesout+1+1 > nout) /* no room for quotes */
|
if(1+q->nrunesout+1+1 > nout) /* no room for quotes */
|
||||||
|
|
|
@ -13,7 +13,7 @@ runevseprint(Rune *buf, Rune *e, char *fmt, va_list args)
|
||||||
f.start = buf;
|
f.start = buf;
|
||||||
f.to = buf;
|
f.to = buf;
|
||||||
f.stop = e - 1;
|
f.stop = e - 1;
|
||||||
f.flush = nil;
|
f.flush = 0;
|
||||||
f.farg = nil;
|
f.farg = nil;
|
||||||
f.nfmt = 0;
|
f.nfmt = 0;
|
||||||
VA_COPY(f.args,args);
|
VA_COPY(f.args,args);
|
||||||
|
|
|
@ -13,7 +13,7 @@ runevsnprint(Rune *buf, int len, char *fmt, va_list args)
|
||||||
f.start = buf;
|
f.start = buf;
|
||||||
f.to = buf;
|
f.to = buf;
|
||||||
f.stop = buf + len - 1;
|
f.stop = buf + len - 1;
|
||||||
f.flush = nil;
|
f.flush = 0;
|
||||||
f.farg = nil;
|
f.farg = nil;
|
||||||
f.nfmt = 0;
|
f.nfmt = 0;
|
||||||
VA_COPY(f.args,args);
|
VA_COPY(f.args,args);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#define VLONG_MAX ~(((vlong) 1)<<63)
|
#define VLONG_MAX ((vlong)~(((uvlong)1)<<63))
|
||||||
#define VLONG_MIN (((vlong) 1)<<63)
|
#define VLONG_MIN ((vlong)(((uvlong)1)<<63))
|
||||||
vlong
|
vlong
|
||||||
strtoll(const char *nptr, char **endptr, int base)
|
strtoll(const char *nptr, char **endptr, int base)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1890,7 +1890,7 @@ boolcopyfn(Memimage *img, Memimage *mask)
|
||||||
default:
|
default:
|
||||||
assert(0 /* boolcopyfn */);
|
assert(0 /* boolcopyfn */);
|
||||||
}
|
}
|
||||||
return nil;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -10,13 +10,13 @@ memlsetrefresh(Memimage *i, Refreshfn fn, void *ptr)
|
||||||
Memlayer *l;
|
Memlayer *l;
|
||||||
|
|
||||||
l = i->layer;
|
l = i->layer;
|
||||||
if(l->refreshfn!=nil && fn!=nil){ /* just change functions */
|
if(l->refreshfn!=0 && fn!=0){ /* just change functions */
|
||||||
l->refreshfn = fn;
|
l->refreshfn = fn;
|
||||||
l->refreshptr = ptr;
|
l->refreshptr = ptr;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(l->refreshfn == nil){ /* is using backup image; just free it */
|
if(l->refreshfn == 0){ /* is using backup image; just free it */
|
||||||
freememimage(l->save);
|
freememimage(l->save);
|
||||||
l->save = nil;
|
l->save = nil;
|
||||||
l->refreshfn = fn;
|
l->refreshfn = fn;
|
||||||
|
@ -29,7 +29,7 @@ memlsetrefresh(Memimage *i, Refreshfn fn, void *ptr)
|
||||||
return 0;
|
return 0;
|
||||||
/* easiest way is just to update the entire save area */
|
/* easiest way is just to update the entire save area */
|
||||||
l->refreshfn(i, i->r, l->refreshptr);
|
l->refreshfn(i, i->r, l->refreshptr);
|
||||||
l->refreshfn = nil;
|
l->refreshfn = 0;
|
||||||
l->refreshptr = nil;
|
l->refreshptr = nil;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#define mpdighi (mpdigit)(1<<(Dbits-1))
|
#define mpdighi (mpdigit)(1U<<(Dbits-1))
|
||||||
#define DIGITS(x) ((Dbits - 1 + (x))/Dbits)
|
#define DIGITS(x) ((Dbits - 1 + (x))/Dbits)
|
||||||
|
|
||||||
// for converting between int's and mpint's
|
// for converting between int's and mpint's
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
ROOT=..
|
||||||
|
include ../Make.config
|
||||||
|
LIB=../libmachdep.a
|
||||||
|
|
||||||
|
OFILES=\
|
||||||
|
getcallerpc.$O\
|
||||||
|
md5block.$O\
|
||||||
|
sha1block.$O\
|
||||||
|
tas.$O
|
||||||
|
|
||||||
|
default: $(LIB)
|
||||||
|
$(LIB): $(OFILES)
|
||||||
|
$(AR) r $(LIB) $(OFILES)
|
||||||
|
$(RANLIB) $(LIB)
|
||||||
|
|
||||||
|
%.$O: %.c
|
||||||
|
$(CC) $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
%.$O: %.s
|
||||||
|
$(AS) -o $*.$O $*.s
|
||||||
|
|
||||||
|
%.s: %.spp
|
||||||
|
cpp $*.spp >$*.s
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#include "u.h"
|
||||||
|
#include "libc.h"
|
||||||
|
|
||||||
|
ulong
|
||||||
|
getcallerpc(void *a)
|
||||||
|
{
|
||||||
|
return ((ulong*)a)[-1];
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,268 @@
|
||||||
|
#include <u.h>
|
||||||
|
#include <libc.h>
|
||||||
|
#include <libsec.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* rfc1321 requires that I include this. The code is new. The constants
|
||||||
|
* all come from the rfc (hence the copyright). We trade a table for the
|
||||||
|
* macros in rfc. The total size is a lot less. -- presotto
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||||
|
* rights reserved.
|
||||||
|
*
|
||||||
|
* License to copy and use this software is granted provided that it
|
||||||
|
* is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
||||||
|
* Algorithm" in all material mentioning or referencing this software
|
||||||
|
* or this function.
|
||||||
|
*
|
||||||
|
* License is also granted to make and use derivative works provided
|
||||||
|
* that such works are identified as "derived from the RSA Data
|
||||||
|
* Security, Inc. MD5 Message-Digest Algorithm" in all material
|
||||||
|
* mentioning or referencing the derived work.
|
||||||
|
*
|
||||||
|
* RSA Data Security, Inc. makes no representations concerning either
|
||||||
|
* the merchantability of this software or the suitability of this
|
||||||
|
* software forany particular purpose. It is provided "as is"
|
||||||
|
* without express or implied warranty of any kind.
|
||||||
|
* These notices must be retained in any copies of any part of this
|
||||||
|
* documentation and/or software.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Rotate ammounts used in the algorithm
|
||||||
|
*/
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
S11= 7,
|
||||||
|
S12= 12,
|
||||||
|
S13= 17,
|
||||||
|
S14= 22,
|
||||||
|
|
||||||
|
S21= 5,
|
||||||
|
S22= 9,
|
||||||
|
S23= 14,
|
||||||
|
S24= 20,
|
||||||
|
|
||||||
|
S31= 4,
|
||||||
|
S32= 11,
|
||||||
|
S33= 16,
|
||||||
|
S34= 23,
|
||||||
|
|
||||||
|
S41= 6,
|
||||||
|
S42= 10,
|
||||||
|
S43= 15,
|
||||||
|
S44= 21,
|
||||||
|
};
|
||||||
|
|
||||||
|
static u32int md5tab[] =
|
||||||
|
{
|
||||||
|
/* round 1 */
|
||||||
|
/*[0]*/ 0xd76aa478,
|
||||||
|
0xe8c7b756,
|
||||||
|
0x242070db,
|
||||||
|
0xc1bdceee,
|
||||||
|
0xf57c0faf,
|
||||||
|
0x4787c62a,
|
||||||
|
0xa8304613,
|
||||||
|
0xfd469501,
|
||||||
|
0x698098d8,
|
||||||
|
0x8b44f7af,
|
||||||
|
0xffff5bb1,
|
||||||
|
0x895cd7be,
|
||||||
|
0x6b901122,
|
||||||
|
0xfd987193,
|
||||||
|
0xa679438e,
|
||||||
|
0x49b40821,
|
||||||
|
|
||||||
|
/* round 2 */
|
||||||
|
/*[16]*/0xf61e2562,
|
||||||
|
0xc040b340,
|
||||||
|
0x265e5a51,
|
||||||
|
0xe9b6c7aa,
|
||||||
|
0xd62f105d,
|
||||||
|
0x2441453,
|
||||||
|
0xd8a1e681,
|
||||||
|
0xe7d3fbc8,
|
||||||
|
0x21e1cde6,
|
||||||
|
0xc33707d6,
|
||||||
|
0xf4d50d87,
|
||||||
|
0x455a14ed,
|
||||||
|
0xa9e3e905,
|
||||||
|
0xfcefa3f8,
|
||||||
|
0x676f02d9,
|
||||||
|
0x8d2a4c8a,
|
||||||
|
|
||||||
|
/* round 3 */
|
||||||
|
/*[32]*/0xfffa3942,
|
||||||
|
0x8771f681,
|
||||||
|
0x6d9d6122,
|
||||||
|
0xfde5380c,
|
||||||
|
0xa4beea44,
|
||||||
|
0x4bdecfa9,
|
||||||
|
0xf6bb4b60,
|
||||||
|
0xbebfbc70,
|
||||||
|
0x289b7ec6,
|
||||||
|
0xeaa127fa,
|
||||||
|
0xd4ef3085,
|
||||||
|
0x4881d05,
|
||||||
|
0xd9d4d039,
|
||||||
|
0xe6db99e5,
|
||||||
|
0x1fa27cf8,
|
||||||
|
0xc4ac5665,
|
||||||
|
|
||||||
|
/* round 4 */
|
||||||
|
/*[48]*/0xf4292244,
|
||||||
|
0x432aff97,
|
||||||
|
0xab9423a7,
|
||||||
|
0xfc93a039,
|
||||||
|
0x655b59c3,
|
||||||
|
0x8f0ccc92,
|
||||||
|
0xffeff47d,
|
||||||
|
0x85845dd1,
|
||||||
|
0x6fa87e4f,
|
||||||
|
0xfe2ce6e0,
|
||||||
|
0xa3014314,
|
||||||
|
0x4e0811a1,
|
||||||
|
0xf7537e82,
|
||||||
|
0xbd3af235,
|
||||||
|
0x2ad7d2bb,
|
||||||
|
0xeb86d391,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void decode(u32int*, uchar*, ulong);
|
||||||
|
extern void _md5block(uchar *p, ulong len, u32int *s);
|
||||||
|
|
||||||
|
void
|
||||||
|
_md5block(uchar *p, ulong len, u32int *s)
|
||||||
|
{
|
||||||
|
u32int a, b, c, d, sh;
|
||||||
|
u32int *t;
|
||||||
|
uchar *end;
|
||||||
|
u32int x[16];
|
||||||
|
|
||||||
|
for(end = p+len; p < end; p += 64){
|
||||||
|
a = s[0];
|
||||||
|
b = s[1];
|
||||||
|
c = s[2];
|
||||||
|
d = s[3];
|
||||||
|
|
||||||
|
decode(x, p, 64);
|
||||||
|
|
||||||
|
t = md5tab;
|
||||||
|
sh = 0;
|
||||||
|
for(; sh != 16; t += 4){
|
||||||
|
a += ((c ^ d) & b) ^ d;
|
||||||
|
a += x[sh] + t[0];
|
||||||
|
a = (a << S11) | (a >> (32 - S11));
|
||||||
|
a += b;
|
||||||
|
|
||||||
|
d += ((b ^ c) & a) ^ c;
|
||||||
|
d += x[sh + 1] + t[1];
|
||||||
|
d = (d << S12) | (d >> (32 - S12));
|
||||||
|
d += a;
|
||||||
|
|
||||||
|
c += ((a ^ b) & d) ^ b;
|
||||||
|
c += x[sh + 2] + t[2];
|
||||||
|
c = (c << S13) | (c >> (32 - S13));
|
||||||
|
c += d;
|
||||||
|
|
||||||
|
b += ((d ^ a) & c) ^ a;
|
||||||
|
b += x[sh + 3] + t[3];
|
||||||
|
b = (b << S14) | (b >> (32 - S14));
|
||||||
|
b += c;
|
||||||
|
|
||||||
|
sh += 4;
|
||||||
|
}
|
||||||
|
sh = 1;
|
||||||
|
for(; sh != 1+20*4; t += 4){
|
||||||
|
a += ((b ^ c) & d) ^ c;
|
||||||
|
a += x[sh & 0xf] + t[0];
|
||||||
|
a = (a << S21) | (a >> (32 - S21));
|
||||||
|
a += b;
|
||||||
|
|
||||||
|
d += ((a ^ b) & c) ^ b;
|
||||||
|
d += x[(sh + 5) & 0xf] + t[1];
|
||||||
|
d = (d << S22) | (d >> (32 - S22));
|
||||||
|
d += a;
|
||||||
|
|
||||||
|
c += ((d ^ a) & b) ^ a;
|
||||||
|
c += x[(sh + 10) & 0xf] + t[2];
|
||||||
|
c = (c << S23) | (c >> (32 - S23));
|
||||||
|
c += d;
|
||||||
|
|
||||||
|
b += ((c ^ d) & a) ^ d;
|
||||||
|
b += x[(sh + 15) & 0xf] + t[3];
|
||||||
|
b = (b << S24) | (b >> (32 - S24));
|
||||||
|
b += c;
|
||||||
|
|
||||||
|
sh += 20;
|
||||||
|
}
|
||||||
|
sh = 5;
|
||||||
|
for(; sh != 5+12*4; t += 4){
|
||||||
|
a += b ^ c ^ d;
|
||||||
|
a += x[sh & 0xf] + t[0];
|
||||||
|
a = (a << S31) | (a >> (32 - S31));
|
||||||
|
a += b;
|
||||||
|
|
||||||
|
d += a ^ b ^ c;
|
||||||
|
d += x[(sh + 3) & 0xf] + t[1];
|
||||||
|
d = (d << S32) | (d >> (32 - S32));
|
||||||
|
d += a;
|
||||||
|
|
||||||
|
c += d ^ a ^ b;
|
||||||
|
c += x[(sh + 6) & 0xf] + t[2];
|
||||||
|
c = (c << S33) | (c >> (32 - S33));
|
||||||
|
c += d;
|
||||||
|
|
||||||
|
b += c ^ d ^ a;
|
||||||
|
b += x[(sh + 9) & 0xf] + t[3];
|
||||||
|
b = (b << S34) | (b >> (32 - S34));
|
||||||
|
b += c;
|
||||||
|
|
||||||
|
sh += 12;
|
||||||
|
}
|
||||||
|
sh = 0;
|
||||||
|
for(; sh != 28*4; t += 4){
|
||||||
|
a += c ^ (b | ~d);
|
||||||
|
a += x[sh & 0xf] + t[0];
|
||||||
|
a = (a << S41) | (a >> (32 - S41));
|
||||||
|
a += b;
|
||||||
|
|
||||||
|
d += b ^ (a | ~c);
|
||||||
|
d += x[(sh + 7) & 0xf] + t[1];
|
||||||
|
d = (d << S42) | (d >> (32 - S42));
|
||||||
|
d += a;
|
||||||
|
|
||||||
|
c += a ^ (d | ~b);
|
||||||
|
c += x[(sh + 14) & 0xf] + t[2];
|
||||||
|
c = (c << S43) | (c >> (32 - S43));
|
||||||
|
c += d;
|
||||||
|
|
||||||
|
b += d ^ (c | ~a);
|
||||||
|
b += x[(sh + 21) & 0xf] + t[3];
|
||||||
|
b = (b << S44) | (b >> (32 - S44));
|
||||||
|
b += c;
|
||||||
|
|
||||||
|
sh += 28;
|
||||||
|
}
|
||||||
|
|
||||||
|
s[0] += a;
|
||||||
|
s[1] += b;
|
||||||
|
s[2] += c;
|
||||||
|
s[3] += d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* decodes input (uchar) into output (u32int). Assumes len is
|
||||||
|
* a multiple of 4.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
decode(u32int *output, uchar *input, ulong len)
|
||||||
|
{
|
||||||
|
uchar *e;
|
||||||
|
|
||||||
|
for(e = input+len; input < e; input += 4)
|
||||||
|
*output++ = input[0] | (input[1] << 8) |
|
||||||
|
(input[2] << 16) | (input[3] << 24);
|
||||||
|
}
|
|
@ -0,0 +1,189 @@
|
||||||
|
#include <u.h>
|
||||||
|
#include <libc.h>
|
||||||
|
#include <libsec.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
_sha1block(uchar *p, ulong len, u32int *s)
|
||||||
|
{
|
||||||
|
u32int a, b, c, d, e, x;
|
||||||
|
uchar *end;
|
||||||
|
u32int *wp, *wend;
|
||||||
|
u32int w[80];
|
||||||
|
|
||||||
|
/* at this point, we have a multiple of 64 bytes */
|
||||||
|
for(end = p+len; p < end;){
|
||||||
|
a = s[0];
|
||||||
|
b = s[1];
|
||||||
|
c = s[2];
|
||||||
|
d = s[3];
|
||||||
|
e = s[4];
|
||||||
|
|
||||||
|
wend = w + 15;
|
||||||
|
for(wp = w; wp < wend; wp += 5){
|
||||||
|
wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
|
||||||
|
e += ((a<<5) | (a>>27)) + wp[0];
|
||||||
|
e += 0x5a827999 + (((c^d)&b)^d);
|
||||||
|
b = (b<<30)|(b>>2);
|
||||||
|
|
||||||
|
wp[1] = (p[4]<<24) | (p[5]<<16) | (p[6]<<8) | p[7];
|
||||||
|
d += ((e<<5) | (e>>27)) + wp[1];
|
||||||
|
d += 0x5a827999 + (((b^c)&a)^c);
|
||||||
|
a = (a<<30)|(a>>2);
|
||||||
|
|
||||||
|
wp[2] = (p[8]<<24) | (p[9]<<16) | (p[10]<<8) | p[11];
|
||||||
|
c += ((d<<5) | (d>>27)) + wp[2];
|
||||||
|
c += 0x5a827999 + (((a^b)&e)^b);
|
||||||
|
e = (e<<30)|(e>>2);
|
||||||
|
|
||||||
|
wp[3] = (p[12]<<24) | (p[13]<<16) | (p[14]<<8) | p[15];
|
||||||
|
b += ((c<<5) | (c>>27)) + wp[3];
|
||||||
|
b += 0x5a827999 + (((e^a)&d)^a);
|
||||||
|
d = (d<<30)|(d>>2);
|
||||||
|
|
||||||
|
wp[4] = (p[16]<<24) | (p[17]<<16) | (p[18]<<8) | p[19];
|
||||||
|
a += ((b<<5) | (b>>27)) + wp[4];
|
||||||
|
a += 0x5a827999 + (((d^e)&c)^e);
|
||||||
|
c = (c<<30)|(c>>2);
|
||||||
|
|
||||||
|
p += 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
|
||||||
|
e += ((a<<5) | (a>>27)) + wp[0];
|
||||||
|
e += 0x5a827999 + (((c^d)&b)^d);
|
||||||
|
b = (b<<30)|(b>>2);
|
||||||
|
|
||||||
|
x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15];
|
||||||
|
wp[1] = (x<<1) | (x>>31);
|
||||||
|
d += ((e<<5) | (e>>27)) + wp[1];
|
||||||
|
d += 0x5a827999 + (((b^c)&a)^c);
|
||||||
|
a = (a<<30)|(a>>2);
|
||||||
|
|
||||||
|
x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14];
|
||||||
|
wp[2] = (x<<1) | (x>>31);
|
||||||
|
c += ((d<<5) | (d>>27)) + wp[2];
|
||||||
|
c += 0x5a827999 + (((a^b)&e)^b);
|
||||||
|
e = (e<<30)|(e>>2);
|
||||||
|
|
||||||
|
x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13];
|
||||||
|
wp[3] = (x<<1) | (x>>31);
|
||||||
|
b += ((c<<5) | (c>>27)) + wp[3];
|
||||||
|
b += 0x5a827999 + (((e^a)&d)^a);
|
||||||
|
d = (d<<30)|(d>>2);
|
||||||
|
|
||||||
|
x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12];
|
||||||
|
wp[4] = (x<<1) | (x>>31);
|
||||||
|
a += ((b<<5) | (b>>27)) + wp[4];
|
||||||
|
a += 0x5a827999 + (((d^e)&c)^e);
|
||||||
|
c = (c<<30)|(c>>2);
|
||||||
|
|
||||||
|
wp += 5;
|
||||||
|
p += 4;
|
||||||
|
|
||||||
|
wend = w + 40;
|
||||||
|
for(; wp < wend; wp += 5){
|
||||||
|
x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16];
|
||||||
|
wp[0] = (x<<1) | (x>>31);
|
||||||
|
e += ((a<<5) | (a>>27)) + wp[0];
|
||||||
|
e += 0x6ed9eba1 + (b^c^d);
|
||||||
|
b = (b<<30)|(b>>2);
|
||||||
|
|
||||||
|
x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15];
|
||||||
|
wp[1] = (x<<1) | (x>>31);
|
||||||
|
d += ((e<<5) | (e>>27)) + wp[1];
|
||||||
|
d += 0x6ed9eba1 + (a^b^c);
|
||||||
|
a = (a<<30)|(a>>2);
|
||||||
|
|
||||||
|
x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14];
|
||||||
|
wp[2] = (x<<1) | (x>>31);
|
||||||
|
c += ((d<<5) | (d>>27)) + wp[2];
|
||||||
|
c += 0x6ed9eba1 + (e^a^b);
|
||||||
|
e = (e<<30)|(e>>2);
|
||||||
|
|
||||||
|
x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13];
|
||||||
|
wp[3] = (x<<1) | (x>>31);
|
||||||
|
b += ((c<<5) | (c>>27)) + wp[3];
|
||||||
|
b += 0x6ed9eba1 + (d^e^a);
|
||||||
|
d = (d<<30)|(d>>2);
|
||||||
|
|
||||||
|
x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12];
|
||||||
|
wp[4] = (x<<1) | (x>>31);
|
||||||
|
a += ((b<<5) | (b>>27)) + wp[4];
|
||||||
|
a += 0x6ed9eba1 + (c^d^e);
|
||||||
|
c = (c<<30)|(c>>2);
|
||||||
|
}
|
||||||
|
|
||||||
|
wend = w + 60;
|
||||||
|
for(; wp < wend; wp += 5){
|
||||||
|
x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16];
|
||||||
|
wp[0] = (x<<1) | (x>>31);
|
||||||
|
e += ((a<<5) | (a>>27)) + wp[0];
|
||||||
|
e += 0x8f1bbcdc + ((b&c)|((b|c)&d));
|
||||||
|
b = (b<<30)|(b>>2);
|
||||||
|
|
||||||
|
x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15];
|
||||||
|
wp[1] = (x<<1) | (x>>31);
|
||||||
|
d += ((e<<5) | (e>>27)) + wp[1];
|
||||||
|
d += 0x8f1bbcdc + ((a&b)|((a|b)&c));
|
||||||
|
a = (a<<30)|(a>>2);
|
||||||
|
|
||||||
|
x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14];
|
||||||
|
wp[2] = (x<<1) | (x>>31);
|
||||||
|
c += ((d<<5) | (d>>27)) + wp[2];
|
||||||
|
c += 0x8f1bbcdc + ((e&a)|((e|a)&b));
|
||||||
|
e = (e<<30)|(e>>2);
|
||||||
|
|
||||||
|
x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13];
|
||||||
|
wp[3] = (x<<1) | (x>>31);
|
||||||
|
b += ((c<<5) | (c>>27)) + wp[3];
|
||||||
|
b += 0x8f1bbcdc + ((d&e)|((d|e)&a));
|
||||||
|
d = (d<<30)|(d>>2);
|
||||||
|
|
||||||
|
x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12];
|
||||||
|
wp[4] = (x<<1) | (x>>31);
|
||||||
|
a += ((b<<5) | (b>>27)) + wp[4];
|
||||||
|
a += 0x8f1bbcdc + ((c&d)|((c|d)&e));
|
||||||
|
c = (c<<30)|(c>>2);
|
||||||
|
}
|
||||||
|
|
||||||
|
wend = w + 80;
|
||||||
|
for(; wp < wend; wp += 5){
|
||||||
|
x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16];
|
||||||
|
wp[0] = (x<<1) | (x>>31);
|
||||||
|
e += ((a<<5) | (a>>27)) + wp[0];
|
||||||
|
e += 0xca62c1d6 + (b^c^d);
|
||||||
|
b = (b<<30)|(b>>2);
|
||||||
|
|
||||||
|
x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15];
|
||||||
|
wp[1] = (x<<1) | (x>>31);
|
||||||
|
d += ((e<<5) | (e>>27)) + wp[1];
|
||||||
|
d += 0xca62c1d6 + (a^b^c);
|
||||||
|
a = (a<<30)|(a>>2);
|
||||||
|
|
||||||
|
x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14];
|
||||||
|
wp[2] = (x<<1) | (x>>31);
|
||||||
|
c += ((d<<5) | (d>>27)) + wp[2];
|
||||||
|
c += 0xca62c1d6 + (e^a^b);
|
||||||
|
e = (e<<30)|(e>>2);
|
||||||
|
|
||||||
|
x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13];
|
||||||
|
wp[3] = (x<<1) | (x>>31);
|
||||||
|
b += ((c<<5) | (c>>27)) + wp[3];
|
||||||
|
b += 0xca62c1d6 + (d^e^a);
|
||||||
|
d = (d<<30)|(d>>2);
|
||||||
|
|
||||||
|
x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12];
|
||||||
|
wp[4] = (x<<1) | (x>>31);
|
||||||
|
a += ((b<<5) | (b>>27)) + wp[4];
|
||||||
|
a += 0xca62c1d6 + (c^d^e);
|
||||||
|
c = (c<<30)|(c>>2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* save state */
|
||||||
|
s[0] += a;
|
||||||
|
s[1] += b;
|
||||||
|
s[2] += c;
|
||||||
|
s[3] += d;
|
||||||
|
s[4] += e;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
.globl tas
|
||||||
|
tas:
|
||||||
|
retl
|
||||||
|
ldstub [%o0], %o0
|
||||||
|
|
Loading…
Reference in New Issue