[patch] vmod_digest (message digests and encoders for VCL)

Nils Goroll slink at schokola.de
Thu Oct 28 14:34:00 CEST 2010


Hi,

I have now finished a first version of vmod_digest. From the .rst file:


			--- 8< ---

SYNOPSIS
========

        import digest;

        digest.DIGEST_ENCODER(STRING)

        digest.encode_ENCODER(STRING)

Common use cases:

        digest.sha256_hexlc(STRING)

        digest.md5_hexlc(STRING)

        digest.encode_base64(STRING)

DESCRIPTION
===========

The digest module makes message digest (hashing) functions available
for use from VCLs. As a side-product, it also provides various string
encoders.

The provided functions are named according to the scheme given in the
synopsis.

			--- 8< ---


I'd appreciate reviews, constructive criticism and suggestions for improvements.


Implementation notes:

* Byte order for sha256 and md5 is little endian. I wanted to verify the
  implementation on a SPARC machine but had to realize that at this point
  varnish does not at all work on this platform, probably due to memory
  alignment errors. I will try to find time to look into this, make varnish
  work on SPARC and check the implementation as a side effect.

  I can't give a time frame for this.

* I've added a base64 encoder and also modified the base64 decoder by phk to
  return the correct length of the decoded byte stream.

  base64_encode went into libvarnishapi because I thought it would be a good
  idea to have it next to base64_decode

* the crc32 code is phk's implementation originally used for hashing of cache
  objects in Varnish, md5 is from FreeBSD

  At this point, only vmod_digests uses crc32 and md5, but should other
  components need those as well, it should be easy to move the code (into
  something like libvmd)

* All of the VCC glue code is generated by a simplistic python script which
  evolved from vcc.py. I wanted to retain vcc.py, so this script generates
  imput to vcc.py.

* The patch contains my first ever rst file. Any improvements welcome.

Thanks, Nils
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: vmod_digest.patch
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20101028/58a443ce/attachment-0003.ksh>


More information about the varnish-dev mailing list