summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorforsyth <forsyth@vitanuova.com>2010-02-03 20:48:47 +0000
committerforsyth <forsyth@vitanuova.com>2010-02-03 20:48:47 +0000
commitf1dcfd03b4648fd6c0221d14436b391cd368beac (patch)
tree23466fba69e89b4ba065c150ac33a096f09e0b3f
parentad7de9e8db6963f4e715c21ee894011b62d0c984 (diff)
20100203-2048
-rw-r--r--CHANGES3
-rw-r--r--FreeBSD/386/include/lib9.h2
-rw-r--r--Irix/mips/include/lib9.h2
-rw-r--r--Linux/386/include/lib9.h2
-rw-r--r--Linux/arm/include/lib9.h2
-rw-r--r--Linux/power/include/lib9.h2
-rw-r--r--Linux/spim/include/lib9.h2
-rw-r--r--MacOSX/386/include/lib9.h2
-rw-r--r--MacOSX/power/include/lib9.h2
-rw-r--r--NetBSD/386/include/lib9.h2
-rwxr-xr-xNt/386/include/lib9.h2
-rw-r--r--OpenBSD/386/include/lib9.h2
-rw-r--r--include/libsec.h31
-rw-r--r--libinterp/keyring.c56
-rw-r--r--libinterp/keyring.h6
-rw-r--r--libinterp/runt.h52
-rw-r--r--module/keyring.m18
17 files changed, 179 insertions, 9 deletions
diff --git a/CHANGES b/CHANGES
index e2bd0103..bb5c8b35 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
20100203
appl/lib/cfg.b treat \r as white space (issue 69, 70)
+ add u64int to lib9.h files that needed it
+ add sha2.c sha256block.c sha512block.c to libsec/port and include/libsec.h
+ add new sha functions to module/keyring.m and libinterp/keyring.c
20100115
appl/cmd/tarfs.b man/4/tarfs changes to permission handling from mechiel [issue 220]
appl/spree/mkfile add explicit -I$ROOT/module [issue 209, powerman]
diff --git a/FreeBSD/386/include/lib9.h b/FreeBSD/386/include/lib9.h
index 07884bb3..882a13c5 100644
--- a/FreeBSD/386/include/lib9.h
+++ b/FreeBSD/386/include/lib9.h
@@ -43,6 +43,8 @@ typedef unsigned short Rune;
typedef long long int vlong;
typedef unsigned long long int uvlong;
typedef unsigned int u32int;
+typedef uvlong u64int;
+
typedef unsigned int mpdigit; /* for /sys/include/mp.h */
typedef unsigned short u16int;
typedef unsigned char u8int;
diff --git a/Irix/mips/include/lib9.h b/Irix/mips/include/lib9.h
index 8531eaa0..ca4916ec 100644
--- a/Irix/mips/include/lib9.h
+++ b/Irix/mips/include/lib9.h
@@ -29,6 +29,8 @@ typedef unsigned short Rune;
typedef long long int vlong;
typedef unsigned long long int uvlong;
typedef unsigned int u32int;
+typedef uvlong u64int;
+
typedef unsigned int mpdigit; /* for /sys/include/mp.h */
typedef unsigned short u16int;
typedef unsigned char u8int;
diff --git a/Linux/386/include/lib9.h b/Linux/386/include/lib9.h
index 0dd37be1..85187272 100644
--- a/Linux/386/include/lib9.h
+++ b/Linux/386/include/lib9.h
@@ -41,6 +41,8 @@ typedef unsigned short Rune;
typedef long long int vlong;
typedef unsigned long long int uvlong;
typedef unsigned int u32int;
+typedef uvlong u64int;
+
typedef unsigned int mpdigit; /* for /sys/include/mp.h */
typedef unsigned short u16int;
typedef unsigned char u8int;
diff --git a/Linux/arm/include/lib9.h b/Linux/arm/include/lib9.h
index da2c5d97..6f4f660a 100644
--- a/Linux/arm/include/lib9.h
+++ b/Linux/arm/include/lib9.h
@@ -41,6 +41,8 @@ typedef unsigned short Rune;
typedef long long int vlong;
typedef unsigned long long int uvlong;
typedef unsigned int u32int;
+typedef uvlong u64int;
+
typedef unsigned int mpdigit; /* for /sys/include/mp.h */
typedef unsigned short u16int;
typedef unsigned char u8int;
diff --git a/Linux/power/include/lib9.h b/Linux/power/include/lib9.h
index c48ac7a6..51b80b30 100644
--- a/Linux/power/include/lib9.h
+++ b/Linux/power/include/lib9.h
@@ -42,6 +42,8 @@ typedef unsigned short Rune;
typedef long long int vlong;
typedef unsigned long long int uvlong;
typedef unsigned int u32int;
+typedef uvlong u64int;
+
typedef unsigned int mpdigit; /* for /sys/include/mp.h */
typedef unsigned short u16int;
typedef unsigned char u8int;
diff --git a/Linux/spim/include/lib9.h b/Linux/spim/include/lib9.h
index 06b7a2be..f443d31b 100644
--- a/Linux/spim/include/lib9.h
+++ b/Linux/spim/include/lib9.h
@@ -46,6 +46,8 @@ typedef unsigned short Rune;
typedef long long int vlong;
typedef unsigned long long int uvlong;
typedef unsigned int u32int;
+typedef uvlong u64int;
+
typedef unsigned int mpdigit; /* for /sys/include/mp.h */
typedef unsigned short u16int;
typedef unsigned char u8int;
diff --git a/MacOSX/386/include/lib9.h b/MacOSX/386/include/lib9.h
index 841da466..9b67537b 100644
--- a/MacOSX/386/include/lib9.h
+++ b/MacOSX/386/include/lib9.h
@@ -36,6 +36,8 @@ typedef long long vlong;
typedef unsigned long long uvlong;
typedef ushort Rune;
typedef unsigned int u32int;
+typedef uvlong u64int;
+
typedef unsigned int mpdigit; /* for /sys/include/mp.h */
typedef unsigned short u16int;
typedef unsigned char u8int;
diff --git a/MacOSX/power/include/lib9.h b/MacOSX/power/include/lib9.h
index 7258d910..96c4b960 100644
--- a/MacOSX/power/include/lib9.h
+++ b/MacOSX/power/include/lib9.h
@@ -36,6 +36,8 @@ typedef long long vlong;
typedef unsigned long long uvlong;
typedef ushort Rune;
typedef unsigned int u32int;
+typedef uvlong u64int;
+
typedef unsigned int mpdigit; /* for /sys/include/mp.h */
typedef unsigned short u16int;
typedef unsigned char u8int;
diff --git a/NetBSD/386/include/lib9.h b/NetBSD/386/include/lib9.h
index 43426125..d50258bf 100644
--- a/NetBSD/386/include/lib9.h
+++ b/NetBSD/386/include/lib9.h
@@ -45,6 +45,8 @@ typedef uint64_t uvlong;
typedef uint8_t u8int;
typedef uint16_t u16int;
typedef uint32_t u32int;
+typedef uvlong u64int;
+
typedef uintptr_t uintptr;
typedef unsigned short Rune;
diff --git a/Nt/386/include/lib9.h b/Nt/386/include/lib9.h
index d45f226c..c726f21e 100755
--- a/Nt/386/include/lib9.h
+++ b/Nt/386/include/lib9.h
@@ -49,6 +49,8 @@ typedef unsigned short Rune;
typedef __int64 vlong;
typedef unsigned __int64 uvlong;
typedef unsigned int u32int;
+typedef uvlong u64int;
+
typedef unsigned int mpdigit; /* for /sys/include/mp.h */
typedef unsigned short u16int;
typedef unsigned char u8int;
diff --git a/OpenBSD/386/include/lib9.h b/OpenBSD/386/include/lib9.h
index f5780dbe..a32d2769 100644
--- a/OpenBSD/386/include/lib9.h
+++ b/OpenBSD/386/include/lib9.h
@@ -43,6 +43,8 @@ typedef unsigned short Rune;
typedef long long int vlong;
typedef unsigned long long int uvlong;
typedef unsigned int u32int;
+typedef uvlong u64int;
+
typedef unsigned int mpdigit; /* for /sys/include/mp.h */
typedef unsigned short u16int;
typedef unsigned char u8int;
diff --git a/include/libsec.h b/include/libsec.h
index 99f4b786..25e977f0 100644
--- a/include/libsec.h
+++ b/include/libsec.h
@@ -138,18 +138,33 @@ void idea_cipher(ushort*, uchar*, int);
enum
{
- SHA1dlen= 20, /* SHA digest length */
- MD4dlen= 16, /* MD4 digest length */
- MD5dlen= 16 /* MD5 digest length */
+ /* digest lengths */
+ SHA1dlen= 20,
+ MD4dlen= 16,
+ MD5dlen= 16,
+
+ SHA224dlen= 28,
+ SHA256dlen= 32,
+
+ SHA384dlen= 48,
+ SHA512dlen= 64,
+
+ /* block sizes */
+ SHA256bsize= 64,
+ SHA512bsize= 128,
+ Digestbsize= 128, /* maximum */
};
typedef struct DigestState DigestState;
struct DigestState
{
- uvlong len;
+ u64int len;
u32int state[5];
- uchar buf[128];
+ uchar buf[Digestbsize];
int blen;
+ u64int nb128[2];
+ u64int h64[8];
+ u32int h32[8];
char malloced;
char seeded;
};
@@ -157,10 +172,16 @@ typedef struct DigestState SHAstate; /* obsolete name */
typedef struct DigestState SHA1state;
typedef struct DigestState MD5state;
typedef struct DigestState MD4state;
+typedef struct DigestState SHA256state;
+typedef struct DigestState SHA512state;
DigestState* md4(uchar*, ulong, uchar*, DigestState*);
DigestState* md5(uchar*, ulong, uchar*, DigestState*);
DigestState* sha1(uchar*, ulong, uchar*, DigestState*);
+DigestState* sha224(uchar*, ulong, uchar*, DigestState*);
+DigestState* sha256(uchar*, ulong, uchar*, DigestState*);
+DigestState* sha384(uchar*, ulong, uchar*, DigestState*);
+DigestState* sha512(uchar*, ulong, uchar*, DigestState*);
DigestState* hmac_md5(uchar*, ulong, uchar*, ulong, uchar*, DigestState*);
DigestState* hmac_sha1(uchar*, ulong, uchar*, ulong, uchar*, DigestState*);
char* md5pickle(MD5state*);
diff --git a/libinterp/keyring.c b/libinterp/keyring.c
index 56971cf4..7bc5b5d3 100644
--- a/libinterp/keyring.c
+++ b/libinterp/keyring.c
@@ -1263,6 +1263,62 @@ Keyring_sha1(void *fp)
}
void
+Keyring_sha224(void *fp)
+{
+ F_Keyring_sha224 *f;
+ void *r;
+
+ f = fp;
+ r = *f->ret;
+ *f->ret = H;
+ destroy(r);
+
+ *f->ret = keyring_digest_x(f->buf, f->n, f->digest, SHA224dlen, f->state, sha224);
+}
+
+void
+Keyring_sha256(void *fp)
+{
+ F_Keyring_sha256 *f;
+ void *r;
+
+ f = fp;
+ r = *f->ret;
+ *f->ret = H;
+ destroy(r);
+
+ *f->ret = keyring_digest_x(f->buf, f->n, f->digest, SHA256dlen, f->state, sha256);
+}
+
+void
+Keyring_sha384(void *fp)
+{
+ F_Keyring_sha384 *f;
+ void *r;
+
+ f = fp;
+ r = *f->ret;
+ *f->ret = H;
+ destroy(r);
+
+ *f->ret = keyring_digest_x(f->buf, f->n, f->digest, SHA384dlen, f->state, sha384);
+}
+
+void
+Keyring_sha512(void *fp)
+{
+ F_Keyring_sha512 *f;
+ void *r;
+
+ f = fp;
+ r = *f->ret;
+ *f->ret = H;
+ destroy(r);
+
+ *f->ret = keyring_digest_x(f->buf, f->n, f->digest, SHA512dlen, f->state, sha512);
+}
+
+void
Keyring_md5(void *fp)
{
F_Keyring_md5 *f;
diff --git a/libinterp/keyring.h b/libinterp/keyring.h
index 0aa4185a..f5ea7a1c 100644
--- a/libinterp/keyring.h
+++ b/libinterp/keyring.h
@@ -68,6 +68,10 @@ Runtab Keyringmodtab[]={
"senderrmsg",0xd2526222,Keyring_senderrmsg,40,2,{0x0,0xc0,},
"sendmsg",0x7cfef557,Keyring_sendmsg,48,2,{0x0,0xc0,},
"sha1",0x7656377,Keyring_sha1,48,2,{0x0,0xb0,},
+ "sha224",0x7656377,Keyring_sha224,48,2,{0x0,0xb0,},
+ "sha256",0x7656377,Keyring_sha256,48,2,{0x0,0xb0,},
+ "sha384",0x7656377,Keyring_sha384,48,2,{0x0,0xb0,},
+ "sha512",0x7656377,Keyring_sha512,48,2,{0x0,0xb0,},
"IPint.shl",0xc7b0bc01,IPint_shl,40,2,{0x0,0x80,},
"IPint.shr",0xc7b0bc01,IPint_shr,40,2,{0x0,0x80,},
"sign",0xdacb7a7e,Keyring_sign,48,2,{0x0,0xb0,},
@@ -92,4 +96,4 @@ Runtab Keyringmodtab[]={
"IPint.xor",0xa47c1b24,IPint_xor,40,2,{0x0,0xc0,},
0
};
-#define Keyringmodlen 90
+#define Keyringmodlen 94
diff --git a/libinterp/runt.h b/libinterp/runt.h
index 75144e0c..1ed6a493 100644
--- a/libinterp/runt.h
+++ b/libinterp/runt.h
@@ -3830,6 +3830,54 @@ struct F_Keyring_sha1
Array* digest;
Keyring_DigestState* state;
};
+void Keyring_sha224(void*);
+typedef struct F_Keyring_sha224 F_Keyring_sha224;
+struct F_Keyring_sha224
+{
+ WORD regs[NREG-1];
+ Keyring_DigestState** ret;
+ uchar temps[12];
+ Array* buf;
+ WORD n;
+ Array* digest;
+ Keyring_DigestState* state;
+};
+void Keyring_sha256(void*);
+typedef struct F_Keyring_sha256 F_Keyring_sha256;
+struct F_Keyring_sha256
+{
+ WORD regs[NREG-1];
+ Keyring_DigestState** ret;
+ uchar temps[12];
+ Array* buf;
+ WORD n;
+ Array* digest;
+ Keyring_DigestState* state;
+};
+void Keyring_sha384(void*);
+typedef struct F_Keyring_sha384 F_Keyring_sha384;
+struct F_Keyring_sha384
+{
+ WORD regs[NREG-1];
+ Keyring_DigestState** ret;
+ uchar temps[12];
+ Array* buf;
+ WORD n;
+ Array* digest;
+ Keyring_DigestState* state;
+};
+void Keyring_sha512(void*);
+typedef struct F_Keyring_sha512 F_Keyring_sha512;
+struct F_Keyring_sha512
+{
+ WORD regs[NREG-1];
+ Keyring_DigestState** ret;
+ uchar temps[12];
+ Array* buf;
+ WORD n;
+ Array* digest;
+ Keyring_DigestState* state;
+};
void IPint_shl(void*);
typedef struct F_IPint_shl F_IPint_shl;
struct F_IPint_shl
@@ -4054,6 +4102,10 @@ struct F_IPint_xor
};
#define Keyring_PATH "$Keyring"
#define Keyring_SHA1dlen 20
+#define Keyring_SHA224dlen 28
+#define Keyring_SHA256dlen 32
+#define Keyring_SHA384dlen 48
+#define Keyring_SHA512dlen 64
#define Keyring_MD5dlen 16
#define Keyring_MD4dlen 16
#define Keyring_Encrypt 0
diff --git a/module/keyring.m b/module/keyring.m
index 7bba0f1c..c729de27 100644
--- a/module/keyring.m
+++ b/module/keyring.m
@@ -175,19 +175,31 @@ Keyring: module
sktopk: fn (sk: ref SK): ref PK;
# digests
- sha1: fn(buf: array of byte, n: int, digest: array of byte, state: ref DigestState):
- ref DigestState;
md4: fn(buf: array of byte, n: int, digest: array of byte, state: ref DigestState):
ref DigestState;
md5: fn(buf: array of byte, n: int, digest: array of byte, state: ref DigestState):
ref DigestState;
+ sha1: fn(buf: array of byte, n: int, digest: array of byte, state: ref DigestState):
+ ref DigestState;
+ sha224: fn(buf: array of byte, n: int, digest: array of byte, state: ref DigestState):
+ ref DigestState;
+ sha256: fn(buf: array of byte, n: int, digest: array of byte, state: ref DigestState):
+ ref DigestState;
+ sha384: fn(buf: array of byte, n: int, digest: array of byte, state: ref DigestState):
+ ref DigestState;
+ sha512: fn(buf: array of byte, n: int, digest: array of byte, state: ref DigestState):
+ ref DigestState;
hmac_sha1: fn(data: array of byte, n: int, key: array of byte, digest: array of byte, state: ref DigestState):
ref DigestState;
hmac_md5: fn(data: array of byte, n: int, key: array of byte, digest: array of byte, state: ref DigestState):
ref DigestState;
- SHA1dlen: con 20;
+ SHA1dlen: con 20;
+ SHA224dlen: con 28;
+ SHA256dlen: con 32;
+ SHA384dlen: con 48;
+ SHA512dlen: con 64;
MD5dlen: con 16;
MD4dlen: con 16;