Small tweaks

Lots of new code imported.
This commit is contained in:
rsc 2004-03-21 04:33:13 +00:00
parent a770daa795
commit 2277c5d7bb
86 changed files with 12444 additions and 91 deletions

View file

@ -43,7 +43,7 @@ static const u32 Td3[256];
static const u8 Te4[256];
static int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
// static int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
static int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
static int rijndaelKeySetup(u32 erk[/*4*(Nr + 1)*/], u32 drk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
static void rijndaelEncrypt(const u32int rk[], int Nr, const uchar pt[16], uchar ct[16]);
static void rijndaelDecrypt(const u32int rk[], int Nr, const uchar ct[16], uchar pt[16]);
@ -950,7 +950,6 @@ static int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int
return 0;
}
#if 0
/**
* Expand the cipher key into the decryption key schedule.
*
@ -995,7 +994,6 @@ static int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int
}
return Nr;
}
#endif
static void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]) {
u32 s0, s1, s2, s3, t0, t1, t2, t3;

View file

@ -1,4 +1,5 @@
#include "os.h"
#include <mp.h>
#include <libsec.h>
typedef struct State{

View file

@ -5,14 +5,55 @@ LIB=libsec.a
OFILES=\
aes.$O\
blowfish.$O\
decodepem.$O\
des.$O\
des3CBC.$O\
des3ECB.$O\
desCBC.$O\
desECB.$O\
desmodes.$O\
dsaalloc.$O\
dsagen.$O\
dsaprimes.$O\
dsaprivtopub.$O\
dsasign.$O\
dsaverify.$O\
egalloc.$O\
egdecrypt.$O\
egencrypt.$O\
eggen.$O\
egprivtopub.$O\
egsign.$O\
egverify.$O\
fastrand.$O\
genprime.$O\
genrandom.$O\
gensafeprime.$O\
genstrongprime.$O\
hmac.$O\
md4.$O\
md5.$O\
md5block.$O\
md5pickle.$O\
nfastrand.$O\
prng.$O\
probably_prime.$O\
rc4.$O\
readcert.$O\
rsaalloc.$O\
rsadecrypt.$O\
rsaencrypt.$O\
rsafill.$O\
rsagen.$O\
rsaprivtopub.$O\
sha1.$O\
sha1block.$O\
sha1pickle.$O\
smallprimetest.$O\
thumb.$O\
tlshand.$O\
x509.$O\
HFILES=$PLAN9/include/libsec.h

View file

@ -1,5 +1,4 @@
#include <u.h>
#include <libc.h>
#include "os.h"
#include <libsec.h>
static void encode(uchar*, u32int*, ulong);
@ -11,8 +10,6 @@ extern void _sha1block(uchar*, ulong, u32int*);
* the last call. There must be room in the input buffer
* to pad.
*/
ulong lastlen;
SHA1state*
sha1(uchar *p, ulong len, uchar *digest, SHA1state *s)
{
@ -21,15 +18,12 @@ sha1(uchar *p, ulong len, uchar *digest, SHA1state *s)
int i;
uchar *e;
lastlen = len;
if(s == nil){
s = malloc(sizeof(*s));
if(s == nil)
return nil;
memset(s, 0, sizeof(*s));
s->malloced = 1;
assert(!s->seeded);
assert(!s->blen);
}
if(s->seeded == 0){
@ -42,11 +36,8 @@ lastlen = len;
s->seeded = 1;
}
assert(len < 100000);
/* fill out the partial 64 byte block from previous calls */
if(s->blen){
assert(s);
i = 64 - s->blen;
if(len < i)
i = len;
@ -61,11 +52,9 @@ assert(s);
}
}
assert(len < 1000000);
/* do 64 byte blocks */
i = len & ~0x3f;
if(i){
assert(i < 1000000);
_sha1block(p, i, s->state);
s->len += i;
len -= i;

View file

@ -1,10 +1,4 @@
#include <u.h>
#include <libc.h>
uchar* lastsbp;
ulong lastsblen;
u32int* lastsbs;
Lock slock;
#include "os.h"
void
_sha1block(uchar *p, ulong len, u32int *s)
@ -14,11 +8,6 @@ _sha1block(uchar *p, ulong len, u32int *s)
u32int *wp, *wend;
u32int w[80];
lock(&slock);
lastsbp=p;
lastsblen=len;
lastsbs=s;
/* at this point, we have a multiple of 64 bytes */
for(end = p+len; p < end;){
a = s[0];
@ -195,5 +184,4 @@ lastsbs=s;
s[3] += d;
s[4] += e;
}
unlock(&slock);
}