pgroups: Ship a keyring file containing the custom prime groups.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 16 Jan 2007 21:50:40 +0000 (21:50 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 16 Jan 2007 21:51:20 +0000 (21:51 +0000)
This is largely as a useful reference for the benefit of, oh, say the
TrIPE RFC document.

.gitignore
Makefile.m4
mkpgroups [new file with mode: 0755]

index c2cba43..00edf95 100644 (file)
@@ -315,3 +315,5 @@ compile
 debug
 prof
 tinymp
 debug
 prof
 tinymp
+*.kr
+*.kr.old
index 0025dc6..a1a6730 100644 (file)
@@ -334,13 +334,20 @@ man_MANS = \
        key.1 dsig.1 cookie.1 catcrypt.1 catsign.1 hashsum.1 mkphrase.1 \
        keyring.5 pixie.1
 
        key.1 dsig.1 cookie.1 catcrypt.1 catsign.1 hashsum.1 mkphrase.1 \
        keyring.5 pixie.1
 
+## --- Prime group keyring ---
+
+pkgdata_DATA = pgroups.kr
+
+$(srcdir)/pgroups.kr: ptab.in mkpgroups
+       cd $(srcdir) && rm -f pgroups.kr && ./mkpgroups <ptab.in
+
 ## --- Other handy definitions ---
 
 EXTRA_DIST = \
        Makefile.m4 genmodes gengctab $(man_MANS) xpixie \
        group-test.c rsa-test.c \
        ectab.in ec-gentab.awk \
 ## --- Other handy definitions ---
 
 EXTRA_DIST = \
        Makefile.m4 genmodes gengctab $(man_MANS) xpixie \
        group-test.c rsa-test.c \
        ectab.in ec-gentab.awk \
-       ptab.in p-gentab.awk \
+       ptab.in p-gentab.awk mkpgroups pgroups.kr \
        bintab.in bin-gentab.awk \
        README.cipher README.hash README.random README.mp \
        debian/rules debian/copyright debian/control debian/changelog \
        bintab.in bin-gentab.awk \
        README.cipher README.hash README.random README.mp \
        debian/rules debian/copyright debian/control debian/changelog \
@@ -432,7 +439,7 @@ CTESTRIG(rho)
 TESTS = serpent-check bittest testprogs
 
 CLEANFILES = \
 TESTS = serpent-check bittest testprogs
 
 CLEANFILES = \
-       *.t$(EXEEXT) *.to \
+       *.t$(EXEEXT) *.to *.kr.old \
        mptypes.h primetab.c primetab.h ectab.c ptab.c bintab.c \
        addsuffix(`gen_tables', `-tab.h')
 
        mptypes.h primetab.c primetab.h ectab.c ptab.c bintab.c \
        addsuffix(`gen_tables', `-tab.h')
 
@@ -447,6 +454,7 @@ DISTCLEANFILES = libtool
 MAINTAINERCLEANFILES = \
        $(srcdir)/Makefile.am \
        $(srcdir)/getdate.c getdate.c \
 MAINTAINERCLEANFILES = \
        $(srcdir)/Makefile.am \
        $(srcdir)/getdate.c getdate.c \
+       $(srcdir)/pgroups.kr \
        $(MODES) modes-stamp $(srcdir)/modes-stamp
 
 ##----- That's all, folks ---------------------------------------------------
        $(MODES) modes-stamp $(srcdir)/modes-stamp
 
 ##----- That's all, folks ---------------------------------------------------
diff --git a/mkpgroups b/mkpgroups
new file mode 100755 (executable)
index 0000000..3b3874f
--- /dev/null
+++ b/mkpgroups
@@ -0,0 +1,42 @@
+#! /usr/bin/python
+
+import catacomb as C
+import mLib as M
+from sys import stdin
+
+kf = C.KeyFile('pgroups.kr', C.KOPEN_WRITE)
+
+for line in stdin:
+  line = line.strip()
+  if line == '' or (line.startswith('#') and not line.startswith('#:')):
+    continue
+  F = line.split()
+  if F[0] == 'group':
+    name = F[1]
+    if not name.startswith('catacomb'):
+      continue
+    def snarf(what):
+      F = stdin.next().split()
+      assert F[0] == what
+      return F[1]
+    p = C.MP(snarf('p'))
+    q = C.MP(snarf('q'))
+    g = C.MP(snarf('g'))
+    ff = []
+    while True:
+      F = stdin.next().split()
+      if not F or F[0] != '#:factor':
+        break
+      ff.append(C.MP(F[1]))
+    seed = C.rmd160().hash(name).done()
+    k = kf.newkey(C.ReadBuffer(seed).getu32(), 'dh-param')
+    k.tag = name
+    k.data = C.KeyDataStructured({
+      'p': C.KeyDataMP(p, 'shared'),
+      'q': C.KeyDataMP(q, 'shared'),
+      'g': C.KeyDataMP(g, 'shared')
+    })
+    k.attr['factor'] = ', '.join([f.tostring() for f in ff])
+    k.attr['genseed'] = M.base64_encode(seed)
+    k.attr['seedalg'] = 'rmd160-mgf'
+kf.save()