ref: 8e3ca2b766e47e3e72587ade1767a565591cf7d2
parent: b66b8d010388d89994a5dea80d3bde4df039ec6a
author: 9ferno <[email protected]>
date: Wed Oct 20 08:02:54 EDT 2021
fixed compilation errors
--- a/include/libsec.h
+++ b/include/libsec.h
@@ -46,16 +46,12 @@
void aes_xts_encrypt(AESstate *tweak, AESstate *ecb, uvlong sectorNumber, uchar *input, uchar *output, u32 len);
void aes_xts_decrypt(AESstate *tweak, AESstate *ecb, uvlong sectorNumber, uchar *input, uchar *output, u32 len);
-#ifdef H
-#undef H;
-#endif
-
typedef struct AESGCMstate AESGCMstate;
struct AESGCMstate
{
AESstate;
- u32 H[4];
+ u32 varH[4]; /* renamed H to varH to avoid collision with the H macro used by inferno */
u32 M[16][256][4];
};
--- a/libinterp/crypt.c
+++ b/libinterp/crypt.c
@@ -251,7 +251,7 @@
*f->ret = H;
destroy(r);
- *f->ret = crypt_digest_x(f->buf, f->n, f->digest, SHA224dlen, f->state, sha224);
+ *f->ret = crypt_digest_x(f->buf, f->n, f->digest, SHA2_224dlen, f->state, sha2_224);
}
void
@@ -265,7 +265,7 @@
*f->ret = H;
destroy(r);
- *f->ret = crypt_digest_x(f->buf, f->n, f->digest, SHA256dlen, f->state, sha256);
+ *f->ret = crypt_digest_x(f->buf, f->n, f->digest, SHA2_256dlen, f->state, sha2_256);
}
void
@@ -279,7 +279,7 @@
*f->ret = H;
destroy(r);
- *f->ret = crypt_digest_x(f->buf, f->n, f->digest, SHA384dlen, f->state, sha384);
+ *f->ret = crypt_digest_x(f->buf, f->n, f->digest, SHA2_384dlen, f->state, sha2_384);
}
void
@@ -293,7 +293,7 @@
*f->ret = H;
destroy(r);
- *f->ret = crypt_digest_x(f->buf, f->n, f->digest, SHA512dlen, f->state, sha512);
+ *f->ret = crypt_digest_x(f->buf, f->n, f->digest, SHA2_512dlen, f->state, sha2_512);
}
void
--- a/libinterp/ipint.c
+++ b/libinterp/ipint.c
@@ -582,90 +582,6 @@
*f->ret = newIPint(ret);
}
-static void
-mpand(mpint *b, mpint *m, mpint *res)
-{
- int i;
-
- res->sign = b->sign;
- if(b->top == 0 || m->top == 0){
- res->top = 0;
- return;
- }
- mpbits(res, b->top*Dbits);
- res->top = b->top;
- for(i = b->top; --i >= 0;){
- if(i < m->top)
- res->p[i] = b->p[i] & m->p[i];
- else
- res->p[i] = 0;
- }
- mpnorm(res);
-}
-
-static void
-mpor(mpint *b1, mpint *b2, mpint *res)
-{
- mpint *t;
- int i;
-
- if(b2->top > b1->top){
- t = b1;
- b1 = b2;
- b2 = t;
- }
- if(b1->top == 0){
- mpassign(b2, res);
- return;
- }
- if(b2->top == 0){
- mpassign(b1, res);
- return;
- }
- mpassign(b1, res);
- for(i = b2->top; --i >= 0;)
- res->p[i] |= b2->p[i];
- mpnorm(res);
-}
-
-static void
-mpxor(mpint *b1, mpint *b2, mpint *res)
-{
- mpint *t;
- int i;
-
- if(b2->top > b1->top){
- t = b1;
- b1 = b2;
- b2 = t;
- }
- if(b1->top == 0){
- mpassign(b2, res);
- return;
- }
- if(b2->top == 0){
- mpassign(b1, res);
- return;
- }
- mpassign(b1, res);
- for(i = b2->top; --i >= 0;)
- res->p[i] ^= b2->p[i];
- mpnorm(res);
-}
-
-static void
-mpnot(mpint *b1, mpint *res)
-{
- int i;
-
- mpbits(res, Dbits*b1->top);
- res->sign = 1;
- res->top = b1->top;
- for(i = res->top; --i >= 0;)
- res->p[i] = ~b1->p[i];
- mpnorm(res);
-}
-
/* bits */
void
IPint_and(void *fp)
--- a/libinterp/keyring.c
+++ b/libinterp/keyring.c
@@ -1272,7 +1272,7 @@
*f->ret = H;
destroy(r);
- *f->ret = keyring_digest_x(f->buf, f->n, f->digest, SHA224dlen, f->state, sha224);
+ *f->ret = keyring_digest_x(f->buf, f->n, f->digest, SHA2_224dlen, f->state, sha2_224);
}
void
@@ -1286,7 +1286,7 @@
*f->ret = H;
destroy(r);
- *f->ret = keyring_digest_x(f->buf, f->n, f->digest, SHA256dlen, f->state, sha256);
+ *f->ret = keyring_digest_x(f->buf, f->n, f->digest, SHA2_256dlen, f->state, sha2_256);
}
void
@@ -1300,7 +1300,7 @@
*f->ret = H;
destroy(r);
- *f->ret = keyring_digest_x(f->buf, f->n, f->digest, SHA384dlen, f->state, sha384);
+ *f->ret = keyring_digest_x(f->buf, f->n, f->digest, SHA2_384dlen, f->state, sha2_384);
}
void
@@ -1314,7 +1314,7 @@
*f->ret = H;
destroy(r);
- *f->ret = keyring_digest_x(f->buf, f->n, f->digest, SHA512dlen, f->state, sha512);
+ *f->ret = keyring_digest_x(f->buf, f->n, f->digest, SHA2_512dlen, f->state, sha2_512);
}
void
--- a/libsec/port/aes_gcm.c
+++ b/libsec/port/aes_gcm.c
@@ -60,7 +60,7 @@
X[0] ^= Y[0], X[1] ^= Y[1], X[2] ^= Y[2], X[3] ^= Y[3];
if(0){
- gfmul(X, s->H, Y);
+ gfmul(X, s->varH, Y);
return;
}
@@ -152,9 +152,9 @@
memset(s->ivec, 0, AESbsize);
aes_encrypt(s->ekey, s->rounds, s->ivec, s->ivec);
- load128(s->ivec, s->H);
+ load128(s->ivec, s->varH);
memset(s->ivec, 0, AESbsize);
- prepareM(s->H, s->M);
+ prepareM(s->varH, s->M);
if(iv != nil && ivlen > 0)
aesgcm_setiv(s, iv, ivlen);
--- a/libsec/port/genrandom.c
+++ b/libsec/port/genrandom.c
@@ -1,7 +1,7 @@
#include "os.h"
#include <libsec.h>
-extern u32 getpid(void);
+extern s32 getpid(void);
static void
init(Chachastate *cs)
--- a/libsec/port/mkfile
+++ b/libsec/port/mkfile
@@ -2,6 +2,8 @@
LIB=libsec.a
+# TODO get rid of the idea.c usage
+# It is used by devssl
CFILES = des.c desmodes.c desECB.c desCBC.c des3ECB.c des3CBC.c\
aes.c aesni.c aesCBC.c aesCFB.c aesOFB.c aes_gcm.c \
blowfish.c \
@@ -35,6 +37,7 @@
secp256r1.c\
secp384r1.c\
secp256k1.c\
+ idea.c\
ALLOFILES=${CFILES:%.c=%.$O}
--- a/os/port/portdat.h
+++ b/os/port/portdat.h
@@ -494,7 +494,7 @@
s32 swipend; /* software interrupt pending for Prog */
Lock sysio; /* note handler lock */
char* psstate; /* What /proc/#/status reports */
- u32 pid;
+ s32 pid;
s32 procctl; /* Control for /proc debugging */
uintptr pc; /* DEBUG only */
Lock rlock; /* sync between sleep/swiproc for r */
--- a/os/port/proc.c
+++ b/os/port/proc.c
@@ -828,7 +828,7 @@
return r;
}
-u32
+s32
getpid(void)
{
return up->pid;