git: hammer2 hammer2 - Crypto handshake work for message stream

Matthew Dillon dillon at
Sat May 12 01:02:39 PDT 2012

commit 62efe6ec4de59dc37e5790107c400be430d3bc49
Author: Matthew Dillon <dillon at>
Date:   Sat May 12 00:43:26 2012 -0700

    hammer2 - Crypto handshake work for message stream
    * 'hammer2 debug' can now take a destination host argument (and will
      default to localhost).  This is the debug shell connection.
    * Add 'hammer2 rsainit' to initialize hammer2's keys /etc/hammer2/rsa.*
    * Change the 'hammer2 node' directive to 'hammer2 service'.
    * Flesh out the initial public key exchange handshake.  Currently the
      handshake consists of a symmetric 512 byte write and 512 byte read.
      The data is encrypted with our private key and the remote end's public
      Currently a very simple verifier has been constructed, but we will
      ultimately want to use sha or md5 or something like that for the
      Since I am doing a double-encryption here the first stage encrypt
      has to check that the result does not exceed the modulus (typically
      bit 7 of the first byte must be zero).  If it does we increment
      a 32 bit quantity in our pad*[] area and retry until we get a good
    * The exchange is used to calculate the AES session key.  Session
      encryption is not yet implemented.  A random session key is sent
      by both ends.  The actual session key will be the XOR of the one
      we send and the one we receive.
    * When a connection is accepted the remote end's public key is looked
      up in /etc/hammer2/remotes/<IP>.pub.  If this file does not exist
      then the connection is not allowed.

Summary of changes:
 sbin/hammer2/Makefile                      |   10 +-
 sbin/hammer2/cmd_debug.c                   |   16 +-
 sbin/hammer2/cmd_rsa.c                     |  382 +++++++++++++++++++++++++++
 sbin/hammer2/{cmd_node.c => cmd_service.c} |   58 +++-
 sbin/hammer2/crypto.c                      |  387 ++++++++++++++++++++++++++++
 sbin/hammer2/hammer2.h                     |   14 +-
 sbin/hammer2/main.c                        |   62 ++++-
 sbin/hammer2/msg.c                         |    9 +
 sbin/hammer2/network.h                     |   64 ++++-
 sbin/newfs_hammer2/newfs_hammer2.c         |   14 +-
 sys/vfs/hammer2/DESIGN                     |   92 +++++--
 sys/vfs/hammer2/hammer2_disk.h             |   25 +-
 sys/vfs/hammer2/hammer2_vfsops.c           |    2 +-
 13 files changed, 1059 insertions(+), 76 deletions(-)
 create mode 100644 sbin/hammer2/cmd_rsa.c
 rename sbin/hammer2/{cmd_node.c => cmd_service.c} (79%)
 create mode 100644 sbin/hammer2/crypto.c

DragonFly BSD source repository

More information about the Commits mailing list