Redo the crypto to bring things in sync with the spec.  Seems to work, needs cleanups.