Merge and close elliptic curve branch.
authormdw <mdw>
Sun, 21 Mar 2004 22:52:06 +0000 (22:52 +0000)
committermdw <mdw>
Sun, 21 Mar 2004 22:52:06 +0000 (22:52 +0000)
60 files changed:
.cvsignore
BRANCHES
Makefile.m4
buf.c [new file with mode: 0644]
buf.h [new file with mode: 0644]
calc/ec2.cal
calc/ecp.cal
calc/gfx.cal
configure.in
debian/.cvsignore [new file with mode: 0644]
debian/catacomb-bin.config [new file with mode: 0644]
debian/catacomb-bin.postinst [new file with mode: 0644]
debian/catacomb-bin.prerm [new file with mode: 0644]
debian/catacomb-bin.templates [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/rules [new file with mode: 0755]
ec-bin.c
ec-exp.h
ec-prime.c
ec.c
ec.h
exp.h
f-binpoly.c
f-prime.c
field.c
field.h
gf-arith.c
gf-gcd.c
gf.h
gfreduce-exp.h
gfreduce.c
gfreduce.h
gfx-sqr.c
gfx.h
hash.h
key-io.c
keyutil.c
mp-arith.c
mp-gcd.c
mpalloc.h [deleted file]
mpbarrett-exp.h
mpmont-exp.h
pixie.c
sha224.c [new file with mode: 0644]
sha224.h [new file with mode: 0644]
sha256.c
sha256.h
tests/gf
tests/gfreduce
tests/gfx
tests/mp
tests/rmd128
tests/rmd160
tests/sha
tests/sha224 [new file with mode: 0644]
tests/sha256
tests/sha384
tests/sha512

index b0f0f68..8eae633 100644 (file)
@@ -279,4 +279,9 @@ xtea-ecb.c
 xtea-ecb.h
 xtea-ofb.c
 xtea-ofb.h
+sha224-hmac.c
+sha224-hmac.h
+sha224-mgf.c
+sha224-mgf.h
 junk
+deb-build
index 2f32e82..5310815 100644 (file)
--- a/BRANCHES
+++ b/BRANCHES
@@ -5,4 +5,4 @@ For a branch FOO, we have:
        FOO-merge-N     Nth branch merge point
 
 `ec' -- elliptic curve work
-       No merges
+       ec-merge-1      Closed.
index 4a95044..9be48d5 100644 (file)
@@ -1,6 +1,6 @@
-## -*-makefile-*-
+## -*-m4-*-
 ##
-## $Id: Makefile.m4,v 1.60.2.2 2004/03/21 22:39:46 mdw Exp $
+## $Id: Makefile.m4,v 1.67 2004/03/21 22:52:06 mdw Exp $
 ##
 ## Makefile for Catacomb
 ##
 ##----- Revision history ----------------------------------------------------
 ##
 ## $Log: Makefile.m4,v $
-## Revision 1.60.2.2  2004/03/21 22:39:46  mdw
-## Elliptic curves on binary fields work.
+## Revision 1.67  2004/03/21 22:52:06  mdw
+## Merge and close elliptic curve branch.
 ##
-## Revision 1.60.2.1  2003/06/10 13:43:53  mdw
-## Simple (non-projective) curves over prime fields now seem to work.
+##   Revision 1.60.2.2  2004/03/21 22:39:46  mdw
+##   Elliptic curves on binary fields work.
+##
+##   Revision 1.60.2.1  2003/06/10 13:43:53  mdw
+##   Simple (non-projective) curves over prime fields now seem to work.
+##
+## Revision 1.66  2004/03/21 22:43:50  mdw
+## New hash variant SHA224.
+##
+## Revision 1.65  2003/11/29 23:39:36  mdw
+## Debianization.
+##
+## Revision 1.64  2003/11/10 22:18:30  mdw
+## Build fixes.
+##
+## Revision 1.63  2003/10/17 16:30:46  mdw
+## Report errors if key files don't exist!
+##
+## Revision 1.62  2003/10/12 15:02:09  mdw
+## Reliability fixes.
+##
+## Revision 1.61  2003/10/11 21:02:33  mdw
+## Import buf stuff from tripe.
 ##
 ## Revision 1.60  2003/05/16 01:12:37  mdw
 ## Ship `rc2-tab.h' and `skipjack-tab.h'.
@@ -260,7 +281,7 @@ define(`cipher_modes', `_(ecb) _(cbc) _(cfb) _(ofb) _(counter)')
 
 define(`hashes', `dnl
 _(md5) _(md4) _(md2) _(tiger) dnl
-_(sha) _(sha256) _(sha384) _(sha512) dnl
+_(sha) _(sha224) _(sha256) _(sha384) _(sha512) dnl
 _(rmd128) _(rmd160) _(rmd256) _(rmd320)')
 define(`hash_modes', `_(mgf) _(hmac)')
 
@@ -285,7 +306,8 @@ _(gfshare) _(gfx-sqr)')
 autoheaders: addsuffix(`gen_tables', `-tab.h') primetab.h mptypes.h
 define(`emit', `
 _item`'-tab.h: _item`'-mktab
-       ./_item`'-mktab >_item`'-tab.h')dnl
+       ./_item`'-mktab >_item`'-tab.h.new
+       mv _item`'-tab.h.new _item`'-tab.h')dnl
 gen_tables
 
 primetab.h: primetab.c
@@ -294,7 +316,8 @@ primetab.c: genprimes
                -t "unsigned short" -i primetab
 archinclude_HEADERS = mptypes.h
 mptypes.h: mptypes
-       ./mptypes >mptypes.h
+       ./mptypes >mptypes.h.new
+       mv mptypes.h.new mptypes.h
 
 BUILT_SOURCES = \
        getdate.c modes-stamp \
@@ -312,7 +335,7 @@ libcatacomb_la_LDFLAGS = -version-info 3:0:1
 ## difference between the first and last numbers is major version.
 
 pkginclude_HEADERS = \
-       arena.h paranoia.h \
+       arena.h paranoia.h buf.h \
        blkc.h hash.h gcipher.h ghash.h gmac.h grand.h ghash-def.h \
        lcrand.h fibrand.h rc4.h seal.h rand.h noise.h fipstest.h maurer.h \
        key.h key-data.h passphrase.h pixie.h lmem.h \
@@ -341,7 +364,7 @@ define(`MP_SOURCES',
        exp.c mpcrt.c mpmul.c mprand.c \
        mpbarrett.c mpbarrett-mexp.c mpbarrett-exp.h \
        mpmont.c mpmont-mexp.c mpmont-exp.h \
-       rho.c \
+       rho.c buf.c \
        GF_SOURCES PGEN_SOURCES EC_SOURCES')
 
 define(`GF_SOURCES',
@@ -459,7 +482,10 @@ man_MANS = key.1 hashsum.1 keyring.5 pixie.1
 
 EXTRA_DIST = \
        Makefile.m4 genmodes $(man_MANS) xpixie \
-       README.cipher README.hash README.random README.mp
+       README.cipher README.hash README.random README.mp \
+       debian/rules debian/copyright debian/control debian/changelog \
+       debian/catacomb-bin.postinst debian/catacomb-bin.config \
+       debian/catacomb-bin.prerm debian/catacomb-bin.templates
 
 dist-hook:
        @ln getdate.c $(distdir) || ln $(srcdir)/getdate.c $(distdir) || true
@@ -541,7 +567,8 @@ CLEANFILES = \
 ## --- Makefile building (haha!) ---
 
 $(srcdir)/Makefile.am: $(srcdir)/Makefile.m4
-       m4 $(srcdir)/Makefile.m4 >$(srcdir)/Makefile.am
+       m4 $(srcdir)/Makefile.m4 >$(srcdir)/Makefile.am.new
+       mv $(srcdir)/Makefile.am.new $(srcdir)/Makefile.am
 
 DISTCLEANFILES = libtool
 
diff --git a/buf.c b/buf.c
new file mode 100644 (file)
index 0000000..5e0a069
--- /dev/null
+++ b/buf.c
@@ -0,0 +1,316 @@
+/* -*-c-*-
+ *
+ * $Id: buf.c,v 1.2 2003/11/10 22:18:30 mdw Exp $
+ *
+ * Buffer handling
+ *
+ * (c) 2001 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------* 
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
+ * Catacomb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Library General Public
+ * License along with Catacomb; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+/*----- Revision history --------------------------------------------------* 
+ *
+ * $Log: buf.c,v $
+ * Revision 1.2  2003/11/10 22:18:30  mdw
+ * Build fixes.
+ *
+ * Revision 1.1  2003/10/11 21:02:33  mdw
+ * Import buf stuff from tripe.
+ *
+ * Revision 1.4  2001/06/19 22:09:54  mdw
+ * Expose interface, for use in the proxy.
+ *
+ * Revision 1.3  2001/03/03 12:06:48  mdw
+ * Use 16-bit lengths on MPs, since there's a packet limit of 64K anyway.
+ *
+ * Revision 1.2  2001/02/16 21:23:20  mdw
+ * Various minor changes.  Check that MPs are in canonical form when
+ * loading.
+ *
+ * Revision 1.1  2001/02/03 20:26:37  mdw
+ * Initial checkin.
+ *
+ */
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <string.h>
+
+#include "mp.h"
+#include "buf.h"
+
+/*----- Main code ---------------------------------------------------------*/
+
+/* --- @buf_init@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @void *p@ = pointer to a buffer
+ *             @size_t sz@ = size of the buffer
+ *
+ * Returns:    ---
+ *
+ * Use:                Initializes the buffer block appropriately.
+ */
+
+void buf_init(buf *b, void *p, size_t sz)
+{
+  b->base = b->p = p;
+  b->limit = b->p + sz;
+  b->f = 0;
+}
+
+/* --- @buf_break@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *
+ * Returns:    Some negative value.
+ *
+ * Use:                Marks a buffer as broken.
+ */
+
+int buf_break(buf *b) { b->f |= BF_BROKEN; return (-1); }
+
+/* --- @buf_flip@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *
+ * Returns:    ---
+ *
+ * Use:                Flips a buffer so that if you've just been writing to it,
+ *             you can now read from the bit you've written.
+ */
+
+void buf_flip(buf *b)
+{
+  b->limit = b->p;
+  b->p = b->base;
+}
+
+/* --- @buf_ensure@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @size_t sz@ = size of data wanted
+ *
+ * Returns:    Zero if it worked, nonzero if there wasn't enough space.
+ *
+ * Use:                Ensures that there are @sz@ bytes still in the buffer.
+ */
+
+int buf_ensure(buf *b, size_t sz) { return (BENSURE(b, sz)); }
+
+/* --- @buf_get@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @size_t sz@ = size of the buffer
+ *
+ * Returns:    Pointer to the place in the buffer.
+ *
+ * Use:                Reserves a space in the buffer of the requested size, and
+ *             returns its start address.
+ */
+
+void *buf_get(buf *b, size_t sz)
+{
+  void *p;
+  if (BENSURE(b, sz))
+    return (0);
+  p = BCUR(b);
+  BSTEP(b, sz);
+  return (p);
+}
+
+/* --- @buf_put@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @const void *p@ = pointer to a buffer
+ *             @size_t sz@ = size of the buffer
+ *
+ * Returns:    Zero if it worked, nonzero if there wasn't enough space.
+ *
+ * Use:                Fetches data from some place and puts it in the buffer
+ */
+
+int buf_put(buf *b, const void *p, size_t sz)
+{
+  if (BENSURE(b, sz))
+    return (-1);
+  memcpy(BCUR(b), p, sz);
+  BSTEP(b, sz);
+  return (0);
+}
+
+/* --- @buf_getbyte@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *
+ * Returns:    A byte, or less than zero if there wasn't a byte there.
+ *
+ * Use:                Gets a single byte from a buffer.
+ */
+
+int buf_getbyte(buf *b)
+{
+  if (BENSURE(b, 1))
+    return (-1);
+  return (*b->p++);
+}
+
+/* --- @buf_putbyte@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @int ch@ = byte to write
+ *
+ * Returns:    Zero if OK, nonzero if there wasn't enough space.
+ *
+ * Use:                Puts a single byte in a buffer.
+ */
+
+int buf_putbyte(buf *b, int ch)
+{
+  if (BENSURE(b, 1))
+    return (-1);
+  *b->p++ = ch;
+  return (0);
+}
+
+/* --- @buf_getu16@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @uint16 *w@ = where to put the word
+ *
+ * Returns:    Zero if OK, or nonzero if there wasn't a word there.
+ *
+ * Use:                Gets a 16-bit word from a buffer.
+ */
+
+int buf_getu16(buf *b, uint16 *w)
+{
+  if (BENSURE(b, 2))
+    return (-1);
+  *w = LOAD16(b->p);
+  BSTEP(b, 2);
+  return (0);
+}
+
+/* --- @buf_putu16@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @uint16 w@ = word to write
+ *
+ * Returns:    Zero if OK, nonzero if there wasn't enough space.
+ *
+ * Use:                Puts a 16-but word in a buffer.
+ */
+
+int buf_putu16(buf *b, uint16 w)
+{
+  if (BENSURE(b, 2))
+    return (-1);
+  STORE16(b->p, w);
+  BSTEP(b, 2);
+  return (0);
+}
+
+/* --- @buf_getu32@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @uint32 *w@ = where to put the word
+ *
+ * Returns:    Zero if OK, or nonzero if there wasn't a word there.
+ *
+ * Use:                Gets a 32-bit word from a buffer.
+ */
+
+int buf_getu32(buf *b, uint32 *w)
+{
+  if (BENSURE(b, 4))
+    return (-1);
+  *w = LOAD32(b->p);
+  BSTEP(b, 4);
+  return (0);
+}
+
+/* --- @buf_putu32@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @uint32 w@ = word to write
+ *
+ * Returns:    Zero if OK, nonzero if there wasn't enough space.
+ *
+ * Use:                Puts a 32-but word in a buffer.
+ */
+
+int buf_putu32(buf *b, uint32 w)
+{
+  if (BENSURE(b, 4))
+    return (-1);
+  STORE32(b->p, w);
+  BSTEP(b, 4);
+  return (0);
+}
+
+/* --- @buf_getmp@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *
+ * Returns:    A multiprecision integer, or null if there wasn't one there.
+ *
+ * Use:                Gets a multiprecision integer from a buffer.
+ */
+
+mp *buf_getmp(buf *b)
+{
+  uint16 sz;
+  mp *m;
+  if (buf_getu16(b, &sz) || buf_ensure(b, sz))
+    return (0);
+  m = mp_loadb(MP_NEW, BCUR(b), sz);
+  if (mp_octets(m) != sz) {
+    mp_drop(m);
+    return (0);
+  }
+  BSTEP(b, sz);
+  return (m);
+}
+
+/* --- @buf_putmp@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @mp *m@ = a multiprecision integer
+ *
+ * Returns:    Zero if it worked, nonzero if there wasn't enough space.
+ *
+ * Use:                Puts a multiprecision integer to a buffer.
+ */
+
+int buf_putmp(buf *b, mp *m)
+{
+  size_t sz = mp_octets(m);
+  assert(sz < MASK16);
+  if (buf_putu16(b, sz) || buf_ensure(b, sz))
+    return (-1);
+  mp_storeb(m, BCUR(b), sz);
+  BSTEP(b, sz);
+  return (0);
+}
+
+/*----- That's all, folks -------------------------------------------------*/
diff --git a/buf.h b/buf.h
new file mode 100644 (file)
index 0000000..0131681
--- /dev/null
+++ b/buf.h
@@ -0,0 +1,267 @@
+/* -*-c-*-
+ *
+ * $Id: buf.h,v 1.2 2003/11/10 22:18:30 mdw Exp $
+ *
+ * Reading and writing packet buffers
+ *
+ * (c) 2001 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------* 
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
+ * Catacomb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Library General Public
+ * License along with Catacomb; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+/*----- Revision history --------------------------------------------------* 
+ *
+ * $Log: buf.h,v $
+ * Revision 1.2  2003/11/10 22:18:30  mdw
+ * Build fixes.
+ *
+ * Revision 1.1  2003/10/11 21:02:33  mdw
+ * Import buf stuff from tripe.
+ *
+ * Revision 1.1  2001/06/19 22:09:54  mdw
+ * Expose interface, for use in the proxy.
+ *
+ */
+
+#ifndef CATACOMB_BUF_H
+#define CATACOMB_BUF_H
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <stddef.h>
+
+#include <mLib/bits.h>
+
+#ifndef CATACOMB_MP_H
+#  include "mp.h"
+#endif
+
+/*----- Data structures ---------------------------------------------------*/
+
+/* --- Buffers --- *
+ *
+ * Buffers provide a simple stream-like interface for building and parsing
+ * packets.
+ */
+
+typedef struct buf {
+  octet *base, *p, *limit;             /* Pointers to the buffer */
+  unsigned f;                          /* Various flags */
+} buf;
+
+#define BF_BROKEN 1u                   /* Buffer is broken */
+
+/*----- Useful macros -----------------------------------------------------*/
+
+#define BBASE(b) ((b)->base)
+#define BLIM(b) ((b)->limit)
+#define BCUR(b) ((b)->p)
+#define BSZ(b) ((b)->limit - (b)->base)
+#define BLEN(b) ((b)->p - (b)->base)
+#define BLEFT(b) ((b)->limit - (b)->p)
+#define BSTEP(b, sz) ((b)->p += (sz))
+#define BBAD(b) ((b)->f & BF_BROKEN)
+#define BOK(b) (!BBAD(b))
+
+#define BENSURE(b, sz)                                                 \
+  (BBAD(b) ? -1 : (sz) > BLEFT(b) ? (b)->f |= BF_BROKEN, -1 : 0)
+
+/*----- Functions provided ------------------------------------------------*/
+
+/* --- @buf_init@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @void *p@ = pointer to a buffer
+ *             @size_t sz@ = size of the buffer
+ *
+ * Returns:    ---
+ *
+ * Use:                Initializes the buffer block appropriately.
+ */
+
+extern void buf_init(buf */*b*/, void */*p*/, size_t /*sz*/);
+
+/* --- @buf_break@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *
+ * Returns:    Some negative value.
+ *
+ * Use:                Marks a buffer as broken.
+ */
+
+extern int buf_break(buf */*b*/);
+
+/* --- @buf_flip@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *
+ * Returns:    ---
+ *
+ * Use:                Flips a buffer so that if you've just been writing to it,
+ *             you can now read from the bit you've written.
+ */
+
+extern void buf_flip(buf */*b*/);
+
+/* --- @buf_ensure@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @size_t sz@ = size of data wanted
+ *
+ * Returns:    Zero if it worked, nonzero if there wasn't enough space.
+ *
+ * Use:                Ensures that there are @sz@ bytes still in the buffer.
+ */
+
+extern int buf_ensure(buf */*b*/, size_t /*sz*/);
+
+/* --- @buf_get@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @size_t sz@ = size of the buffer
+ *
+ * Returns:    Pointer to the place in the buffer.
+ *
+ * Use:                Reserves a space in the buffer of the requested size, and
+ *             returns its start address.
+ */
+
+extern void *buf_get(buf */*b*/, size_t /*sz*/);
+
+/* --- @buf_put@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @const void *p@ = pointer to a buffer
+ *             @size_t sz@ = size of the buffer
+ *
+ * Returns:    Zero if it worked, nonzero if there wasn't enough space.
+ *
+ * Use:                Fetches data from some place and puts it in the buffer
+ */
+
+extern int buf_put(buf */*b*/, const void */*p*/, size_t /*sz*/);
+
+/* --- @buf_getbyte@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *
+ * Returns:    A byte, or less than zero if there wasn't a byte there.
+ *
+ * Use:                Gets a single byte from a buffer.
+ */
+
+extern int buf_getbyte(buf */*b*/);
+
+/* --- @buf_putbyte@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @int ch@ = byte to write
+ *
+ * Returns:    Zero if OK, nonzero if there wasn't enough space.
+ *
+ * Use:                Puts a single byte in a buffer.
+ */
+
+extern int buf_putbyte(buf */*b*/, int /*ch*/);
+
+/* --- @buf_getu16@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @uint16 *w@ = where to put the word
+ *
+ * Returns:    Zero if OK, or nonzero if there wasn't a word there.
+ *
+ * Use:                Gets a 16-bit word from a buffer.
+ */
+
+extern int buf_getu16(buf */*b*/, uint16 */*w*/);
+
+/* --- @buf_putu16@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @uint16 w@ = word to write
+ *
+ * Returns:    Zero if OK, nonzero if there wasn't enough space.
+ *
+ * Use:                Puts a 16-but word in a buffer.
+ */
+
+extern int buf_putu16(buf */*b*/, uint16 /*w*/);
+
+/* --- @buf_getu32@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @uint32 *w@ = where to put the word
+ *
+ * Returns:    Zero if OK, or nonzero if there wasn't a word there.
+ *
+ * Use:                Gets a 32-bit word from a buffer.
+ */
+
+extern int buf_getu32(buf */*b*/, uint32 */*w*/);
+
+/* --- @buf_putu32@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @uint32 w@ = word to write
+ *
+ * Returns:    Zero if OK, nonzero if there wasn't enough space.
+ *
+ * Use:                Puts a 32-but word in a buffer.
+ */
+
+extern int buf_putu32(buf */*b*/, uint32 /*w*/);
+
+/* --- @buf_getmp@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *
+ * Returns:    A multiprecision integer, or null if there wasn't one there.
+ *
+ * Use:                Gets a multiprecision integer from a buffer.
+ */
+
+extern mp *buf_getmp(buf */*b*/);
+
+/* --- @buf_putmp@ --- *
+ *
+ * Arguments:  @buf *b@ = pointer to a buffer block
+ *             @mp *m@ = a multiprecision integer
+ *
+ * Returns:    Zero if it worked, nonzero if there wasn't enough space.
+ *
+ * Use:                Puts a multiprecision integer to a buffer.
+ */
+
+extern int buf_putmp(buf */*b*/, mp */*m*/);
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif
index 0d7ceb9..3e89034 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-apcalc-*-
  *
- * $Id: ec2.cal,v 1.1.2.1 2004/03/21 22:39:46 mdw Exp $
+ * $Id: ec2.cal,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Testbed for elliptic curve arithmetic over binary fields
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: ec2.cal,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.2.1  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
index 43ac1b3..7c560c5 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-apcalc-*-
  *
- * $Id: ecp.cal,v 1.1.4.2 2004/03/20 00:13:31 mdw Exp $
+ * $Id: ecp.cal,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Testbed for elliptic curve arithmetic over prime fields
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: ecp.cal,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.4.2  2004/03/20 00:13:31  mdw
  * Projective coordinates for prime curves
  *
index 5b19cb3..446061e 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-apcalc-*-
  *
- * $Id: gfx.cal,v 1.1.4.1 2004/03/21 22:39:46 mdw Exp $
+ * $Id: gfx.cal,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Testbed for %$\gf{2}$% poltnomial arithmetic
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: gfx.cal,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.4.1  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
index 599cc28..7e2245d 100644 (file)
@@ -1,6 +1,6 @@
-dnl -*-fundamental-*-
+dnl -*-m4-*-
 dnl
-dnl $Id: configure.in,v 1.24.2.1 2003/06/10 13:43:53 mdw Exp $
+dnl $Id: configure.in,v 1.27 2004/03/21 22:52:06 mdw Exp $
 dnl
 dnl Autoconfiguration for Catacomb
 dnl
@@ -29,8 +29,17 @@ dnl MA 02111-1307, USA.
 dnl ----- Revision history --------------------------------------------------
 dnl
 dnl $Log: configure.in,v $
-dnl Revision 1.24.2.1  2003/06/10 13:43:53  mdw
-dnl Simple (non-projective) curves over prime fields now seem to work.
+dnl Revision 1.27  2004/03/21 22:52:06  mdw
+dnl Merge and close elliptic curve branch.
+dnl
+dnl   Revision 1.24.2.1  2003/06/10 13:43:53  mdw
+dnl   Simple (non-projective) curves over prime fields now seem to work.
+dnl
+dnl Revision 1.26  2003/11/29 23:39:36  mdw
+dnl Debianization.
+dnl
+dnl Revision 1.25  2003/10/11 21:02:33  mdw
+dnl Import buf stuff from tripe.
 dnl
 dnl Revision 1.24  2003/05/16 00:30:28  mdw
 dnl Version bump.
@@ -81,7 +90,7 @@ dnl
 dnl --- Boring boilerplate ---
 
 AC_INIT(blkc.h)
-mdw_INIT_LIB(catacomb, Catacomb, 2.1.0ec1)
+mdw_INIT_LIB(catacomb, Catacomb, 2.1.0)
 AM_CONFIG_HEADER(config.h)
 
 dnl --- Make sure I can compile and build libraries ---
diff --git a/debian/.cvsignore b/debian/.cvsignore
new file mode 100644 (file)
index 0000000..0af825e
--- /dev/null
@@ -0,0 +1,4 @@
+files tmp substvars *.substvars *.debhelper
+catacomb
+catacomb-bin catacomb-dev
+catacomb2
diff --git a/debian/catacomb-bin.config b/debian/catacomb-bin.config
new file mode 100644 (file)
index 0000000..49d6dbf
--- /dev/null
@@ -0,0 +1,5 @@
+#! /bin/sh -e
+. /usr/share/debconf/confmodule
+db_version 2.0
+db_input medium catacomb-bin/pixie-is-setuid || true
+db_go || true
diff --git a/debian/catacomb-bin.postinst b/debian/catacomb-bin.postinst
new file mode 100644 (file)
index 0000000..c78ee62
--- /dev/null
@@ -0,0 +1,17 @@
+#! /bin/sh -e
+. /usr/share/debconf/confmodule
+db_version 2.0
+db_get catacomb-bin/pixie-is-setuid; setuid=$RET
+dpkg-statoverride --remove /usr/bin/pixie 2>/dev/null || true
+case $setuid in
+  true)
+    echo "Installing /usr/bin/pixie setuid-root."
+    dpkg-statoverride --add --update root root 4755 /usr/bin/pixie 
+    ;;
+  false)
+    echo "Making /usr/bin/pixie non-setuid."
+    dpkg-statoverride --add --update root root 755 /usr/bin/pixie
+    ;;
+esac
+
+#DEBHELPER#
diff --git a/debian/catacomb-bin.prerm b/debian/catacomb-bin.prerm
new file mode 100644 (file)
index 0000000..2cdd63b
--- /dev/null
@@ -0,0 +1,2 @@
+#! /bin/sh -e
+dpkg-statoverride --remove /usr/bin/pixie 2>/dev/null || true
diff --git a/debian/catacomb-bin.templates b/debian/catacomb-bin.templates
new file mode 100644 (file)
index 0000000..d4fb741
--- /dev/null
@@ -0,0 +1,14 @@
+Template: catacomb-bin/pixie-is-setuid
+Type: boolean
+Default: true
+Description: Install pixie setuid-root?
+ Catacomb provides a `passphrase pixie' which prompts for passphrases
+ (either on its terminal or using an external command) and remembers them
+ for a configurable period of time.
+ .
+ For added security, the pixie can ensure that the memory it uses for
+ passphrases is not swapped to disk.  To do this, it must be installed
+ setuid root.  While the pixie has been carefully written so that this
+ shouldn't be a security problem -- it allocates a small amount of memory,
+ marks it as unswappable and then drops privileges immediately -- it may
+ make some administrators nervous, so you have the option.
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..ce65b69
--- /dev/null
@@ -0,0 +1,15 @@
+catacomb (2.1.0) experimental; urgency=low
+
+  * Added support for elliptic curves, on both prime and binary fields
+    (polynomial basis only).  No actual crypto, but there's enough already
+    to do ECDH and stuff on well-known curves  Testing is currently a bit
+    patchy.
+
+ -- Mark Wooding <mdw@nsict.org>  Sun, 21 Mar 2004 22:47:56 +0000
+
+catacomb (2.0.1) experimental; urgency=low
+
+  * Debianization!
+  * (pixie): Don't report uninteresting errors when accepting connections.
+
+ -- Mark Wooding <mdw@nsict.org>  Thu, 11 Dec 2003 10:47:59 +0000
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..9a8d75b
--- /dev/null
@@ -0,0 +1,62 @@
+Source: catacomb
+Section: libs
+Priority: extra
+Build-Depends: mlib-dev (>= 2.0.2), debhelper (>= 4.0.2)
+Maintainer: Mark Wooding <mdw@nsict.org>
+Standards-Version: 3.1.1
+
+Package: catacomb2
+Architecture: any
+Depends: ${shlibs:Depends}
+Recommends: catacomb-bin
+Description: A cryptographic library
+ Catacomb is a cryptographic library.  It implements a large number of
+ encryption algorithms, hash functions, message authentication codes
+ and random number generators.  It has a multi-precision maths library,
+ for implementing public key schemes such as RSA, DSA and Diffie-Hellman.
+ It contains rudimentary key-management tools.
+ .
+ The objective of Catacomb is to make a crypto library which is
+ relatively straightforward to audit for security.  Its focus is on
+ clarity of source code and portability more than performance.
+ .
+ This package just contains the shared library.  If you want to develop
+ programs which use the library, you need catacomb-dev.
+
+Package: catacomb-bin
+Architecture: any
+Depends: ${shlibs:Depends}, catacomb2 (= ${Source-Version}), ${misc:Depends}
+Suggests: xtoys
+Description: A cryptographic library
+ Catacomb is a cryptographic library.  It implements a large number of
+ encryption algorithms, hash functions, message authentication codes
+ and random number generators.  It has a multi-precision maths library,
+ for implementing public key schemes such as RSA, DSA and Diffie-Hellman.
+ It contains rudimentary key-management tools.
+ .
+ The objective of Catacomb is to make a crypto library which is
+ relatively straightforward to audit for security.  Its focus is on
+ clarity of source code and portability more than performance.
+ .
+ This package contains a tool for key management, a passphrase
+ pixie, and other stuff.
+ .
+ The `xpixie' script uses `xgetline' from the `xtoys' package.
+
+Package: catacomb-dev
+Architecture: any
+Depends: catacomb2 (= ${Source-Version})
+Recommends: catacomb-bin
+Description: A cryptographic library
+ Catacomb is a cryptographic library.  It implements a large number of
+ encryption algorithms, hash functions, message authentication codes
+ and random number generators.  It has a multi-precision maths library,
+ for implementing public key schemes such as RSA, DSA and Diffie-Hellman.
+ It contains rudimentary key-management tools.
+ .
+ The objective of Catacomb is to make a crypto library which is
+ relatively straightforward to audit for security.  Its focus is on
+ clarity of source code and portability more than performance.
+ .
+ This package contains the headers and static libraries needed for
+ building programs which use the library.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..2b1f4b6
--- /dev/null
@@ -0,0 +1,16 @@
+Catacomb is copyright (c) 2003 Straylight/Edgeware
+
+Catacomb is free software; you can redistribute it and/or modify it under
+the terms of the GNU Library General Public License as published by the
+Free Software Foundation; either version 2 of the License, or (at your
+option) any later version.
+
+Catacomb is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+License for more details.
+
+You should have a copy of the GNU Library General Public License in
+/usr/share/common-licenses/LGPL-2; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+USA.
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..8116163
--- /dev/null
@@ -0,0 +1,61 @@
+#! /usr/bin/make -f
+
+export DH_COMPAT = 4
+
+build:
+       rm -rf build deb-build
+       mkdir deb-build
+       cd deb-build; ../configure --prefix=/usr --mandir=/usr/share/man
+       make -C deb-build
+       make -C deb-build check
+       touch build
+
+clean:
+       dh_clean
+       rm -rf deb-build build
+
+install: build
+       dh_clean
+       make -C deb-build install DESTDIR=`pwd`/debian/catacomb2
+       mkdir -p debian/catacomb-dev/usr
+       mv debian/catacomb2/usr/include debian/catacomb-dev/usr
+       mkdir -p debian/catacomb-dev/usr/lib
+       mv debian/catacomb2/usr/lib/catacomb debian/catacomb-dev/usr/lib
+       mv debian/catacomb2/usr/lib/*.a debian/catacomb-dev/usr/lib
+       mv debian/catacomb2/usr/lib/*.so debian/catacomb-dev/usr/lib
+       mv debian/catacomb2/usr/lib/*.la debian/catacomb-dev/usr/lib
+       mkdir -p debian/catacomb-bin/usr
+       mv debian/catacomb2/usr/bin debian/catacomb-bin/usr
+       mkdir -p debian/catacomb-bin/usr/share/man
+       mv debian/catacomb2/usr/share/man/man1 \
+               debian/catacomb-bin/usr/share/man
+
+binary-indep:
+
+binary-arch: install
+       dh_testdir -a
+       dh_testroot -a
+       dh_compress -a
+       dh_installdocs -a
+       dh_strip -a
+       dh_makeshlibs -a -V
+       dh_undocumented -a
+       dh_shlibdeps -a
+       dh_installdebconf -a
+       dh_gencontrol -a
+       dh_fixperms -a
+       dh_installdeb -a
+       dh_md5sums -a
+       dh_builddeb -a
+
+binary: binary-indep binary-arch
+
+source:
+       rm -rf deb-build/*.tar.gz deb-build/=deb=
+       make -C deb-build dist
+       mkdir deb-build/=deb=
+       cd deb-build/=deb=; tar xvfz ../*.tar.gz
+       d=`pwd`; cd ..; dpkg-source -i -b $$d/deb-build/=deb=/*
+       rm -rf deb-build/=deb=
+
+.PHONY: binary binary-arch binary-indep clean install source 
index 4f79c3d..3e85e65 100644 (file)
--- a/ec-bin.c
+++ b/ec-bin.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: ec-bin.c,v 1.1.2.1 2004/03/21 22:39:46 mdw Exp $
+ * $Id: ec-bin.c,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Arithmetic for elliptic curves over binary fields
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: ec-bin.c,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.2.1  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
index bb4e08a..0daf717 100644 (file)
--- a/ec-exp.h
+++ b/ec-exp.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: ec-exp.h,v 1.2.4.1 2004/03/20 00:13:31 mdw Exp $
+ * $Id: ec-exp.h,v 1.3 2004/03/21 22:52:06 mdw Exp $
  *
  * Exponentiation operations for elliptic curves
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: ec-exp.h,v $
+ * Revision 1.3  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.2.4.1  2004/03/20 00:13:31  mdw
  * Projective coordinates for prime curves
  *
index 40f487e..bdc6368 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: ec-prime.c,v 1.3.4.3 2004/03/21 22:39:46 mdw Exp $
+ * $Id: ec-prime.c,v 1.4 2004/03/21 22:52:06 mdw Exp $
  *
  * Elliptic curves over prime fields
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: ec-prime.c,v $
+ * Revision 1.4  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.3.4.3  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
diff --git a/ec.c b/ec.c
index a2b229f..c95333f 100644 (file)
--- a/ec.c
+++ b/ec.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: ec.c,v 1.4.4.2 2004/03/20 00:13:31 mdw Exp $
+ * $Id: ec.c,v 1.5 2004/03/21 22:52:06 mdw Exp $
  *
  * Elliptic curve definitions
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: ec.c,v $
+ * Revision 1.5  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.4.4.2  2004/03/20 00:13:31  mdw
  * Projective coordinates for prime curves
  *
diff --git a/ec.h b/ec.h
index bb5e201..07f1468 100644 (file)
--- a/ec.h
+++ b/ec.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: ec.h,v 1.4.4.3 2004/03/21 22:39:46 mdw Exp $
+ * $Id: ec.h,v 1.5 2004/03/21 22:52:06 mdw Exp $
  *
  * Elliptic curve definitions
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: ec.h,v $
+ * Revision 1.5  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.4.4.3  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
diff --git a/exp.h b/exp.h
index fc9e3a9..6bfd686 100644 (file)
--- a/exp.h
+++ b/exp.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: exp.h,v 1.1.4.1 2004/03/20 00:13:31 mdw Exp $
+ * $Id: exp.h,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Generalized exponentiation
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: exp.h,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.4.1  2004/03/20 00:13:31  mdw
  * Projective coordinates for prime curves
  *
index 509efc4..02e683d 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: f-binpoly.c,v 1.1.2.1 2004/03/21 22:39:46 mdw Exp $
+ * $Id: f-binpoly.c,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Binary fields with polynomial basis representation
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: f-binpoly.c,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.2.1  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
index 7215ec8..8454902 100644 (file)
--- a/f-prime.c
+++ b/f-prime.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: f-prime.c,v 1.3.4.3 2004/03/21 22:39:46 mdw Exp $
+ * $Id: f-prime.c,v 1.4 2004/03/21 22:52:06 mdw Exp $
  *
  * Prime fields with Montgomery arithmetic
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: f-prime.c,v $
+ * Revision 1.4  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.3.4.3  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
diff --git a/field.c b/field.c
index 0f02fa7..c310b93 100644 (file)
--- a/field.c
+++ b/field.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: field.c,v 1.1.4.1 2003/06/10 13:43:53 mdw Exp $
+ * $Id: field.c,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Abstract field operations
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: field.c,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.4.1  2003/06/10 13:43:53  mdw
  * Simple (non-projective) curves over prime fields now seem to work.
  *
diff --git a/field.h b/field.h
index ea019c5..dd674c9 100644 (file)
--- a/field.h
+++ b/field.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: field.h,v 1.3.4.2 2004/03/21 22:39:46 mdw Exp $
+ * $Id: field.h,v 1.4 2004/03/21 22:52:06 mdw Exp $
  *
  * Definitions for field arithmetic
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: field.h,v $
+ * Revision 1.4  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.3.4.2  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
index 6838e44..debfba1 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: gf-arith.c,v 1.1.2.1 2004/03/21 22:39:46 mdw Exp $
+ * $Id: gf-arith.c,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Basic arithmetic on binary polynomials
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: gf-arith.c,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.2.1  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
index 64d61d4..7c09d3a 100644 (file)
--- a/gf-gcd.c
+++ b/gf-gcd.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: gf-gcd.c,v 1.1.2.1 2004/03/21 22:39:46 mdw Exp $
+ * $Id: gf-gcd.c,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Euclidian algorithm on binary polynomials
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: gf-gcd.c,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.2.1  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
diff --git a/gf.h b/gf.h
index 889cd9b..ebf67f1 100644 (file)
--- a/gf.h
+++ b/gf.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: gf.h,v 1.1.2.1 2004/03/21 22:39:46 mdw Exp $
+ * $Id: gf.h,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Arithmetic on binary polynomials
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: gf.h,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.2.1  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
index 0393145..f826fc7 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: gfreduce-exp.h,v 1.1.2.1 2004/03/21 22:39:46 mdw Exp $
+ * $Id: gfreduce-exp.h,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Exponentiation operations for binary field reduction
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: gfreduce-exp.h,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.2.1  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
index 3969f11..819c276 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: gfreduce.c,v 1.1.2.1 2004/03/21 22:39:46 mdw Exp $
+ * $Id: gfreduce.c,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Efficient reduction modulo sparse binary polynomials
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: gfreduce.c,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.2.1  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
index 2fc4c0a..9840b5e 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: gfreduce.h,v 1.1.2.1 2004/03/21 22:39:46 mdw Exp $
+ * $Id: gfreduce.h,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Reduction modulo sparse binary polynomials
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: gfreduce.h,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.2.1  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
index 778f85a..19ec574 100644 (file)
--- a/gfx-sqr.c
+++ b/gfx-sqr.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: gfx-sqr.c,v 1.1.4.1 2004/03/21 22:39:46 mdw Exp $
+ * $Id: gfx-sqr.c,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Sqaring binary polynomials
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: gfx-sqr.c,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.4.1  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
diff --git a/gfx.h b/gfx.h
index d525650..18ac9a5 100644 (file)
--- a/gfx.h
+++ b/gfx.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: gfx.h,v 1.1.4.1 2004/03/21 22:39:46 mdw Exp $
+ * $Id: gfx.h,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Low-level arithmetic on binary polynomials
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: gfx.h,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.4.1  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
diff --git a/hash.h b/hash.h
index 1d659d3..f5d21de 100644 (file)
--- a/hash.h
+++ b/hash.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: hash.h,v 1.3 2000/06/17 11:23:27 mdw Exp $
+ * $Id: hash.h,v 1.4 2004/03/21 22:42:27 mdw Exp $
  *
  * Generic handling for message digest functions
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: hash.h,v $
+ * Revision 1.4  2004/03/21 22:42:27  mdw
+ * Test hashing on long strings.
+ *
  * Revision 1.3  2000/06/17 11:23:27  mdw
  * Portability fix for broken compilers.
  *
 #include <mLib/quis.h>
 #include <mLib/testrig.h>
 
+#define HASH_BUFLEN 100000
+
 #define HASH_TEST(PRE, pre)                                            \
                                                                        \
 static int verify(dstr *v)                                             \
@@ -227,8 +232,47 @@ static int verify(dstr *v)                                         \
   return (ok);                                                         \
 }                                                                      \
                                                                        \
+static int verifyrep(dstr *v)                                          \
+{                                                                      \
+  pre##_ctx ctx;                                                       \
+  size_t len = v[0].len;                                               \
+  int n = *(int *)v[1].buf;                                            \
+  int nd = 0;                                                          \
+  int nn = len;                                                                \
+  int ok = 1;                                                          \
+  octet *p, *q;                                                                \
+  dstr d = DSTR_INIT;                                                  \
+                                                                       \
+  while (nn < HASH_BUFLEN && (n & 1) == 0) { nd++; nn <<= 1; n >>= 1; }        \
+  p = xmalloc(nn);                                                     \
+  memcpy(p, v[0].buf, len);                                            \
+  q = p + len;                                                         \
+  while (nd--) { memcpy(q, p, len); q += len; len <<= 1; }             \
+                                                                       \
+  dstr_ensure(&d, PRE##_HASHSZ);                                       \
+  d.len = PRE##_HASHSZ;                                                        \
+  pre##_init(&ctx);                                                    \
+  while (n--) pre##_hash(&ctx, p, len);                                        \
+  pre##_done(&ctx, d.buf);                                             \
+                                                                       \
+  if (memcmp(d.buf, v[2].buf, PRE##_HASHSZ) != 0) {                    \
+    printf("\nfail:\n\tinput = `%s'\n\treps = `%i'\n\texpected = ",    \
+            v[0].buf, *(int *)v[1].buf);                               \
+    type_hex.dump(&v[2], stdout);                                      \
+    fputs("\n\tcomputed = ", stdout);                                  \
+    type_hex.dump(&d, stdout);                                         \
+    putchar('\n');                                                     \
+    ok = 0;                                                            \
+  }                                                                    \
+  free(p);                                                             \
+  dstr_destroy(&d);                                                    \
+  return (ok);                                                         \
+}                                                                      \
+                                                                       \
 static test_chunk defs[] = {                                           \
   { #pre, verify, { &type_string, &type_hex, 0 } },                    \
+  { #pre "-rep", verifyrep,                                            \
+    { &type_string, &type_int, &type_hex, 0 } },                       \
   { 0, 0, { 0 } }                                                      \
 };                                                                     \
                                                                        \
index dbe8bdf..a2d1c91 100644 (file)
--- a/key-io.c
+++ b/key-io.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: key-io.c,v 1.4 2001/02/03 11:57:38 mdw Exp $
+ * $Id: key-io.c,v 1.5 2003/10/17 16:30:46 mdw Exp $
  *
  * Adding new keys to a key file
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: key-io.c,v $
+ * Revision 1.5  2003/10/17 16:30:46  mdw
+ * Report errors if key files don't exist!
+ *
  * Revision 1.4  2001/02/03 11:57:38  mdw
  * Allow creating keyfiles with no file attached.
  *
@@ -440,9 +443,10 @@ int key_extract(key_file *f, key *k, FILE *fp, const key_filter *kf)
 int key_open(key_file *f, const char *file, unsigned how,
             key_reporter *rep, void *arg)
 {
-  if (key_lockfile(f, file, how))
+  if (key_lockfile(f, file, how)) {
+    rep(file, 0, strerror(errno), arg);
     return (-1);
-
+  }
   f->f = 0;
   f->name = xstrdup(file);
 
index 45ae8f4..1871c1a 100644 (file)
--- a/keyutil.c
+++ b/keyutil.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: keyutil.c,v 1.15 2003/05/15 23:23:24 mdw Exp $
+ * $Id: keyutil.c,v 1.16 2003/10/15 09:31:45 mdw Exp $
  *
  * Simple key manager program
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: keyutil.c,v $
+ * Revision 1.16  2003/10/15 09:31:45  mdw
+ * Fix help message.
+ *
  * Revision 1.15  2003/05/15 23:23:24  mdw
  * Fix behaviour with bogus trailing attributes.
  *
@@ -1724,8 +1727,6 @@ void help(FILE *fp, char **argv)
       fputs(c->help, fp);
     }
   } else {
-    version(fp);
-    fputc('\n', fp);
     usage(fp);
     fputs("\n\
 Performs various simple key management operations.  Command line options\n\
index 59198cf..53584e7 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: mp-arith.c,v 1.16.2.2 2004/03/20 00:14:03 mdw Exp $
+ * $Id: mp-arith.c,v 1.17 2003/10/12 15:03:35 mdw Exp $
  *
  * Basic arithmetic on multiprecision integers
  *
@@ -30,8 +30,8 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: mp-arith.c,v $
- * Revision 1.16.2.2  2004/03/20 00:14:03  mdw
- * Bug fix.
+ * Revision 1.17  2003/10/12 15:03:35  mdw
+ * Merge fix from other branch.
  *
  * Revision 1.16.2.1  2003/06/10 13:21:10  mdw
  * Fix bug dividing small things by large ones.
index f55d0aa..6135e54 100644 (file)
--- a/mp-gcd.c
+++ b/mp-gcd.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: mp-gcd.c,v 1.5.4.1 2004/03/21 22:39:46 mdw Exp $
+ * $Id: mp-gcd.c,v 1.6 2004/03/21 22:52:06 mdw Exp $
  *
  * Extended GCD calculation
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: mp-gcd.c,v $
+ * Revision 1.6  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.5.4.1  2004/03/21 22:39:46  mdw
  * Elliptic curves on binary fields work.
  *
diff --git a/mpalloc.h b/mpalloc.h
deleted file mode 100644 (file)
index 8dc7bf7..0000000
--- a/mpalloc.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/* -*-c-*-
- *
- * $Id: mpalloc.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
- *
- * Allocation and freeing of MP buffers
- *
- * (c) 1999 Straylight/Edgeware
- */
-
-/*----- Licensing notice --------------------------------------------------* 
- *
- * This file is part of Catacomb.
- *
- * Catacomb is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- * 
- * Catacomb is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Library General Public License for more details.
- * 
- * You should have received a copy of the GNU Library General Public
- * License along with Catacomb; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-/*----- Revision history --------------------------------------------------* 
- *
- * $Log: mpalloc.h,v $
- * Revision 1.2  1999/12/10 23:29:48  mdw
- * Change header file guard names.
- *
- * Revision 1.1  1999/11/17 18:02:16  mdw
- * New multiprecision integer arithmetic suite.
- *
- */
-
-#ifndef CATACOMB_MPARENA_H
-#define CATACOMB_MPARENA_H
-
-#ifdef __cplusplus
-  extern "C" {
-#endif
-
-/*----- Header files ------------------------------------------------------*/
-
-#ifndef CATACOMB_MPW_H
-#  include "mpw.h"
-#endif
-
-/*----- Data structures ---------------------------------------------------*/
-
-typedef struct mparena_node {
-  struct mparena_node *left, *right;
-  mpw *v;
-} mparena_node;
-
-typedef struct mparena {
-  mparena_node *root;
-} mparena_arena;
-
-/*----- Magical constants -------------------------------------------------*/
-
-#define MPARENA_GLOBAL ((mparena *)0)
-
-/*----- Functions provided ------------------------------------------------*/
-
-/* --- @mparena_create@ --- *
- *
- * Arguments:  @mparena *a@ = pointer to arena block
- *
- * Returns:    ---
- *
- * Use:                Initializes an MP arena so that blocks can be allocated from
- *             it.
- */
-
-extern void mparena_create(mparena */*a*/);
-
-#define MPARENA_INIT { 0 }
-
-/* --- @mparena_destroy@ --- *
- *
- * Arguments:  @mparena *a@ = pointer to arena block
- *
- * Returns:    ---
- *
- * Use:                Frees an MP arena, and all the vectors held within it.  The
- *             blocks which are currently allocated can be freed into some
- *             other arena.
- */
-
-extern void mparena_destroy(mparena */*a*/);
-
-/* --- @mp_alloc@ --- *
- *
- * Arguments:  @mparena *a@ = pointer to arena block
- *             @size_t n@ = number of digits required
- *
- * Returns:    Pointer to a suitably sized block.
- *
- * Use:                Allocates a lump of data suitable for use as an array of MP
- *             digits.
- */
-
-extern mpw *mp_alloc(mparena */*a*/, size_t /*n*/);
-
-/* --- @mp_free@ --- *
- *
- * Arguments:  @mparena *a@ = pointer to arena block
- *             @mpw *v@ = pointer to allocated vector
- *
- * Returns:    ---
- *
- * Use:                Returns an MP vector to an arena.  It doesn't have to be
- *             returned to the arena from which it was allocated.
- */
-
-extern mpw *mp_free(mparena */*a*/, mpw */*v*/);
-
-/*----- That's all, folks -------------------------------------------------*/
-
-#ifdef __cplusplus
-  }
-#endif
-
-#endif
index e34ea49..dd02637 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: mpbarrett-exp.h,v 1.1.4.1 2004/03/20 00:20:05 mdw Exp $
+ * $Id: mpbarrett-exp.h,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Exponentiation operations for Barrett reduction
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: mpbarrett-exp.h,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.4.1  2004/03/20 00:20:05  mdw
  * Projective coordinates for prime curves
  *
index 0f82b9c..5f2b31d 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: mpmont-exp.h,v 1.1.4.1 2004/03/20 00:13:31 mdw Exp $
+ * $Id: mpmont-exp.h,v 1.2 2004/03/21 22:52:06 mdw Exp $
  *
  * Exponentiation operations for Montgomery reduction
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: mpmont-exp.h,v $
+ * Revision 1.2  2004/03/21 22:52:06  mdw
+ * Merge and close elliptic curve branch.
+ *
  * Revision 1.1.4.1  2004/03/20 00:13:31  mdw
  * Projective coordinates for prime curves
  *
diff --git a/pixie.c b/pixie.c
index a1d1e2a..ba1285a 100644 (file)
--- a/pixie.c
+++ b/pixie.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: pixie.c,v 1.12 2002/01/13 13:50:42 mdw Exp $
+ * $Id: pixie.c,v 1.13 2004/03/21 22:43:05 mdw Exp $
  *
  * Passphrase pixie for Catacomb
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: pixie.c,v $
+ * Revision 1.13  2004/03/21 22:43:05  mdw
+ * Keep quiet about expected errors on incoming connections.
+ *
  * Revision 1.12  2002/01/13 13:50:42  mdw
  * Various fixes tracking mLib changes.
  *
@@ -902,7 +905,8 @@ static void pixserv_accept(int fd, unsigned mode, void *p)
   if (mode != SEL_READ)
     return;
   if ((nfd = accept(fd, (struct sockaddr *)&sun, &sunsz)) < 0) {
-    if (verbose)
+    if (verbose && errno != EAGAIN && errno != EWOULDBLOCK &&
+       errno != ECONNABORTED && errno != EPROTO && errno != EINTR)
       log("new connection failed: %s", strerror(errno));
     return;
   }
diff --git a/sha224.c b/sha224.c
new file mode 100644 (file)
index 0000000..2eceba0
--- /dev/null
+++ b/sha224.c
@@ -0,0 +1,14 @@
+/* -*-c-*-
+ *
+ * $Id: sha224.c,v 1.1 2004/03/21 22:43:34 mdw Exp $
+ *
+ * Stub code for SHA-224
+ */
+
+#include "ghash.h"
+#include "ghash-def.h"
+#include "hash.h"
+#include "sha224.h"
+
+GHASH_DEF(SHA224, sha224)
+HASH_TEST(SHA224, sha224)
diff --git a/sha224.h b/sha224.h
new file mode 100644 (file)
index 0000000..23684b7
--- /dev/null
+++ b/sha224.h
@@ -0,0 +1,13 @@
+/* -*-c-*-
+ *
+ * $Id: sha224.h,v 1.1 2004/03/21 22:43:34 mdw Exp $
+ *
+ * Stub header for SHA-224
+ */
+
+#ifndef CATACOMB_SHA224_H
+#define CATACOMB_SHA224_H
+
+#include "sha256.h"
+
+#endif
index 54a4c85..8ffc689 100644 (file)
--- a/sha256.c
+++ b/sha256.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: sha256.c,v 1.1 2000/10/15 17:48:14 mdw Exp $
+ * $Id: sha256.c,v 1.2 2004/03/21 22:43:34 mdw Exp $
  *
  * Implementation of the SHA-256 hash function
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: sha256.c,v $
+ * Revision 1.2  2004/03/21 22:43:34  mdw
+ * New hash variant SHA224.
+ *
  * Revision 1.1  2000/10/15 17:48:14  mdw
  * New SHA variants with longer outputs.
  *
@@ -46,7 +49,7 @@
 
 /*----- Main code ---------------------------------------------------------*/
 
-/* --- @sha256_compress@ --- *
+/* --- @sha256_compress@, @sha224_compress@ --- *
  *
  * Arguments:  @sha256_ctx *ctx@ = pointer to context block
  *             @const void *sbuf@ = pointer to buffer of appropriate size
@@ -179,7 +182,7 @@ void sha256_compress(sha256_ctx *ctx, const void *sbuf)
   ctx->h += h;
 }
 
-/* --- @sha256_init@ --- *
+/* --- @sha256_init@, @sha224_init@ --- *
  *
  * Arguments:  @sha256_ctx *ctx@ = pointer to context block to initialize
  *
@@ -202,7 +205,21 @@ void sha256_init(sha256_ctx *ctx)
   ctx->nl = ctx->nh = 0;
 }
 
-/* --- @sha256_set@ --- *
+void sha224_init(sha256_ctx *ctx)
+{
+  ctx->a = 0xc1059ed8;
+  ctx->b = 0x367cd507;
+  ctx->c = 0x3070dd17;
+  ctx->d = 0xf70e5939;
+  ctx->e = 0xffc00b31;
+  ctx->f = 0x68581511;
+  ctx->g = 0x64f98fa7;
+  ctx->h = 0xbefa4fa4;
+  ctx->off = 0;
+  ctx->nl = ctx->nh = 0;
+}
+
+/* --- @sha256_set@, @sha224_set@ --- *
  *
  * Arguments:  @sha256_ctx *ctx@ = pointer to context block
  *             @const void *buf@ = pointer to state buffer
@@ -231,7 +248,7 @@ void sha256_set(sha256_ctx *ctx, const void *buf, unsigned long count)
   ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
 }
 
-/* --- @sha256_hash@ --- *
+/* --- @sha256_hash@, @sha224_hash@ --- *
  *
  * Arguments:  @sha256_ctx *ctx@ = pointer to context block
  *             @const void *buf@ = buffer of data to hash
@@ -248,7 +265,7 @@ void sha256_hash(sha256_ctx *ctx, const void *buf, size_t sz)
   HASH_BUFFER(SHA256, sha256, ctx, buf, sz);
 }
 
-/* --- @sha256_done@ --- *
+/* --- @sha256_done, @sha224_done@ --- *
  *
  * Arguments:  @sha256_ctx *ctx@ = pointer to context block
  *             @void *hash@ = pointer to output buffer
@@ -258,13 +275,18 @@ void sha256_hash(sha256_ctx *ctx, const void *buf, size_t sz)
  * Use:                Returns the hash of the data read so far.
  */
 
-void sha256_done(sha256_ctx *ctx, void *hash)
+static void final(sha256_ctx *ctx)
 {
-  octet *p = hash;
   HASH_PAD(SHA256, sha256, ctx, 0x80, 0, 8);
   STORE32(ctx->buf + SHA256_BUFSZ - 8, (ctx->nl >> 29) | (ctx->nh << 3));
   STORE32(ctx->buf + SHA256_BUFSZ - 4, ctx->nl << 3);
-  sha256_compress(ctx, ctx->buf);
+  sha256_compress(ctx, ctx->buf);  
+}
+
+void sha256_done(sha256_ctx *ctx, void *hash)
+{
+  octet *p = hash;
+  final(ctx);
   STORE32(p +  0, ctx->a);
   STORE32(p +  4, ctx->b);
   STORE32(p +  8, ctx->c);
@@ -275,7 +297,20 @@ void sha256_done(sha256_ctx *ctx, void *hash)
   STORE32(p + 28, ctx->h);
 }
 
-/* --- @sha256_state@ --- *
+void sha224_done(sha224_ctx *ctx, void *hash)
+{
+  octet *p = hash;
+  final(ctx);
+  STORE32(p +  0, ctx->a);
+  STORE32(p +  4, ctx->b);
+  STORE32(p +  8, ctx->c);
+  STORE32(p + 12, ctx->d);
+  STORE32(p + 16, ctx->e);
+  STORE32(p + 20, ctx->f);
+  STORE32(p + 24, ctx->g);
+}
+
+/* --- @sha256_state@, @sha224_state@ --- *
  *
  * Arguments:  @sha256_ctx *ctx@ = pointer to context
  *             @void *state@ = pointer to buffer for current state
index 50d61fa..ca6e18c 100644 (file)
--- a/sha256.h
+++ b/sha256.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: sha256.h,v 1.2 2000/10/15 19:09:20 mdw Exp $
+ * $Id: sha256.h,v 1.3 2004/03/21 22:43:34 mdw Exp $
  *
  * Implementation of the SHA-256 hash function
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: sha256.h,v $
+ * Revision 1.3  2004/03/21 22:43:34  mdw
+ * New hash variant SHA224.
+ *
  * Revision 1.2  2000/10/15 19:09:20  mdw
  * Support HMAC mode for hash functions which need to store more state than
  * the hash output size.
 #define SHA256_HASHSZ 32
 #define SHA256_STATESZ 32
 
+#define SHA224_BUFSZ 64
+#define SHA224_HASHSZ 28
+#define SHA224_STATESZ 32
+
 /*----- Data structures ---------------------------------------------------*/
 
 typedef struct sha256_ctx {
@@ -75,11 +82,11 @@ typedef struct sha256_ctx {
   uint32 nl, nh;                       /* Byte count so far */
   unsigned off;                                /* Offset into buffer */
   octet buf[SHA256_BUFSZ];             /* Accumulation buffer */
-} sha256_ctx;
+} sha256_ctx, sha224_ctx;
 
 /*----- Functions provided ------------------------------------------------*/
 
-/* --- @sha256_compress@ --- *
+/* --- @sha256_compress@, @sha224_compress@ --- *
  *
  * Arguments:  @sha256_ctx *ctx@ = pointer to context block
  *             @const void *sbuf@ = pointer to buffer of appropriate size
@@ -90,8 +97,9 @@ typedef struct sha256_ctx {
  */
 
 extern void sha256_compress(sha256_ctx */*ctx*/, const void */*sbuf*/);
+#define sha224_compress sha256_compress
 
-/* --- @sha256_init@ --- *
+/* --- @sha256_init@, @sha224_init@ --- *
  *
  * Arguments:  @sha256_ctx *ctx@ = pointer to context block to initialize
  *
@@ -101,8 +109,9 @@ extern void sha256_compress(sha256_ctx */*ctx*/, const void */*sbuf*/);
  */
 
 extern void sha256_init(sha256_ctx */*ctx*/);
+extern void sha224_init(sha256_ctx */*ctx*/);
 
-/* --- @sha256_set@ --- *
+/* --- @sha256_set@, @sha224_set@ --- *
  *
  * Arguments:  @sha256_ctx *ctx@ = pointer to context block
  *             @const void *buf@ = pointer to state buffer
@@ -117,8 +126,9 @@ extern void sha256_init(sha256_ctx */*ctx*/);
 
 extern void sha256_set(sha256_ctx */*ctx*/, const void */*buf*/,
                       unsigned long /*count*/);
+#define sha224_set sha256_set
 
-/* --- @sha256_hash@ --- *
+/* --- @sha256_hash@, @sha224_hash@ --- *
  *
  * Arguments:  @sha256_ctx *ctx@ = pointer to context block
  *             @const void *buf@ = buffer of data to hash
@@ -132,8 +142,9 @@ extern void sha256_set(sha256_ctx */*ctx*/, const void */*buf*/,
 
 extern void sha256_hash(sha256_ctx */*ctx*/,
                        const void */*buf*/, size_t /*sz*/);
+#define sha224_hash sha256_hash
 
-/* --- @sha256_done@ --- *
+/* --- @sha256_done@, @sha224_done@ --- *
  *
  * Arguments:  @sha256_ctx *ctx@ = pointer to context block
  *             @void *hash@ = pointer to output buffer
@@ -144,8 +155,9 @@ extern void sha256_hash(sha256_ctx */*ctx*/,
  */
 
 extern void sha256_done(sha256_ctx */*ctx*/, void */*hash*/);
+extern void sha224_done(sha256_ctx */*ctx*/, void */*hash*/);
 
-/* --- @sha256_state@ --- *
+/* --- @sha256_state@, @sha224_state@ --- *
  *
  * Arguments:  @sha256_ctx *ctx@ = pointer to context
  *             @void *state@ = pointer to buffer for current state
@@ -157,10 +169,12 @@ extern void sha256_done(sha256_ctx */*ctx*/, void */*hash*/);
  */
 
 extern unsigned long sha256_state(sha256_ctx */*ctx*/, void */*state*/);
+#define sha224_state sha256_state
 
 /*----- Generic hash interface --------------------------------------------*/
 
 extern const gchash sha256;
+extern const gchash sha224;
 
 /*----- That's all, folks -------------------------------------------------*/
 
index 0c3987f..bbb1514 100644 (file)
--- a/tests/gf
+++ b/tests/gf
@@ -1,4 +1,4 @@
-# $Id: gf,v 1.1.2.1 2004/03/21 22:39:46 mdw Exp $
+# $Id: gf,v 1.2 2004/03/21 22:52:06 mdw Exp $
 #
 # Test cases for higher-level binary poly arithmetic.
 
index aec5318..806ec28 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: gfreduce,v 1.1.2.1 2004/03/21 22:39:46 mdw Exp $
+# $Id: gfreduce,v 1.2 2004/03/21 22:52:06 mdw Exp $
 #
 # Test efficient polynomial reduction
 
index 866bd39..1ef6081 100644 (file)
--- a/tests/gfx
+++ b/tests/gfx
@@ -1,6 +1,6 @@
 # Test vectors for low-level GF functions
 #
-# $Id: gfx,v 1.1.4.1 2004/03/21 22:39:46 mdw Exp $
+# $Id: gfx,v 1.2 2004/03/21 22:52:06 mdw Exp $
 
 # --- Addition (and subtraction) ---
 
index 3e5757c..f66795e 100644 (file)
--- a/tests/mp
+++ b/tests/mp
@@ -1,6 +1,6 @@
 # Test vectors for MP functions
 #
-# $Id: mp,v 1.15.2.2 2004/03/20 00:14:03 mdw Exp $
+# $Id: mp,v 1.16 2003/10/12 15:03:35 mdw Exp $
 
 add {
   5 4 9; 5 -4 1; -5 4 -1; -5 -4 -9;
index 574a344..c82b25d 100644 (file)
@@ -1,6 +1,6 @@
 # Test vectors for RIPEMD-160
 #
-# $Id: rmd128,v 1.2 2000/07/15 10:03:51 mdw Exp $
+# $Id: rmd128,v 1.3 2004/03/21 22:44:36 mdw Exp $
 
 # --- Basic hash function ---
 #
@@ -17,8 +17,11 @@ rmd128 {
                        a1aa0689d0fafa2ddc22e88b49133a06;
   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
                        d1e959eb179c911faea4624c60c5c702;
-  "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
-                       3f45ef194732c2dbb2c4a2c769795fa3;
+}
+
+rmd128-rep {
+  "1234567890" 8 3f45ef194732c2dbb2c4a2c769795fa3;
+  "a" 1000000 4a7f5723f954eba1216c9d8f6320431f;
 }
 
 # --- HMAC mode ---
index ef12d1b..1bd3a77 100644 (file)
@@ -1,6 +1,6 @@
 # Test vectors for RIPEMD-160
 #
-# $Id: rmd160,v 1.3 2000/07/15 10:03:51 mdw Exp $
+# $Id: rmd160,v 1.4 2004/03/21 22:44:36 mdw Exp $
 
 # --- Basic hash function ---
 #
@@ -17,8 +17,11 @@ rmd160 {
                        12a053384a9c0c88e405a06c27dcf49ada62eb2b;
   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
                        b0e20b6e3116640286ed3a87a5713079b21f5189;
-  "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
-                       9b752e45573d4b39f4dbd3323cab82bf63326bfb;
+}
+
+rmd160-rep {
+  "1234567890" 8 9b752e45573d4b39f4dbd3323cab82bf63326bfb;
+  "a" 1000000 52783243c1697bdbe16d37f97f68f08325dc1528;
 }
 
 # --- HMAC mode ---
index 99f5a40..94e4219 100644 (file)
--- a/tests/sha
+++ b/tests/sha
@@ -1,6 +1,6 @@
 # Test vectors for the SHA-1 hash function
 #
-# $Id: sha,v 1.4 2000/07/15 10:03:13 mdw Exp $
+# $Id: sha,v 1.5 2004/03/21 22:44:36 mdw Exp $
 
 # --- Basic hash function ---
 #
@@ -19,33 +19,12 @@ sha {
                        84983e441c3bd26ebaae4aa1f95129e5e54670f1;
   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
                        761c457bf73b14d27e9e9265c46f4b4dda11f940;
-  "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
-                       50abf5706a150990a08b2c5ea40fa0e585554732;
+}
 
+sha-rep {
+  "1234567890" 8       50abf5706a150990a08b2c5ea40fa0e585554732;
   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-"                      f74d36bf17ee23c46ec166a48a24da6ab999eaea;
+" 23                   f74d36bf17ee23c46ec166a48a24da6ab999eaea;
 }
 
 # --- HMAC mode ---
diff --git a/tests/sha224 b/tests/sha224
new file mode 100644 (file)
index 0000000..c9fc538
--- /dev/null
@@ -0,0 +1,72 @@
+# $Id: sha224,v 1.1 2004/03/21 22:43:34 mdw Exp $
+#
+# Test vectors for SHA-224
+
+# --- Basic hash function ---
+
+sha224 {
+
+  # --- Test vectors from the definition [FALSE] ---
+
+  "abc"
+       23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7;
+  "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+       75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525;
+
+  # --- Other tests to trap regression ---
+
+  ""
+       d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f;
+  "a"
+       abd37534c7d9a2efb9465de931cd7055ffdb8879563ae98078d6d6d5;
+  "message digest"
+       2cb21c83ae2f004de7e81c3c7019cbcb65b71ab656b22d6d0c39b8eb;
+  "abcdefghijklmnopqrstuvwxyz"
+       45a5f72c39c5cff2522eb3429799e49e5f44b356ef926bcf390dccc2;
+  "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+       75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525;
+  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
+       bff72b4fcb7d75e5632900ac5f90d219e05e97a7bde72e740db393d9;
+}
+
+sha224-rep {
+  "1234567890" 8
+       b50aecbe4e9bb0b57bc5f3ae760a8e01db24f203fb3cdcd13148046e;
+  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+" 23 
+       5a86156c37c95ab356e003d569370580737794815f46de7f4834d634;
+}
+
+# --- HMAC mode ---
+#
+# Autogenerated, unofficial.
+
+sha224-hmac {
+  "Hi There"
+       0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
+       1abbc7c42cf4ca9f9d7b624564cb72d7b0945ea0a615095904a0fd34;
+
+  "what do ya want for nothing?"
+       4a656665
+       a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44;
+
+  "ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ"
+       aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+       5121d4bc8e43ee3ddcc2b0d312c110e961fc34b19ced1cce11c7a55c;
+
+  "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
+       0102030405060708090a0b0c0d0e0f10111213141516171819
+       6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a;
+
+  "Test With Truncation"
+       0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
+       0f081672137307d07aad12880537cd43f454823de00c038424741e17;
+
+  "Test Using Larger Than Block-Size Key - Hash Key First"
+       aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+       9ed2eebc0ed23576efc815e9b5bc0d9257e36d13e4dd5d5f0c809b38;
+
+  "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"
+       aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+       7358939e58683a448ac5065196d33191a1c1d33d4b8b0304dc60f5e0;
+}
index d58d442..ee4691f 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: sha256,v 1.1 2000/10/15 17:48:16 mdw Exp $
+# $Id: sha256,v 1.2 2004/03/21 22:44:36 mdw Exp $
 #
 # Test vectors for SHA-256
 
@@ -27,33 +27,13 @@ sha256 {
        248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1;
   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
        db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0;
-  "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+}
+
+sha256-rep {
+  "1234567890" 8
        f371bc4a311f2b009eef952dd83ca80e2b60026c8e935592d0f9c308453c813e;
   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-"
-       4804a2a4759acebe127b62ba651ae601a756ca0b509e4987498224acaffb0d98;
+" 23 4804a2a4759acebe127b62ba651ae601a756ca0b509e4987498224acaffb0d98;
 }
 
 # --- HMAC mode ---
index d05102d..192b6b6 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: sha384,v 1.2 2000/10/15 19:09:32 mdw Exp $
+# $Id: sha384,v 1.3 2004/03/21 22:44:36 mdw Exp $
 #
 # Test vectors for SHA-384
 
@@ -27,32 +27,13 @@ sha384 {
        3391fdddfc8dc7393707a65b1b4709397cf8b1d162af05abfe8f450de5f36bc6b0455a8520bc4e6f5fe95b1fe3c8452b;
   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
        1761336e3f7cbfe51deb137f026f89e01a448e3b1fafa64039c1464ee8732f11a5341a6f41e0c202294736ed64db1a84;
-  "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+}
+
+sha384-rep {
+  "1234567890" 8
        b12932b0627d1c060942f5447764155655bd4da0c9afa6dd9b9ef53129af1b8fb0195996d2de9ca0df9d821ffee67026;
   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-"
+" 23
        f77d169c73427bd30cceff74f822a0209657dfb78c07980509bf8452a3c5d671b7198081898d0a0034e0f7151211fa0f;
 }
 
index 2acf2f4..60f4574 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: sha512,v 1.2 2001/04/03 19:37:01 mdw Exp $
+# $Id: sha512,v 1.3 2004/03/21 22:44:36 mdw Exp $
 #
 # Test vectors for SHA-512
 
@@ -27,32 +27,14 @@ sha512 {
        204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445;
   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
        1e07be23c26a86ea37ea810c8ec7809352515a970e9253c26f536cfc7a9996c45c8370583e0a78fa4a90041d71a4ceab7423f19c71b9d5a3e01249f0bebd5894;
-  "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+}
+
+sha512-rep {
+  "1234567890" 8
        72ec1ef1124a45b047e8b7c75a932195135bb61de24ec0d1914042246e0aec3a2354e093d76f3048b456764346900cb130d2a4fd5dd16abb5e30bcb850dee843;
+
   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
-"
+" 23
        4def32cfb1107a104eae530fe04326a57e839a0bd9675f6770ff18d0b3b3ee2d4343bf99e9d54adc272617d49d0f61eab4b4bc177f9d2bac086cd2d902b5780e;
 }