chiark / gitweb /
server/tests.at, t/keyring-*: New tests for key management.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 Jan 2012 00:09:25 +0000 (00:09 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 7 May 2012 14:35:11 +0000 (15:35 +0100)
Ensure that everything works when different peer associations use
different private keys, and when the keys, algorithms and groups change
under our feet.

This involves adding a new peer to the keyrings, and inventing a new
keyring.  More interestingly, it also involves plumbing together a
network of three peers, which is where the earlier refactoring of the
test communications machinery pays off.

server/tests.at
t/Makefile.am
t/keyring-alpha
t/keyring-beta-new [new file with mode: 0644]

index ab64c538ff3a47634075ea05e15af1cc39f76409..a326709ec085f8792109c724962a37f0ba9fdb6b 100644 (file)
@@ -423,6 +423,143 @@ WITH_3TRIPES([alice], [bob], [carol], [-nslip],
 
 AT_CLEANUP
 
+###--------------------------------------------------------------------------
+### Key management.
+
+AT_SETUP([server key-management])
+AT_KEYWORDS([keymgmt])
+export TRIPE_SLIPIF=USLIP
+
+## Determine all of the nets and the principals.
+princs=""
+nets=" "
+while read princ pnets; do
+  princs="$princs $princ"
+  for n in $pnets; do
+    case " $nets " in *" $n "*) ;; *) nets="$nets$n " ;; esac
+  done
+done <<PRINC
+alice  alpha   beta
+bob    alpha   beta
+carol  beta
+PRINC
+
+## Build the master keyring.  All key tags here are of the form PRINC/NET.
+for n in $nets; do
+  key -k$abs_top_srcdir/t/keyring-$n extract keyring-$n $princs
+  for p in $princs; do key -kkeyring-$n tag $p $p/$n; done
+  key merge keyring-$n
+  rm keyring-$n
+done
+key extract -f-secret keyring.pub
+
+## Set up the principals' directories.
+for p in $princs; do
+  mkdir $p
+  cp keyring keyring.pub $p/
+done
+
+WITH_3TRIPES([alice], [bob], [carol], [-nslip -Tmx],
+       [-talice/alpha], [-tbob/alpha], [-tcarol/beta], [
+
+  ## Establish this little merry-go-round.
+  ESTABLISH([alice], [alice], [-key alice/alpha],
+       [bob], [bob], [-key bob/alpha])
+  ESTABLISH([alice], [alice], [-key alice/beta],
+       [carol], [carol], [-priv alice/beta -key carol/beta])
+  ESTABLISH([bob], [bob], [-key bob/beta],
+       [carol], [carol], [-priv bob/beta -key carol/beta])
+
+  ## Tweak Bob's alpha key.
+  for p in $princs; do
+    TRIPECTL -d$p WARN test COMMENT tweak bob/alpha
+  done
+
+  key -k$abs_top_srcdir/t/keyring-alpha extract keyring-bob-new bob-new
+  key merge keyring-bob-new
+  key tag -r bob-new bob/alpha
+  key extract -f-secret keyring.pub
+  for p in alice bob; do cp keyring keyring.pub $p/; done
+
+  ## Kick the peers to see whether they update.
+  AWAIT_KXDONE([alice], [alice], [bob], [bob], [
+    TRIPECTL -dalice RELOAD
+    TRIPECTL -dbob RELOAD
+    TRIPECTL -dalice FORCEKX bob
+    TRIPECTL -dbob FORCEKX alice
+  ])
+
+  COMMS_EPING([alice], [alice], [bob], [bob])
+  COMMS_EPING([bob], [bob], [alice], [alice])
+
+  ## Update the beta ring.
+  key merge $abs_top_srcdir/t/keyring-beta-new
+  for p in $princs; do key tag -r $p $p/beta; done
+  key extract -f-secret keyring.pub
+
+  ## Update alice's and carol's private keys, bob's public.  This should be
+  ## insufficient for them to switch, but the results could be interesting.
+  for p in $princs; do
+    TRIPECTL -d$p WARN test COMMENT tweak beta step 1
+  done
+
+  for p in alice carol; do cp keyring $p/; done
+  cp keyring.pub bob/
+  for p in $princs; do TRIPECTL -d$p RELOAD; done
+
+  AT_DATA([algs-alpha], [dnl
+kx-group=ec kx-group-order-bits=256 kx-group-elt-bits=512
+hash=rmd160 mgf=rmd160-mgf hash-sz=20
+cipher=blowfish-cbc cipher-keysz=20 cipher-blksz=8
+cipher-data-limit=67108864
+mac=rmd160-hmac mac-keysz=20 mac-tagsz=10
+])
+
+  AT_DATA([algs-beta-old], [dnl
+kx-group=prime kx-group-order-bits=160 kx-group-elt-bits=1023
+hash=rmd160 mgf=rmd160-mgf hash-sz=20
+cipher=blowfish-cbc cipher-keysz=20 cipher-blksz=8
+cipher-data-limit=67108864
+mac=rmd160-hmac mac-keysz=20 mac-tagsz=10
+])
+
+  AT_DATA([algs-beta-new], [dnl
+kx-group=ec kx-group-order-bits=161 kx-group-elt-bits=320
+hash=rmd160 mgf=rmd160-mgf hash-sz=20
+cipher=blowfish-cbc cipher-keysz=20 cipher-blksz=8
+cipher-data-limit=67108864
+mac=rmd160-hmac mac-keysz=20 mac-tagsz=10
+])
+
+  cp algs-alpha expout;    AT_CHECK([TRIPECTL -dalice ALGS],,       [expout])
+  cp algs-beta-old expout; AT_CHECK([TRIPECTL -dalice ALGS carol],, [expout])
+  cp algs-beta-old expout; AT_CHECK([TRIPECTL -dbob   ALGS carol],, [expout])
+  cp algs-beta-new expout; AT_CHECK([TRIPECTL -dcarol ALGS],,       [expout])
+  cp algs-beta-old expout; AT_CHECK([TRIPECTL -dcarol ALGS alice],, [expout])
+
+  ## Now copy the full keys.  We expect this to provoke key exchange.
+  for p in $princs; do
+    TRIPECTL -d$p WARN test COMMENT tweak beta step 2
+  done
+
+  for p in $princs; do cp keyring keyring.pub $p/; done
+
+  AWAIT_KXDONE([alice], [alice], [carol], [carol], [
+    TRIPECTL -dalice RELOAD
+    AWAIT_KXDONE([bob], [bob], [carol], [carol], [
+      TRIPECTL -dbob RELOAD
+      TRIPECTL -dcarol RELOAD
+    ])
+  ])
+
+  cp algs-alpha expout;    AT_CHECK([TRIPECTL -dalice ALGS],,       [expout])
+  cp algs-beta-new expout; AT_CHECK([TRIPECTL -dalice ALGS carol],, [expout])
+  cp algs-beta-new expout; AT_CHECK([TRIPECTL -dbob   ALGS carol],, [expout])
+  cp algs-beta-new expout; AT_CHECK([TRIPECTL -dcarol ALGS],,       [expout])
+])
+
+AT_CLEANUP
+
 ###--------------------------------------------------------------------------
 ### Services.
 
index 73a7429ad51d2045eb02e4d91ce53070b5c84534..09387aac78a08b8602d3d42707651e4973618fff 100644 (file)
@@ -40,6 +40,6 @@ autotest_TESTS                += $(top_srcdir)/keys/tests.at
 ### Test files.
 
 ## Keyring files.
-EXTRA_DIST             += keyring-alpha keyring-beta
+EXTRA_DIST             += keyring-alpha keyring-beta keyring-beta-new
 
 ###----- That's all, folks --------------------------------------------------
index 936d75f937729543ade0060ef84ec566f39f591f..fe5f97520db686ae0401002ac6f1e084ffb787a8 100644 (file)
@@ -1,4 +1,5 @@
 65604204:tripe-ec:bob struct:[p=ec,public:0x6df064afcdc923160114d2919f014bcef1051bf5cb3071194088a10be4f0c992,0xea0f0b538cb3ad46d07d9b83eff95458b691bdfbf09188ccd7b0758bebd8f107,private=struct:[x=integer,private,burn:26559628286452801356420934030260728558957937100654818426187327519091722521190],curve=string,shared:nist%2dp256] forever forever -
 b10d3366:tripe-ec-param struct:[curve=string,shared:nist%2dp256] forever forever -
+1aac2ad7:tripe-ec:bob-new struct:[p=ec,public:0xebf0cb581592dc6244a47e9d2e6bc79f76ecb9e5f6e34d69f9f0d07eab188351,0xa6ec5ff761242a0eef1565fd7a6604dbab7b4a0552226b60f2359bccd3e80f48,private=struct:[x=integer,private,burn:15276384741843750980963471236080551062792600396841148726840678168354415102951],curve=string,shared:nist%2dp256] forever forever -
 ec1faca7:tripe-ec:alice struct:[p=ec,public:0xa886b00e1457196c1fd91f11a94cf4a081169602c5e2b576d4182eca470ec253,0xb0fa9a01d4205c912d97c4b4c8d8c5e0af869bd7cdef2139aff7579ca590b4c2,private=struct:[x=integer,private,burn:27337377592101678962721737273774069706724348359128065055711824790983665511674],curve=string,shared:nist%2dp256] forever forever -
 73bad30f:tripe-ec:carol struct:[p=ec,public:0xac7b854c5e38a74a005a8940cfe7e9cac692bfb12316de782167632b38ced9fc,0xc4467936d15ba07f4ca5e6a7bbf2afb526dec70de0f0ad78f74010e0998a66cd,private=struct:[x=integer,private,burn:62821717637637708743367607162182045550925703241285672642684065475493697147942],curve=string,shared:nist%2dp256] forever forever -
diff --git a/t/keyring-beta-new b/t/keyring-beta-new
new file mode 100644 (file)
index 0000000..a7a1bd9
--- /dev/null
@@ -0,0 +1,4 @@
+000f1070:tripe-ec-param struct:[curve=string,shared:secp160r1] forever forever -
+63803f04:tripe-ec:carol struct:[p=ec,public:0x42a11d34a1e19a69222a67c6ec29ff1d421cb021,0xc7d35a6dc9c330a09ee8e30680397b8bf51c29de,private=struct:[x=integer,private,burn:964893088925854502228477969935127891578649410999],curve=string,shared:secp160r1] forever forever -
+4045911b:tripe-ec:bob struct:[p=ec,public:0xcfc0b74fe1c4f30ced726bb70fbe4592ed8456ba,0x351d4dcbc200ccd3f3b6f4ecc112ecbf2043402d,private=struct:[x=integer,private,burn:333869955870933965311262832506583263321304092611],curve=string,shared:secp160r1] forever forever -
+e1a55f0e:tripe-ec:alice struct:[p=ec,public:0xce3bdc518066042b19083e2d27b0ded1915cb6b9,0xadef0e2006072f7bf038ef608e039a47e5767070,private=struct:[x=integer,private,burn:184161721501402669384082492238940360070520035996],curve=string,shared:secp160r1] forever forever -