Adding new hash types to Stephanie for OpenBSD 3.6
--------------------------------------------------

Due to the way Stephanie for OpenBSD 3.6 is designed, it's even easier now
to add new hash types if your implementation needs them.

The OpenBSD kernel's generic interface to hashing routines is compiled of
three actions: Init, Update, and Final. The naming convention of these is
usually HASHInit, HASHUpdate, and HASHFinal or HASH_Init, HASH_Update, and
HASH_Final. Why this is semi-important you'll see later on.

Your first step would be to make sure the hashing mechanism you add comply
with the above described interface or at least provides wrappers for it.
Stephanie for OpenBSD 3.6 *can* make use of non-compliant hashing
mechanisms but it just won't be as easy.

For example, the hash we'll add now will be called 'FOO1337.' The kernel
interface will be FOO1337_Init, FOO1337_Update, and FOO1337_Final.

First make some changes to vexec.h (/usr/src/sys/sys/vexec.h AND
/usr/include/sys/vexec.h)

  - Add an #include directive for your hash's header.
  - Add a FPTYPE_FOO1337 entry with a new unique value.
  - Add a FPLEN_FOO1337 entry with the binary digest length. Adjust
    FPLEN_MAX if needed.

Then you'll have to make the userland parser aware of the new hash type.
Open ~/Stephanie-3.6/vexecctl/parse.y and look for the first appearance
'vexec_hashmaps.' Add just above the '{ 0, NULL, 0 },' entry the one
corresponding your new hash type. First element is the type name as
previously defined, followed by a string of how you want the parser to
recognize that type by, and the length. (also previously defined) In
our example:

	{ FPTYPE_FOO1337, "foo1337", FPLEN_FOO1337 },

And finally, add an entry to /usr/src/sys/kern/kern_vexec.c's
vexec_hash_list array. This is why I previously mentioned the most common
naming conventions and why it would be easier if you used them.

The 'vexec_hash_list' array stores information needed inside the kernel
to perform per-hash type operations. This includes type, length, binary
digest size, and function pointers. (to Init, Update, and Final)

Stephanie defines two macros to help you add a vexec_hash_list entry for
your hash if you used any of the previously described common naming
conventions - VEXEC_HASHINIT() (for HASHInit, etc.) and VEXEC_HASHINIT2()
(for HASH_Init etc.) If you did, it comes down to an entry in the form
of:

	{ VEXEC_HASHINIT(FOO1337) },

(or VEXEC_HASHINIT2(FOO1337), of course.)

If you didn't, however, follow the Init/Update/Final naming conventions,
you can manually add the entry in the following form:

	{ FPTYPE_FOO1337, FPLEN_FOO1337, sizeof(FOO1337_CTX), \
	  (VEXEC_INIT_FN) FOO1337_Start, (VEXEC_UPDATE_FN) FOO1337_Add, \
	  (VEXEC_FINAL_FN) FOO1337_End) },

Note that the only reason for you to use this is when the naming alone
differs, and not the way the hashing works. For deeper modifications
you'll have to make code changes that I believe you'll pick up yourself.
