libsec: remove aesCTRencrypt()/aesCTRdecrypt() (thanks mischief and qrstuv)
as mischief and qrstuv point out, these functions are not very usefull and are even implemented wrong (incrementCTR()), so deleting the code.
This commit is contained in:
parent
e9c9ea4235
commit
12bb7bcfff
3 changed files with 1 additions and 72 deletions
|
@ -23,7 +23,6 @@ struct AESstate
|
|||
ulong setup;
|
||||
int rounds;
|
||||
int keybytes;
|
||||
uint ctrsz;
|
||||
uchar key[AESmaxkey]; /* unexpanded key */
|
||||
ulong ekey[4*(AESmaxrounds + 1)]; /* encryption key */
|
||||
ulong dkey[4*(AESmaxrounds + 1)]; /* decryption key */
|
||||
|
@ -38,8 +37,6 @@ void aes_decrypt(ulong rk[], int Nr, uchar ct[16], uchar pt[16]);
|
|||
void setupAESstate(AESstate *s, uchar key[], int keybytes, uchar *ivec);
|
||||
void aesCBCencrypt(uchar *p, int len, AESstate *s);
|
||||
void aesCBCdecrypt(uchar *p, int len, AESstate *s);
|
||||
void aesCTRdecrypt(uchar *p, int len, AESstate *s);
|
||||
void aesCTRencrypt(uchar *p, int len, AESstate *s);
|
||||
|
||||
void setupAESXCBCstate(AESstate *s);
|
||||
uchar* aesXCBCmac(uchar *p, int len, AESstate *s);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.TH AES 2
|
||||
.SH NAME
|
||||
setupAESstate, aesCBCencrypt, aesCBCdecrypt, aesCTRencrypt, aesCTRdecrypt, setupAESXCBCstate, aesXCBCmac - advanced encryption standard (rijndael)
|
||||
setupAESstate, aesCBCencrypt, aesCBCdecrypt, setupAESXCBCstate, aesXCBCmac - advanced encryption standard (rijndael)
|
||||
.SH SYNOPSIS
|
||||
.B #include <u.h>
|
||||
.br
|
||||
|
@ -28,12 +28,6 @@ void aesCBCencrypt(uchar *p, int len, AESstate *s)
|
|||
void aesCBCdecrypt(uchar *p, int len, AESstate *s)
|
||||
.PP
|
||||
.B
|
||||
void aesCTRencrypt(uchar *p, int len, AESstate *s)
|
||||
.PP
|
||||
.B
|
||||
void aesCTRdecrypt(uchar *p, int len, AESstate *s)
|
||||
.PP
|
||||
.B
|
||||
void setupAESXCBCstate(AESstate *s)
|
||||
.PP
|
||||
.B
|
||||
|
@ -52,11 +46,6 @@ are the block ciphers, corresponding to
|
|||
and
|
||||
.I aesCBCdecrypt
|
||||
implement cipher-block-chaining encryption.
|
||||
.I AesCTRencrypt
|
||||
and
|
||||
.I aesCTRdecrypt
|
||||
implement counter mode, per RFC 3686;
|
||||
they are identical operations.
|
||||
.I setupAESXCBCstate
|
||||
and
|
||||
.I aesXCBCmac
|
||||
|
@ -93,8 +82,6 @@ in
|
|||
The functions
|
||||
.IR aes_encrypt ,
|
||||
.IR aes_decrypt ,
|
||||
.IR aesCTRencrypt ,
|
||||
.IR aesCTRdecrypt ,
|
||||
.IR setupAESXCBCstate ,
|
||||
and
|
||||
.IR aesXCBCmac
|
||||
|
|
|
@ -220,61 +220,6 @@ aesCBCdecrypt(uchar *p, int len, AESstate *s)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* AES-CTR mode, per rfc3686.
|
||||
* CTRs could be precalculated for efficiency
|
||||
* and there would also be less back and forth mp
|
||||
*/
|
||||
|
||||
static void
|
||||
incrementCTR(uchar *p, uint ctrsz)
|
||||
{
|
||||
int len;
|
||||
uchar *ctr;
|
||||
mpint *mpctr, *mpctrsz;
|
||||
|
||||
ctr = p + AESbsize - ctrsz;
|
||||
mpctr = betomp(ctr, ctrsz, nil);
|
||||
mpctrsz = itomp(1 << (ctrsz*8), nil);
|
||||
mpadd(mpctr, mpone, mpctr);
|
||||
mpmod(mpctr, mpctrsz, mpctr);
|
||||
len = mptobe(mpctr, ctr, ctrsz, nil);
|
||||
assert(len == ctrsz);
|
||||
mpfree(mpctrsz);
|
||||
mpfree(mpctr);
|
||||
}
|
||||
|
||||
void
|
||||
aesCTRencrypt(uchar *p, int len, AESstate *s)
|
||||
{
|
||||
uchar q[AESbsize];
|
||||
uchar *ip, *eip, *ctr;
|
||||
|
||||
ctr = s->ivec;
|
||||
for(; len >= AESbsize; len -= AESbsize){
|
||||
ip = q;
|
||||
aes_encrypt(s->ekey, s->rounds, ctr, q);
|
||||
for(eip = p + AESbsize; p < eip; )
|
||||
*p++ ^= *ip++;
|
||||
incrementCTR(ctr, s->ctrsz);
|
||||
}
|
||||
|
||||
if(len > 0){
|
||||
ip = q;
|
||||
aes_encrypt(s->ekey, s->rounds, ctr, q);
|
||||
for(eip = p + len; p < eip; )
|
||||
*p++ ^= *ip++;
|
||||
incrementCTR(ctr, s->ctrsz);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
aesCTRdecrypt(uchar *p, int len, AESstate *s)
|
||||
{
|
||||
aesCTRencrypt(p, len, s);
|
||||
}
|
||||
|
||||
|
||||
/* taken from sha1; TODO: verify suitability (esp. byte order) for aes */
|
||||
/*
|
||||
* encodes input (ulong) into output (uchar). Assumes len is
|
||||
|
|
Loading…
Reference in a new issue