Digests and data encoding in Varnish

Nils Goroll slink at schokola.de
Mon Sep 27 12:53:10 CEST 2010


Hi,

I need some generic way to handle message digests in Varnish, something like

	if (digest(SHA1, req.http.a) == req.http.b)

While it would be easy to implement VCL functions (preferrably in a module) for
such digests always returning a STRING representation with some encoding (base64
or whatever), for the VSLP director (which I briefly introduced here some time
ago and which we will publish when an important rewrite is done), it would be
really handy to also get an INT (or, more specifically, UINT32) representation
for digests.

Also it would be nice if

	if (digest(SHA1, req.http.a) == digest(SHA1, req.http.b))

would need a de-tour via ASCII encoding and also I will need to choose the
encoding as in

	set req.http.foo = encode(BASE64, digest(SHA1, "abc" + "def" + now));

As mentioned, I need this feature, so if no one else wants to work on it, I'd
look after the implementation, but, most importantly, I'd like to ask for the
core developers' advice on how to proceed.

My suggestion is to

* add two types to the vcc/vrt code:
  - DIGEST representing a message digest
  - DATA representing opaque data

* implement the actual functions in two vmods:
  - vmod_digest.c  for the actual message digests and
  - vmod_dataenc.c for the ascii-armor tools

The DIGEST would be represented as a struct with a type selector and some
implementation-private data. DATA would just represent any data, which functions
from vmod_codec.c would convert to and from some string (or other) representation.

Is this a good idea or not? Any comments, suggestions?
Does the core team support this suggestion?

Thanks, Nils




More information about the varnish-dev mailing list